@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); }
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 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 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); }
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); }
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);  }