public class RedirectProtocolHandler extends Response.Listener.Adapter implements ProtocolHandler
A protocol handler that handles redirect status codes 301, 302, 303, 307 and 308.
Response.Listener.Adapter
Constructor and Description |
---|
RedirectProtocolHandler(HttpClient client) |
Modifier and Type | Method and Description |
---|---|
boolean |
accept(Request request,
Response response)
Inspects the given
request and response
to detect whether this protocol handler should handle them. |
String |
getName() |
Response.Listener |
getResponseListener() |
void |
onComplete(Result result)
Callback method invoked when the request and the response have been processed,
either successfully or not.
|
public static final String NAME
public RedirectProtocolHandler(HttpClient client)
public String getName()
getName
in interface ProtocolHandler
public boolean accept(Request request, Response response)
ProtocolHandler
Inspects the given request
and response
to detect whether this protocol handler should handle them.
For example, a redirect protocol handler can inspect the response code and return true if it is a redirect response code.
This method is being called just after the response line has been parsed, and before the response headers are available.
accept
in interface ProtocolHandler
request
- the request to acceptresponse
- the response to acceptpublic Response.Listener getResponseListener()
getResponseListener
in interface ProtocolHandler
public void onComplete(Result result)
Response.CompleteListener
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 Response.SuccessListener.onSuccess(Response)
or
Response.FailureListener.onFailure(Response, Throwable)
, and only when request indicates that
it is completed.
onComplete
in interface Response.CompleteListener
onComplete
in class Response.Listener.Adapter
result
- the result of the request / response exchangeCopyright © 1995-2015 Webtide. All Rights Reserved.