Top Description Methods
org.eclipse.jetty.client

public Interface ContentResponse

extends Response
Known Direct Implementers
org.eclipse.jetty.client.internal.HttpContentResponse
Imports
org.eclipse.jetty.client.internal.HttpContentResponse

A specialized Response that can hold a limited content in memory.

Method Summary

Modifier and TypeMethod and Description
public static ContentResponse
from(Response
the Response with status code and headers
response
,
byte[]
the content bytes associated to the response
content
,
String
the media type of the content bytes
mediaType
,
String
the encoding of the content bytes
encoding
)

Returns: a new ContentResponse from the given arguments

public byte[]
getContent()

Returns: the response content

public String
getContentAsString()

Returns: the response content as a string, decoding the bytes using the charset provided by the Content-Type header, if any, or UTF-8.

public String
getEncoding()

Returns: the encoding of the content, such as "UTF-8"

public String
getMediaType()

Returns: the media type of the content, such as "text/html" or "application/octet-stream"

Inherited from org.eclipse.jetty.client.Response:
abortgetHeadersgetReasongetRequestgetStatusgetTrailersgetVersion

Method Detail

fromback to summary
public static ContentResponse from(Response response, byte[] content, String mediaType, String encoding)
Parameters
response:Response

the Response with status code and headers

content:byte[]

the content bytes associated to the response

mediaType:String

the media type of the content bytes

encoding:String

the encoding of the content bytes

Returns:ContentResponse

a new ContentResponse from the given arguments

getContentback to summary
public byte[] getContent()
Returns:byte[]

the response content

getContentAsStringback to summary
public String getContentAsString()
Returns:String

the response content as a string, decoding the bytes using the charset provided by the Content-Type header, if any, or UTF-8.

getEncodingback to summary
public String getEncoding()
Returns:String

the encoding of the content, such as "UTF-8"

getMediaTypeback to summary
public String getMediaType()
Returns:String

the media type of the content, such as "text/html" or "application/octet-stream"