- java.lang.Object
-
- com.github.mizosoft.methanol.internal.cache.RedirectingInterceptor
-
- All Implemented Interfaces:
Methanol.Interceptor
public final class RedirectingInterceptor extends java.lang.Object implements Methanol.Interceptor
AnMethanol.Interceptorthat follows redirects. The interceptor is applied prior to the cache interceptor only if one is installed. Allowing the cache to intercept redirects increases its efficiency as network access can be avoided in case a redirected URI is accessed repeatedly (provided the redirecting response is cacheable). Additionally, this ensures correctness in case a cacheable response is received for a redirected request. In such case, the response should be cached for the URI the request was redirected to, not the initiating URI.For best compatibility, the interceptor follows HttpClient's redirecting behaviour.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.github.mizosoft.methanol.Methanol.Interceptor
Methanol.Interceptor.Chain<T>
-
-
Constructor Summary
Constructors Constructor Description RedirectingInterceptor(java.net.http.HttpClient.Redirect policy, java.util.concurrent.Executor handlerExecutor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> java.net.http.HttpResponse<T>intercept(java.net.http.HttpRequest request, Methanol.Interceptor.Chain<T> chain)Intercepts given request and returns the resulting response, usually by forwarding to the given chain.<T> java.util.concurrent.CompletableFuture<java.net.http.HttpResponse<T>>interceptAsync(java.net.http.HttpRequest request, Methanol.Interceptor.Chain<T> chain)Intercepts the given request and returns aCompletableFuturefor the resulting response, usually by forwarding to the given chain.
-
-
-
Method Detail
-
intercept
public <T> java.net.http.HttpResponse<T> intercept(java.net.http.HttpRequest request, Methanol.Interceptor.Chain<T> chain) throws java.io.IOException, java.lang.InterruptedExceptionDescription copied from interface:Methanol.InterceptorIntercepts given request and returns the resulting response, usually by forwarding to the given chain.- Specified by:
interceptin interfaceMethanol.Interceptor- Throws:
java.io.IOExceptionjava.lang.InterruptedException
-
interceptAsync
public <T> java.util.concurrent.CompletableFuture<java.net.http.HttpResponse<T>> interceptAsync(java.net.http.HttpRequest request, Methanol.Interceptor.Chain<T> chain)Description copied from interface:Methanol.InterceptorIntercepts the given request and returns aCompletableFuturefor the resulting response, usually by forwarding to the given chain.- Specified by:
interceptAsyncin interfaceMethanol.Interceptor
-
-