Package jetbrains.buildServer.util
Interface HTTPRequestBuilder.Response
-
- All Superinterfaces:
AutoCloseable
- Enclosing class:
- HTTPRequestBuilder
public static interface HTTPRequestBuilder.Response extends AutoCloseable
Representation of http(s) response.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description String
getBodyAsString()
Return response content asString
.String
getBodyAsString(String defaultCharsetName)
Return response content asString
.String
getBodyAsStringLimit(int limit)
default long
getContentLength()
Return content length.InputStream
getContentStream()
Return response content asInputStream
.String
getHeader(String headerName)
Return header by its name.int
getStatusCode()
Return response's status code.String
getStatusText()
Return response's status text.URI
getUri()
Requested URI.-
Methods inherited from interface java.lang.AutoCloseable
close
-
-
-
-
Method Detail
-
getUri
@NotNull URI getUri()
Requested URI.
-
getContentStream
@Nullable InputStream getContentStream() throws IOException
Return response content asInputStream
. WARN: Each call returns the same stream. You do not have to close is- Returns:
- response content as
InputStream
- Throws:
IOException
- in case of IO exception while getting a response content.
-
getBodyAsString
@Nullable String getBodyAsString() throws IOException
Return response content asString
.- Returns:
- response content as
String
- Throws:
IOException
- in case of IO exception while getting a response content.
-
getBodyAsString
@Nullable String getBodyAsString(@Nullable String defaultCharsetName) throws IOException
Return response content asString
. Use defaultCharset if none is specified- Parameters:
defaultCharsetName
- a charset to use if no charset is specified in the response header- Returns:
- response content as
String
- Throws:
IOException
- in case of IO exception while getting a response content.
-
getBodyAsStringLimit
@Nullable String getBodyAsStringLimit(int limit) throws IOException
- Throws:
IOException
-
getStatusCode
int getStatusCode()
Return response's status code.
-
getStatusText
@NotNull String getStatusText()
Return response's status text.
-
getHeader
@Nullable String getHeader(@NotNull String headerName)
Return header by its name.- Parameters:
headerName
- name of header to search- Returns:
- header with specified name or null if such header is not exists
-
getContentLength
default long getContentLength()
Return content length. In general it is a value from Content-Length header.- Returns:
- content length or value below zero if we can not get it
-
-