Class HTTPResponse (2.0.0)

public class HTTPResponse implements Serializable

HTTPResponse encapsulates the results of a HTTPRequest made via the URLFetchService.

Inheritance

java.lang.Object > HTTPResponse

Implements

Serializable

Constructors

HTTPResponse(int responseCode, byte @Nullable [] content, @Nullable URL finalUrl, List<HTTPHeader> headers)

public HTTPResponse(int responseCode, byte @Nullable [] content, @Nullable URL finalUrl, List<HTTPHeader> headers)

Construct an HTTPResponse object.

Parameters
NameDescription
responseCodeint

the HTTP response code

contentbyte @org.checkerframework.checker.nullness.qual.Nullable []

the HTTP response content (can be null)

finalUrl@org.checkerframework.checker.nullness.qual.Nullable java.net.URL

the URL that served the request if redirection was followed (can be null)

headersList<HTTPHeader>

the HTTP response headers

Methods

getContent()

public byte @Nullable [] getContent()

Returns the content of the request, or null if there is no content present (e.g. in a HEAD request).

Returns
TypeDescription
byte @org.checkerframework.checker.nullness.qual.Nullable []

getFinalUrl()

public @Nullable URL getFinalUrl()

Returns the final URL the content came from if redirects were followed automatically in the request, if different than the input URL; otherwise this will be null.

Returns
TypeDescription
@org.checkerframework.checker.nullness.qual.Nullable java.net.URL

getHeaders()

public List<HTTPHeader> getHeaders()

Returns a List of HTTP response headers that were returned by the remote server. Multi-valued headers are represented as a single HTTPHeader with comma-separated values.

Returns
TypeDescription
List<HTTPHeader>

getHeadersUncombined()

public List<HTTPHeader> getHeadersUncombined()

Returns a List of HTTP response headers that were returned by the remote server. These are not combined for repeated values.

Returns
TypeDescription
List<HTTPHeader>

getResponseCode()

public int getResponseCode()

Returns the HTTP response code from the request (e.g. 200, 500, etc.).

Returns
TypeDescription
int