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 StringgetBodyAsString()Return response content asString.StringgetBodyAsString(String defaultCharsetName)Return response content asString.StringgetBodyAsStringLimit(int limit)default longgetContentLength()Return content length.InputStreamgetContentStream()Return response content asInputStream.StringgetHeader(String headerName)Return header by its name.intgetStatusCode()Return response's status code.StringgetStatusText()Return response's status text.URIgetUri()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
-
-