public class InputStreamResponseListener extends Response.Listener.Empty
Response.Listener.Empty
Constructor and Description |
---|
InputStreamResponseListener() |
InputStreamResponseListener(long capacity) |
Modifier and Type | Method and Description |
---|---|
Result |
await(long timeout,
TimeUnit unit) |
Response |
get(long timeout,
TimeUnit unit) |
InputStream |
getInputStream() |
void |
onComplete(Result result)
Callback method invoked when the request and the response have been processed,
either successfully or not.
|
void |
onContent(Response response,
ByteBuffer content)
Callback method invoked when the response content has been received.
|
void |
onFailure(Response response,
Throwable failure)
Callback method invoked when the response has failed in the process of being received
|
void |
onHeaders(Response response)
Callback method invoked when the response headers have been received and parsed.
|
void |
onSuccess(Response response)
Callback method invoked when the whole response has been successfully received.
|
onBegin
public static final Logger LOG
public InputStreamResponseListener()
public InputStreamResponseListener(long capacity)
public void onHeaders(Response response)
Response.Listener
onHeaders
in interface Response.Listener
onHeaders
in class Response.Listener.Empty
response
- the response containing the response line data and the headerspublic void onContent(Response response, ByteBuffer content)
Response.Listener
content
buffer must be consumed
before returning from this method.onContent
in interface Response.Listener
onContent
in class Response.Listener.Empty
response
- the response containing the response line data and the headerscontent
- the content bytes receivedpublic void onFailure(Response response, Throwable failure)
Response.Listener
onFailure
in interface Response.Listener
onFailure
in class Response.Listener.Empty
response
- the response containing data up to the point the failure happenedfailure
- the failure happenedpublic void onSuccess(Response response)
Response.Listener
onSuccess
in interface Response.Listener
onSuccess
in class Response.Listener.Empty
response
- the response containing the response line data and the headerspublic void onComplete(Result result)
Response.Listener
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 Response.Listener.onSuccess(Response)
or
Response.Listener.onFailure(Response, Throwable)
, and only when request indicates that it is completed.onComplete
in interface Response.Listener
onComplete
in class Response.Listener.Empty
result
- the result of the request / response exchangepublic Response get(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException, ExecutionException
public Result await(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException
InterruptedException
TimeoutException
public InputStream getInputStream()
Copyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.