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 Object
    implements RedirectStrategy

Default implementation of `RedirectStrategy`.

Since:
  4.1

### Field Summary

Fields
`static DefaultRedirectStrategy` `INSTANCE` Default instance of `DefaultRedirectStrategy`.

### Constructor Summary

Constructors
Constructor and Description
`DefaultRedirectStrategy()`
`DefaultRedirectStrategy(SchemePortResolver schemePortResolver)`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected URI` `createLocationURI(String location)`
`URI` `getLocationURI(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.protocol.HttpContext context)`
`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)` Determines if the given redirect should be executed or the redirect response should be returned to the caller without further processing.
`boolean` `isRedirected(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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### INSTANCE

    public static final DefaultRedirectStrategy INSTANCE

Default instance of `DefaultRedirectStrategy`.

### Constructor Detail

#### DefaultRedirectStrategy

    @Internal
    public DefaultRedirectStrategy(SchemePortResolver schemePortResolver)

#### DefaultRedirectStrategy

    public DefaultRedirectStrategy()

### 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: `RedirectStrategy`
Determines 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:
  `isRedirectAllowed` in interface `RedirectStrategy`

#### 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.ProtocolException

Description copied from interface: `RedirectStrategy`
Determines if a request should be redirected to a new location given the response from the target server.

Specified by:
  `isRedirected` in interface `RedirectStrategy`
Parameters:
  `request` - the executed request
  `response` - the response received from the target server
  `context` - the context for the request execution
Returns:
  `true` if the request should be redirected, `false` otherwise
Throws:
  `org.apache.hc.core5.http.ProtocolException`

#### getLocationURI

    public 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:
  `getLocationURI` in interface `RedirectStrategy`
Throws:
  `org.apache.hc.core5.http.HttpException`

#### createLocationURI

    protected URI createLocationURI(String location)
                             throws org.apache.hc.core5.http.ProtocolException

Throws:
  `org.apache.hc.core5.http.ProtocolException`
Since:
  4.1