Package org.apache.hc.client5.http.impl
Class DefaultRedirectStrategy
- java.lang.Object
-
- org.apache.hc.client5.http.impl.DefaultRedirectStrategy
-
- All Implemented Interfaces:
RedirectStrategy
- Direct Known Subclasses:
LaxRedirectStrategy
@Contract(threading=STATELESS) public class DefaultRedirectStrategy extends java.lang.Object implements RedirectStrategy
Default implementation ofRedirectStrategy.- Since:
- 4.1
-
-
Field Summary
Fields Modifier and Type Field Description static DefaultRedirectStrategyINSTANCEDefault instance ofDefaultRedirectStrategy.private SchemePortResolverschemePortResolver
-
Constructor Summary
Constructors Constructor Description DefaultRedirectStrategy()Creates a newDefaultRedirectStrategywith the defaultDefaultSchemePortResolver.INSTANCE.DefaultRedirectStrategy(SchemePortResolver schemePortResolver)Creates a newDefaultRedirectStrategyusing the givenSchemePortResolver.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.net.URIcreateLocationURI(java.lang.String location)java.net.URIgetLocationURI(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.protocol.HttpContext context)booleanisRedirectAllowed(org.apache.hc.core5.http.HttpHost currentTarget, org.apache.hc.core5.http.HttpHost newTarget, org.apache.hc.core5.http.HttpRequest redirect, org.apache.hc.core5.http.protocol.HttpContext context)Determines if the given redirect should be executed or the redirect response should be returned to the caller without further processing.booleanisRedirected(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.protocol.HttpContext context)Determines if a request should be redirected to a new location given the response from the target server.private booleanisSameAuthority(org.apache.hc.core5.http.HttpHost h1, org.apache.hc.core5.http.HttpHost h2)
-
-
-
Field Detail
-
schemePortResolver
private final SchemePortResolver schemePortResolver
-
INSTANCE
public static final DefaultRedirectStrategy INSTANCE
Default instance ofDefaultRedirectStrategy.
-
-
Constructor Detail
-
DefaultRedirectStrategy
public DefaultRedirectStrategy(SchemePortResolver schemePortResolver)
Creates a newDefaultRedirectStrategyusing the givenSchemePortResolver. IfschemePortResolverisnull, this will default toDefaultSchemePortResolver.INSTANCE.- Parameters:
schemePortResolver- the resolver to use for determining default ports- Since:
- 5.6
-
DefaultRedirectStrategy
public DefaultRedirectStrategy()
Creates a newDefaultRedirectStrategywith the defaultDefaultSchemePortResolver.INSTANCE.- Since:
- 5.6
-
-
Method Detail
-
isRedirectAllowed
public boolean isRedirectAllowed(org.apache.hc.core5.http.HttpHost currentTarget, org.apache.hc.core5.http.HttpHost newTarget, org.apache.hc.core5.http.HttpRequest redirect, org.apache.hc.core5.http.protocol.HttpContext context)Description copied from interface:RedirectStrategyDetermines if the given redirect should be executed or the redirect response should be returned to the caller without further processing.It is legal for this method implementation to modify the redirect request in order to make it suitable for redirect execution.
- Specified by:
isRedirectAllowedin interfaceRedirectStrategy
-
isSameAuthority
private boolean isSameAuthority(org.apache.hc.core5.http.HttpHost h1, org.apache.hc.core5.http.HttpHost h2)
-
isRedirected
public boolean isRedirected(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.protocol.HttpContext context) throws org.apache.hc.core5.http.ProtocolExceptionDescription copied from interface:RedirectStrategyDetermines if a request should be redirected to a new location given the response from the target server.- Specified by:
isRedirectedin interfaceRedirectStrategy- Parameters:
request- the executed requestresponse- the response received from the target servercontext- the context for the request execution- Returns:
trueif the request should be redirected,falseotherwise- Throws:
org.apache.hc.core5.http.ProtocolException
-
getLocationURI
public java.net.URI getLocationURI(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.protocol.HttpContext context) throws org.apache.hc.core5.http.HttpException- Specified by:
getLocationURIin interfaceRedirectStrategy- Throws:
org.apache.hc.core5.http.HttpException
-
createLocationURI
protected java.net.URI createLocationURI(java.lang.String location) throws org.apache.hc.core5.http.ProtocolException- Throws:
org.apache.hc.core5.http.ProtocolException- Since:
- 4.1
-
-