public class BlockingResponseListener extends BufferingResponseListener implements Future<ContentResponse>
Response.Listener.Empty
Constructor and Description |
---|
BlockingResponseListener() |
Modifier and Type | Method and Description |
---|---|
boolean |
cancel(boolean mayInterruptIfRunning) |
ContentResponse |
get() |
ContentResponse |
get(long timeout,
TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone() |
void |
onBegin(Response response)
Callback method invoked when the response line containing HTTP version,
HTTP status code and reason has been received and parsed.
|
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 |
onHeaders(Response response)
Callback method invoked when the response headers have been received and parsed.
|
getContent, getContentAsString, getContentAsString, getEncoding
onFailure, onSuccess
public void onBegin(Response response)
Response.Listener
onBegin
in interface Response.Listener
onBegin
in class Response.Listener.Empty
response
- the response containing the response line datapublic void onHeaders(Response response)
Response.Listener
onHeaders
in interface Response.Listener
onHeaders
in class BufferingResponseListener
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 BufferingResponseListener
response
- the response containing the response line data and the headerscontent
- the content bytes receivedpublic 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 boolean cancel(boolean mayInterruptIfRunning)
cancel
in interface Future<ContentResponse>
public boolean isCancelled()
isCancelled
in interface Future<ContentResponse>
public boolean isDone()
isDone
in interface Future<ContentResponse>
public ContentResponse get() throws InterruptedException, ExecutionException
get
in interface Future<ContentResponse>
InterruptedException
ExecutionException
public ContentResponse get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get
in interface Future<ContentResponse>
InterruptedException
ExecutionException
TimeoutException
Copyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.