Package kong.unirest.core
Class MockRawResponse
java.lang.Object
kong.unirest.core.MockRawResponse
- All Implemented Interfaces:
RawResponse
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Configprivate final Stringprivate final Headersprivate final intprivate final Stringprivate final HttpRequestSummary -
Constructor Summary
ConstructorsConstructorDescriptionMockRawResponse(String responseBody, Headers responseHeaders, int status, String statusMessage, Config config, HttpRequestSummary summary) -
Method Summary
Modifier and TypeMethodDescriptionReturns the current config for this request/responseReturns 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.returns a lightweight read only summary of the request.intReturns the status code for this response.Returns the status text for this response.booleanIndicates that the response has contentreturns a lightweight read only summary of the response.private CharsettryGetCharset(String charset)
-
Field Details
-
response
-
responseHeaders
-
status
private final int status -
statusMessage
-
config
-
summary
-
-
Constructor Details
-
MockRawResponse
public MockRawResponse(String responseBody, Headers responseHeaders, int status, String statusMessage, Config config, HttpRequestSummary summary)
-
-
Method Details
-
getStatus
public int getStatus()Description copied from interface:RawResponseReturns the status code for this response.- Specified by:
getStatusin interfaceRawResponse- Returns:
- the response code
-
getStatusText
Description copied from interface:RawResponseReturns the status text for this response.- Specified by:
getStatusTextin interfaceRawResponse- Returns:
- the response text
-
getHeaders
Description copied from interface:RawResponseReturns the received response headers.- Specified by:
getHeadersin interfaceRawResponse- Returns:
- the response headers
-
getContent
Description copied from interface:RawResponseReturns 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- Specified by:
getContentin interfaceRawResponse- Returns:
- the content
-
getContentAsBytes
public byte[] getContentAsBytes()Description copied from interface:RawResponseReturns 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- Specified by:
getContentAsBytesin interfaceRawResponse- Returns:
- the content as bytes
-
getContentAsString
Description copied from interface:RawResponseReturns 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- Specified by:
getContentAsStringin interfaceRawResponse- Returns:
- the content as a UTF-8 String
-
getContentAsString
Description copied from interface:RawResponseReturns 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- Specified by:
getContentAsStringin interfaceRawResponse- Parameters:
charset- the charset for the String- Returns:
- the content as a string in the provided charset.
-
tryGetCharset
-
getContentReader
Description copied from interface:RawResponseReturns 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- Specified by:
getContentReaderin interfaceRawResponse- Returns:
- the content
-
hasContent
public boolean hasContent()Description copied from interface:RawResponseIndicates that the response has content- Specified by:
hasContentin interfaceRawResponse- Returns:
- boolean indicating that the response has content.
-
getContentType
Description copied from interface:RawResponseReturns 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)- Specified by:
getContentTypein interfaceRawResponse- Returns:
- the Content-Type
-
getEncoding
Description copied from interface:RawResponseReturns the encoding of the response as indicated by the Content-Encoding header or returns a empty string if none provided.- Specified by:
getEncodingin interfaceRawResponse- Returns:
- the encoding
-
getConfig
Description copied from interface:RawResponseReturns the current config for this request/response- Specified by:
getConfigin interfaceRawResponse- Returns:
- the config
-
toSummary
Description copied from interface:RawResponsereturns a lightweight read only summary of the response.- Specified by:
toSummaryin interfaceRawResponse- Returns:
- the response summary
-
getRequestSummary
Description copied from interface:RawResponsereturns a lightweight read only summary of the request.- Specified by:
getRequestSummaryin interfaceRawResponse- Returns:
- the request summary
-