### Question:
RedirectingHttpRequesterFilter implements StreamingHttpClientFilterFactory,
                                                             StreamingHttpConnectionFilterFactory,
                                                             HttpExecutionStrategyInfluencer { private Single<StreamingHttpResponse> request(final StreamingHttpRequester delegate, final HttpExecutionStrategy strategy, final StreamingHttpRequest request, final boolean onlyRelative) { final Single<StreamingHttpResponse> response = delegate.request(strategy, request); if (maxRedirects <= 0) { return response; } return new RedirectSingle(strategy, response, request, maxRedirects, delegate, onlyRelative); } RedirectingHttpRequesterFilter();  RedirectingHttpRequesterFilter(final int maxRedirects);  RedirectingHttpRequesterFilter(final boolean onlyRelativeClient);  RedirectingHttpRequesterFilter(final boolean onlyRelativeClient,
                                          final int maxRedirects);  RedirectingHttpRequesterFilter(final boolean onlyRelativeClient,
                                          final boolean onlyRelativeConnection);  RedirectingHttpRequesterFilter(final boolean onlyRelativeClient,
                                          final boolean onlyRelativeConnection,
                                          final int maxRedirects); @Override StreamingHttpClientFilter create(final FilterableStreamingHttpClient client); @Override StreamingHttpConnectionFilter create(final FilterableStreamingHttpConnection connection); @Override HttpExecutionStrategy influenceStrategy(final HttpExecutionStrategy strategy);  }### Answer:
@Test public void maxRedirectsReached() throws Exception { AtomicInteger counter = new AtomicInteger(); when(httpClient.request(any(), any())).thenAnswer(a -> createRedirectResponse(counter.incrementAndGet())); final int maxRedirects = MAX_REDIRECTS; StreamingHttpClient client = newClient(new RedirectingHttpRequesterFilter(maxRedirects)); StreamingHttpRequest request = client.get("/path"); request.headers().set(HOST, "servicetalk.io"); verifyResponse(client, request, MOVED_PERMANENTLY, "/location-" + (maxRedirects + 1), maxRedirects + 1); }
@Test public void requestWithNullResponse() throws Exception { when(httpClient.request(any(), any())).thenReturn(succeeded(null)); StreamingHttpClient client = newClient(new RedirectingHttpRequesterFilter(false)); StreamingHttpRequest request = client.get("/path"); request.headers().set(HOST, "servicetalk.io"); request.headers().set(REQUESTED_STATUS, String.valueOf(MOVED_PERMANENTLY.code())); request.headers().set(REQUESTED_LOCATION, "/new-location"); StreamingHttpResponse response = client.request(defaultStrategy(), request).toFuture().get(); assertNull(response); }
@Test public void multipleFollowUpRedirects() throws Exception { when(httpClient.request(any(), any())).thenReturn( createRedirectResponse(1), createRedirectResponse(2), createRedirectResponse(3), succeeded(reqRespFactory.ok())); StreamingHttpClient client = newClient(new RedirectingHttpRequesterFilter()); StreamingHttpRequest request = client.get("/path"); request.headers().set(HOST, "servicetalk.io"); verifyRedirects(client, request, 4); }