Top Description Inners Methods
org.eclipse.jetty.client

public Interface Response

Known Direct Subinterfaces
org.eclipse.jetty.client.ContentResponse
Known Direct Implementers
org.eclipse.jetty.client.transport.HttpResponse
Imports
java.nio.ByteBuffer, java.util.EventListener, java.util.concurrent.CompletableFuture, org.eclipse.jetty.http.HttpField, .HttpFields, .HttpVersion, org.eclipse.jetty.io.Content

Response represents an HTTP response and offers methods to retrieve status code, HTTP version and headers.

Response objects are passed as parameters to Response.Listener callbacks, or as future result of Request#send().

Response objects do not contain getters for the response content, because it may be too large to fit into memory. The response content should be retrieved via content events, or via utility classes such as BufferingResponseListener.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Response.AsyncContentListener

Asynchronous listener for the response content events.

public static interface
Response.BeginListener

Listener for the response begin event.

public static interface
Response.CompleteListener

Listener for the request and response completed event.

public static interface
Response.ContentListener

Synchronous listener for the response content events.

public static interface
Response.ContentSourceListener

Asynchronous listener for the response content events.

public static interface
Response.FailureListener

Listener for the response failure event.

public static interface
Response.HeaderListener

Listener for a response header event.

public static interface
Response.HeadersListener

Listener for the response headers event.

public static interface
Response.Listener

Listener for all response events.

public static interface
Response.ResponseListener

Common, empty, super-interface for response listeners

public static interface
Response.SuccessListener

Listener for the response succeeded event.

Method Summary

Modifier and TypeMethod and Description
public CompletableFuture<Boolean>

Returns:

whether the abort succeeded
abort
(Throwable
the abort cause, must not be null
cause
)

Attempts to abort the receive of this response.

public HttpFields

Returns:

the headers of this response
getHeaders
()

Returns the headers of this response.

public String

Returns:

the HTTP reason associated to the getStatus
getReason
()

public Request

Returns:

the request associated with this response
getRequest
()

public int

Returns:

the HTTP status code of this response, such as 200 or 404
getStatus
()

public HttpFields

Returns:

the trailers of this response
getTrailers
()

public HttpVersion

Returns:

the HTTP version of this response, such as "HTTP/1.1"
getVersion
()

Method Detail

abortback to summary
public CompletableFuture<Boolean> abort(Throwable cause)

Attempts to abort the receive of this response.

Parameters
cause:Throwable

the abort cause, must not be null

Returns:CompletableFuture<Boolean>

whether the abort succeeded

getHeadersback to summary
public HttpFields getHeaders()

Returns the headers of this response.

Some headers sent by the server may not be present, or be present but modified, while the content is being processed. A typical example is the Content-Length header when the content is sent compressed by the server and automatically decompressed by the client: the Content-Length header will be removed.

Similarly, the Content-Encoding header may be removed or modified, as the content is decoded by the client.

Returns:HttpFields

the headers of this response

getReasonback to summary
public String getReason()
Returns:String

the HTTP reason associated to the getStatus

getRequestback to summary
public Request getRequest()
Returns:Request

the request associated with this response

getStatusback to summary
public int getStatus()
Returns:int

the HTTP status code of this response, such as 200 or 404

getTrailersback to summary
public HttpFields getTrailers()
Returns:HttpFields

the trailers of this response

getVersionback to summary
public HttpVersion getVersion()
Returns:HttpVersion

the HTTP version of this response, such as "HTTP/1.1"

org.eclipse.jetty.client back to summary

public Interface Response.AsyncContentListener

extends ContentSourceListener
Known Direct Subinterfaces
org.eclipse.jetty.client.Response.ContentListener

Asynchronous listener for the response content events.
See Also
ContentSourceListener

Method Summary

Modifier and TypeMethod and Description
public void
onContent(Response response, Content.Chunk chunk, Runnable demander)

public default void
onContentSource(Response
the response containing the response line data and the headers
response
,
Content.Source
the Content.Source that must be driven to read the data
contentSource
)

Implements org.eclipse.jetty.client.Response.ContentSourceListener.onContentSource.

Callback method invoked when all the response headers have been received and parsed.

Method Detail

onContentback to summary
public void onContent(Response response, Content.Chunk chunk, Runnable demander)
onContentSourceback to summary
public default void onContentSource(Response response, Content.Source contentSource)

Implements org.eclipse.jetty.client.Response.ContentSourceListener.onContentSource.

Doc from org.eclipse.jetty.client.Response.ContentSourceListener.onContentSource.

Callback method invoked when all the response headers have been received and parsed. It is responsible for driving the contentSource instance with a read/demand loop. Note that this is not invoked for interim statuses.

Parameters
response:Response

the response containing the response line data and the headers

contentSource:Content.Source

the Content.Source that must be driven to read the data

Annotations
@Override
org.eclipse.jetty.client back to summary

public Interface Response.BeginListener

extends ResponseListener
Known Direct Subinterfaces
org.eclipse.jetty.client.Response.Listener

Listener for the response begin event.

Method Summary

Modifier and TypeMethod and Description
public void
onBegin(Response
the response containing the response line data
response
)

Callback method invoked when the response line containing HTTP version, HTTP status code and reason has been received and parsed.

Method Detail

onBeginback to summary
public void onBegin(Response response)

Callback method invoked when the response line containing HTTP version, HTTP status code and reason has been received and parsed.

This method is the best approximation to detect when the first bytes of the response arrived to the client.

Parameters
response:Response

the response containing the response line data

org.eclipse.jetty.client back to summary

public Interface Response.CompleteListener

extends ResponseListener
Known Direct Subinterfaces
org.eclipse.jetty.client.Response.Listener

Listener for the request and response completed event.

Method Summary

Modifier and TypeMethod and Description
public void
onComplete(Result
the result of the request / response exchange
result
)

Callback method invoked when the request and the response have been processed, either successfully or not.

Method Detail

onCompleteback to summary
public void onComplete(Result result)

Callback method invoked when the request and the response have been processed, either successfully or not.

The result parameter contains the request, the response, and eventual failures.

Requests may complete after response, for example in case of big uploads that are discarded or read asynchronously by the server. This method is always invoked after SuccessListener#onSuccess(Response) or FailureListener#onFailure(Response, Throwable), and only when request indicates that it is completed.

Parameters
result:Result

the result of the request / response exchange

org.eclipse.jetty.client back to summary

public Interface Response.ContentListener

extends AsyncContentListener
Known Direct Subinterfaces
org.eclipse.jetty.client.Response.Listener

Synchronous listener for the response content events.
See Also
AsyncContentListener

Method Summary

Modifier and TypeMethod and Description
public void
onContent(Response
the response containing the response line data and the headers
response
,
ByteBuffer
the content bytes received
content
)

Callback method invoked when the response content has been received, parsed and there is demand.

public default void
Inherited from org.eclipse.jetty.client.Response.AsyncContentListener:
onContentSource

Method Detail

onContentback to summary
public void onContent(Response response, ByteBuffer content)

Callback method invoked when the response content has been received, parsed and there is demand. This method may be invoked multiple times, and the content buffer must be consumed (or copied) before returning from this method.

Parameters
response:Response

the response containing the response line data and the headers

content:ByteBuffer

the content bytes received

onContentback to summary
public default void onContent(Response response, Content.Chunk chunk, Runnable demander)

Implements org.eclipse.jetty.client.Response.AsyncContentListener.onContent.

Annotations
@Override
org.eclipse.jetty.client back to summary

public Interface Response.ContentSourceListener

extends ResponseListener
Known Direct Subinterfaces
org.eclipse.jetty.client.Response.AsyncContentListener
Known Direct Implementers
org.eclipse.jetty.client.transport.ResponseListeners.ContentSourceDemultiplexer

Asynchronous listener for the response content events.

Method Summary

Modifier and TypeMethod and Description
public void
onContentSource(Response
the response containing the response line data and the headers
response
,
Content.Source
the Content.Source that must be driven to read the data
contentSource
)

Callback method invoked when all the response headers have been received and parsed.

Method Detail

onContentSourceback to summary
public void onContentSource(Response response, Content.Source contentSource)

Callback method invoked when all the response headers have been received and parsed. It is responsible for driving the contentSource instance with a read/demand loop. Note that this is not invoked for interim statuses.

Parameters
response:Response

the response containing the response line data and the headers

contentSource:Content.Source

the Content.Source that must be driven to read the data

org.eclipse.jetty.client back to summary

public Interface Response.FailureListener

extends ResponseListener
Known Direct Subinterfaces
org.eclipse.jetty.client.Response.Listener

Listener for the response failure event.

Method Summary

Modifier and TypeMethod and Description
public void
onFailure(Response
the response containing data up to the point the failure happened
response
,
Throwable
the failure happened
failure
)

Callback method invoked when the response has failed in the process of being received

Method Detail

onFailureback to summary
public void onFailure(Response response, Throwable failure)

Callback method invoked when the response has failed in the process of being received

Parameters
response:Response

the response containing data up to the point the failure happened

failure:Throwable

the failure happened

org.eclipse.jetty.client back to summary

public Interface Response.HeaderListener

extends ResponseListener
Known Direct Subinterfaces
org.eclipse.jetty.client.Response.Listener

Listener for a response header event.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true to process the header, false to skip processing of the header
onHeader
(Response
the response containing the response line data and the headers so far
response
,
HttpField
the header received
field
)

Callback method invoked when a response header has been received and parsed, returning whether the header should be processed or not.

Method Detail

onHeaderback to summary
public boolean onHeader(Response response, HttpField field)

Callback method invoked when a response header has been received and parsed, returning whether the header should be processed or not.

Parameters
response:Response

the response containing the response line data and the headers so far

field:HttpField

the header received

Returns:boolean

true to process the header, false to skip processing of the header

org.eclipse.jetty.client back to summary

public Interface Response.HeadersListener

extends ResponseListener
Known Direct Subinterfaces
org.eclipse.jetty.client.Response.Listener

Listener for the response headers event.

Method Summary

Modifier and TypeMethod and Description
public void
onHeaders(Response
the response containing the response line data and the headers
response
)

Callback method invoked when all the response headers have been received and parsed.

Method Detail

onHeadersback to summary
public void onHeaders(Response response)

Callback method invoked when all the response headers have been received and parsed.

Parameters
response:Response

the response containing the response line data and the headers

org.eclipse.jetty.client back to summary

public Interface Response.Listener

extends BeginListener, HeaderListener, HeadersListener, ContentListener, SuccessListener, FailureListener, CompleteListener
Known Direct Implementers
org.eclipse.jetty.client.AuthenticationProtocolHandler.AfterAuthenticationListener, org.eclipse.jetty.client.BufferingResponseListener, org.eclipse.jetty.client.HttpProxy.CreateTunnelPromise.TunnelListener, org.eclipse.jetty.client.InputStreamResponseListener, org.eclipse.jetty.client.RedirectProtocolHandler

Listener for all response events.

Method Summary

Modifier and TypeMethod and Description
public default void
onBegin(Response
the response containing the response line data
response
)

Implements org.eclipse.jetty.client.Response.BeginListener.onBegin.

Callback method invoked when the response line containing HTTP version, HTTP status code and reason has been received and parsed.
public default void
onComplete(Result
the result of the request / response exchange
result
)

Implements org.eclipse.jetty.client.Response.CompleteListener.onComplete.

Callback method invoked when the request and the response have been processed, either successfully or not.
public default void
onContent(Response
the response containing the response line data and the headers
response
,
ByteBuffer
the content bytes received
content
)

Implements org.eclipse.jetty.client.Response.ContentListener.onContent.

Callback method invoked when the response content has been received, parsed and there is demand.
public default void
onFailure(Response
the response containing data up to the point the failure happened
response
,
Throwable
the failure happened
failure
)

Implements org.eclipse.jetty.client.Response.FailureListener.onFailure.

Callback method invoked when the response has failed in the process of being received
public default boolean
onHeader(Response
the response containing the response line data and the headers so far
response
,
HttpField
the header received
field
)

Implements org.eclipse.jetty.client.Response.HeaderListener.onHeader.

Callback method invoked when a response header has been received and parsed, returning whether the header should be processed or not.
public default void
onHeaders(Response
the response containing the response line data and the headers
response
)

Implements org.eclipse.jetty.client.Response.HeadersListener.onHeaders.

Callback method invoked when all the response headers have been received and parsed.
public default void
onSuccess(Response
the response containing the response line data and the headers
response
)

Implements org.eclipse.jetty.client.Response.SuccessListener.onSuccess.

Callback method invoked when the whole response has been successfully received.
Inherited from org.eclipse.jetty.client.Response.ContentListener:
onContent

Method Detail

onBeginback to summary
public default void onBegin(Response response)

Implements org.eclipse.jetty.client.Response.BeginListener.onBegin.

Doc from org.eclipse.jetty.client.Response.BeginListener.onBegin.

Callback method invoked when the response line containing HTTP version, HTTP status code and reason has been received and parsed.

This method is the best approximation to detect when the first bytes of the response arrived to the client.

Parameters
response:Response

the response containing the response line data

Annotations
@Override
onCompleteback to summary
public default void onComplete(Result result)

Implements org.eclipse.jetty.client.Response.CompleteListener.onComplete.

Doc from org.eclipse.jetty.client.Response.CompleteListener.onComplete.

Callback method invoked when the request and the response have been processed, either successfully or not.

The result parameter contains the request, the response, and eventual failures.

Requests may complete after response, for example in case of big uploads that are discarded or read asynchronously by the server. This method is always invoked after SuccessListener#onSuccess(Response) or FailureListener#onFailure(Response, Throwable), and only when request indicates that it is completed.

Parameters
result:Result

the result of the request / response exchange

Annotations
@Override
onContentback to summary
public default void onContent(Response response, ByteBuffer content)

Implements org.eclipse.jetty.client.Response.ContentListener.onContent.

Doc from org.eclipse.jetty.client.Response.ContentListener.onContent.

Callback method invoked when the response content has been received, parsed and there is demand. This method may be invoked multiple times, and the content buffer must be consumed (or copied) before returning from this method.

Parameters
response:Response

the response containing the response line data and the headers

content:ByteBuffer

the content bytes received

Annotations
@Override
onFailureback to summary
public default void onFailure(Response response, Throwable failure)

Implements org.eclipse.jetty.client.Response.FailureListener.onFailure.

Doc from org.eclipse.jetty.client.Response.FailureListener.onFailure.

Callback method invoked when the response has failed in the process of being received

Parameters
response:Response

the response containing data up to the point the failure happened

failure:Throwable

the failure happened

Annotations
@Override
onHeaderback to summary
public default boolean onHeader(Response response, HttpField field)

Implements org.eclipse.jetty.client.Response.HeaderListener.onHeader.

Doc from org.eclipse.jetty.client.Response.HeaderListener.onHeader.

Callback method invoked when a response header has been received and parsed, returning whether the header should be processed or not.

Parameters
response:Response

the response containing the response line data and the headers so far

field:HttpField

the header received

Returns:boolean

true to process the header, false to skip processing of the header

Annotations
@Override
onHeadersback to summary
public default void onHeaders(Response response)

Implements org.eclipse.jetty.client.Response.HeadersListener.onHeaders.

Doc from org.eclipse.jetty.client.Response.HeadersListener.onHeaders.

Callback method invoked when all the response headers have been received and parsed.

Parameters
response:Response

the response containing the response line data and the headers

Annotations
@Override
onSuccessback to summary
public default void onSuccess(Response response)

Implements org.eclipse.jetty.client.Response.SuccessListener.onSuccess.

Doc from org.eclipse.jetty.client.Response.SuccessListener.onSuccess.

Callback method invoked when the whole response has been successfully received.

Parameters
response:Response

the response containing the response line data and the headers

Annotations
@Override
org.eclipse.jetty.client back to summary

public Interface Response.ResponseListener

extends EventListener
Known Direct Subinterfaces
org.eclipse.jetty.client.Response.BeginListener, org.eclipse.jetty.client.Response.HeaderListener, org.eclipse.jetty.client.Response.HeadersListener, org.eclipse.jetty.client.Response.ContentSourceListener, org.eclipse.jetty.client.Response.SuccessListener, org.eclipse.jetty.client.Response.FailureListener, org.eclipse.jetty.client.Response.CompleteListener

Common, empty, super-interface for response listeners
org.eclipse.jetty.client back to summary

public Interface Response.SuccessListener

extends ResponseListener
Known Direct Subinterfaces
org.eclipse.jetty.client.Response.Listener

Listener for the response succeeded event.

Method Summary

Modifier and TypeMethod and Description
public void
onSuccess(Response
the response containing the response line data and the headers
response
)

Callback method invoked when the whole response has been successfully received.

Method Detail

onSuccessback to summary
public void onSuccess(Response response)

Callback method invoked when the whole response has been successfully received.

Parameters
response:Response

the response containing the response line data and the headers