Package kong.unirest.core.java
Class JavaResponse
java.lang.Object
kong.unirest.core.RawResponseBase
kong.unirest.core.java.JavaResponse
- All Implemented Interfaces:
RawResponse
-
Field Summary
FieldsFields inherited from class kong.unirest.core.RawResponseBase
config
-
Constructor Summary
ConstructorsConstructorDescriptionJavaResponse
(HttpResponse<InputStream> response, Config config, HttpRequestSummary summary) -
Method Summary
Modifier and TypeMethodDescriptionprivate static byte[]
getBytes
(InputStream is) private String
getCharset
(String charset) Returns the body content of the response as a InputStream.byte[]
Returns the body as bytes.Returns the body as UTF-8 String.getContentAsString
(String charset) Returns the body as UTF-8 String.Returns the body content of the response as a InputStreamReader.Returns the mime type of the response content as indicated by the Content-Type header or a empty string if none is supplied (e.g.Returns the encoding of the response as indicated by the Content-Encoding header or returns a empty string if none provided.Returns the received response headers.int
Returns the status code for this response.Returns the status text for this response.boolean
Indicates that the response has contentprivate static boolean
Methods inherited from class kong.unirest.core.RawResponseBase
getCharSet, getConfig, getRequestSummary, toSummary
-
Field Details
-
response
-
-
Constructor Details
-
JavaResponse
-
-
Method Details
-
getStatus
public int getStatus()Description copied from interface:RawResponse
Returns the status code for this response.- Returns:
- the response code
-
getStatusText
Description copied from interface:RawResponse
Returns the status text for this response.- Returns:
- the response text
-
getHeaders
Description copied from interface:RawResponse
Returns the received response headers.- Returns:
- the response headers
-
getContent
Description copied from interface:RawResponse
Returns the body content of the response as a InputStream. Like most InputStreams it can only be read once. If you read the response though some other method like getContentAsBytes() or getBodyAsString() it will read this method and consume the InputStream- Returns:
- the content
-
getContentAsBytes
public byte[] getContentAsBytes()Description copied from interface:RawResponse
Returns the body as bytes. This consumes the entire InputStream. Warning: Calling this on very large responses will place all data in memory and could create OutOfMemory errors- Returns:
- the content as bytes
-
getBytes
- Throws:
IOException
-
isGzipped
-
getContentAsString
Description copied from interface:RawResponse
Returns the body as UTF-8 String. This consumes the entire InputStream. Warning: Calling this on very large responses will place all data in memory and could create OutOfMemory errors Using this method with a binary response will make you sad- Returns:
- the content as a UTF-8 String
-
getContentAsString
Description copied from interface:RawResponse
Returns the body as UTF-8 String. This consumes the entire InputStream. Warning: Calling this on very large responses will place all data in memory and could create OutOfMemory errors Using this method with a binary response will make you sad- Parameters:
charset
- the charset for the String- Returns:
- the content as a string in the provided charset.
-
getCharset
-
getContentReader
Description copied from interface:RawResponse
Returns the body content of the response as a InputStreamReader. Like most InputStreams it can only be read once. If you read the response though some other method like getContentAsBytes() or getBodyAsString() it will read this method and consume the InputStream- Returns:
- the content
-
hasContent
public boolean hasContent()Description copied from interface:RawResponse
Indicates that the response has content- Returns:
- boolean indicating that the response has content.
-
getContentType
Description copied from interface:RawResponse
Returns the mime type of the response content as indicated by the Content-Type header or a empty string if none is supplied (e.g. application/json)- Returns:
- the Content-Type
-
getEncoding
Description copied from interface:RawResponse
Returns the encoding of the response as indicated by the Content-Encoding header or returns a empty string if none provided.- Returns:
- the encoding
-