public class DefaultRedirectHandler
extends org.apache.http.impl.client.DefaultRedirectStrategy
Modifier and Type | Field and Description |
---|---|
protected URI |
lastURL
The last url detected for a redirect
|
protected String |
userAgent
The User-Agent to use (if any)
|
Constructor and Description |
---|
DefaultRedirectHandler()
Create a new DefaultRedirectHandler instance
|
DefaultRedirectHandler(String userAgent,
RobotDirectives directives)
Create a new DefaultHandler instance with a user agent defined
|
Modifier and Type | Method and Description |
---|---|
URI |
getlastURI()
Retrieve the last URI Used
|
URI |
getLocationURI(org.apache.http.HttpRequest request,
org.apache.http.HttpResponse response,
org.apache.http.protocol.HttpContext context)
Cleans up URL in location header and sets a new value.
|
String |
getUserAgent()
Retrieve the user agent
|
protected void |
setResponseUserAgent(org.apache.http.HttpResponse response)
Sets the user agent header in the HttpResponse object to the value of
this.userAgent if it is not empty.
|
void |
setUserAgent(String agent)
Set the user agent string to use
|
protected String userAgent
protected URI lastURL
public DefaultRedirectHandler()
public DefaultRedirectHandler(String userAgent, RobotDirectives directives)
userAgent
- user agent stringdirectives
- Directives read from robots.txtpublic final void setUserAgent(String agent) throws IllegalArgumentException
agent
- user agentIllegalArgumentException
- if agent is nullpublic String getUserAgent()
public URI getlastURI()
public URI getLocationURI(org.apache.http.HttpRequest request, org.apache.http.HttpResponse response, org.apache.http.protocol.HttpContext context) throws org.apache.http.ProtocolException
getLocationURI
in class org.apache.http.impl.client.DefaultRedirectStrategy
request
- Request Objectresponse
- Response from servercontext
- contextorg.apache.http.ProtocolException
protected void setResponseUserAgent(org.apache.http.HttpResponse response)
response
- responseCopyright © 2017. All rights reserved.