java.lang.Object
com.github.mizosoft.methanol.internal.cache.RedirectingInterceptor
- All Implemented Interfaces:
Methanol.Interceptor
An
Methanol.Interceptor
that 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
ConstructorDescriptionRedirectingInterceptor
(HttpClient.Redirect policy, @Nullable Executor handlerExecutor) -
Method Summary
Modifier and TypeMethodDescription<T> HttpResponse
<T> intercept
(HttpRequest request, Methanol.Interceptor.Chain<T> chain) Intercepts given request and returns the resulting response, usually by forwarding to the given chain.<T> CompletableFuture
<HttpResponse<T>> interceptAsync
(HttpRequest request, Methanol.Interceptor.Chain<T> chain) Intercepts the given request and returns aCompletableFuture
for the resulting response, usually by forwarding to the given chain.
-
Constructor Details
-
RedirectingInterceptor
-
-
Method Details
-
intercept
public <T> HttpResponse<T> intercept(HttpRequest request, Methanol.Interceptor.Chain<T> chain) throws IOException, InterruptedException Description copied from interface:Methanol.Interceptor
Intercepts given request and returns the resulting response, usually by forwarding to the given chain.- Specified by:
intercept
in interfaceMethanol.Interceptor
- Throws:
IOException
InterruptedException
-
interceptAsync
public <T> CompletableFuture<HttpResponse<T>> interceptAsync(HttpRequest request, Methanol.Interceptor.Chain<T> chain) Description copied from interface:Methanol.Interceptor
Intercepts the given request and returns aCompletableFuture
for the resulting response, usually by forwarding to the given chain.- Specified by:
interceptAsync
in interfaceMethanol.Interceptor
-