Package org.apache.juneau.rest.client
Class TransportResponse
java.lang.Object
org.apache.juneau.rest.client.TransportResponse
- All Implemented Interfaces:
Closeable,AutoCloseable
A transport-layer HTTP response.
Produced by HttpTransport.execute(TransportRequest) and consumed by the higher-level
RestResponse.
Callers must close this object (it implements Closeable) after consuming the response body;
transport implementations use the close callback to release connection-pool resources.
- Since:
- 9.2.1
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic TransportResponse.Builderbuilder()Returns a newTransportResponse.Builder.voidclose()getBody()Returns the response body stream, ornullif the response has no body.getFirstHeader(String name) Returns the first header with the given name (case-insensitive), ornullif absent.Returns all response headers.Returns the reason phrase (e.g.intReturns the HTTP status code.
-
Method Details
-
builder
Returns a newTransportResponse.Builder. -
getStatusCode
Returns the HTTP status code.- Returns:
- The status code (e.g.
200).
-
getReasonPhrase
Returns the reason phrase (e.g."OK"), ornullif absent.- Returns:
- The reason phrase, possibly
null .
-
getHeaders
Returns all response headers.- Returns:
- An unmodifiable list. Never
null .
-
getFirstHeader
Returns the first header with the given name (case-insensitive), ornullif absent.- Parameters:
name- The header name. Must not benull .- Returns:
- The first matching header, or
null if absent.
-
getBody
Returns the response body stream, ornullif the response has no body.Callers must not close this stream directly — close the
TransportResponseinstead.- Returns:
- The body stream, possibly
null .
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-