Class RedirectProtocolHandler
- java.lang.Object
-
- org.eclipse.jetty.client.api.Response.Listener.Adapter
-
- org.eclipse.jetty.client.RedirectProtocolHandler
-
- All Implemented Interfaces:
java.util.EventListener
,Response.AsyncContentListener
,Response.BeginListener
,Response.CompleteListener
,Response.ContentListener
,Response.DemandedContentListener
,Response.FailureListener
,Response.HeaderListener
,Response.HeadersListener
,Response.Listener
,Response.ResponseListener
,Response.SuccessListener
,ProtocolHandler
public class RedirectProtocolHandler extends Response.Listener.Adapter implements ProtocolHandler
A protocol handler that handles redirect status codes 301, 302, 303, 307 and 308.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.client.api.Response.Listener
Response.Listener.Adapter
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
NAME
-
Constructor Summary
Constructors Constructor Description RedirectProtocolHandler(HttpClient client)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(Request request, Response response)
Inspects the givenrequest
andresponse
to detect whether this protocol handler should handle them.java.lang.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.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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.client.api.Response.AsyncContentListener
onContent
-
Methods inherited from interface org.eclipse.jetty.client.api.Response.ContentListener
onContent
-
Methods inherited from interface org.eclipse.jetty.client.api.Response.DemandedContentListener
onBeforeContent
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RedirectProtocolHandler
public RedirectProtocolHandler(HttpClient client)
-
-
Method Detail
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceProtocolHandler
- Returns:
- a unique name among protocol handlers
-
accept
public boolean accept(Request request, Response response)
Description copied from interface:ProtocolHandler
Inspects the given
request
andresponse
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.
- Specified by:
accept
in interfaceProtocolHandler
- Parameters:
request
- the request to acceptresponse
- the response to accept- Returns:
- true if this protocol handler can handle the given request and response
-
getResponseListener
public Response.Listener getResponseListener()
- Specified by:
getResponseListener
in interfaceProtocolHandler
- Returns:
- a response listener that will handle the request and response on behalf of the application.
-
onHeader
public boolean onHeader(Response response, HttpField field)
Description copied from interface:Response.HeaderListener
Callback method invoked when a response header has been received and parsed, returning whether the header should be processed or not.- Specified by:
onHeader
in interfaceResponse.HeaderListener
- Specified by:
onHeader
in interfaceResponse.Listener
- Parameters:
response
- the response containing the response line data and the headers so farfield
- the header received- Returns:
- true to process the header, false to skip processing of the header
-
onComplete
public void onComplete(Result result)
Description copied from interface:Response.CompleteListener
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
Response.SuccessListener.onSuccess(Response)
orResponse.FailureListener.onFailure(Response, Throwable)
, and only when request indicates that it is completed.- Specified by:
onComplete
in interfaceResponse.CompleteListener
- Specified by:
onComplete
in interfaceResponse.Listener
- Parameters:
result
- the result of the request / response exchange
-
-