HttpClient implements IncomingRequestAwareClient { @Override public CompletionStage<com.spotify.apollo.Response<ByteString>> send( com.spotify.apollo.Request apolloRequest, Optional<com.spotify.apollo.Request> apolloIncomingRequest) { final Optional<RequestBody> requestBody = apolloRequest.payload().map(payload -> { final MediaType contentType = apolloRequest.header("Content-Type") .map(MediaType::parse) .orElse(DEFAULT_CONTENT_TYPE); return RequestBody.create(contentType, payload); }); Headers.Builder headersBuilder = new Headers.Builder(); apolloRequest.headerEntries().forEach((e) -> headersBuilder.add(e.getKey(), e.getValue())); apolloIncomingRequest .flatMap(req -> req.header(AUTHORIZATION_HEADER)) .ifPresent(header -> headersBuilder.add(AUTHORIZATION_HEADER, header)); final Request request = new Request.Builder() .method(apolloRequest.method(), requestBody.orElse(null)) .url(apolloRequest.uri()) .headers(headersBuilder.build()) .build(); final CompletableFuture<com.spotify.apollo.Response<ByteString>> result = new CompletableFuture<>(); OkHttpClient finalClient = client; if (apolloRequest.ttl().isPresent() && client.getReadTimeout() != apolloRequest.ttl().get().toMillis()) { finalClient = client.clone(); finalClient.setReadTimeout(apolloRequest.ttl().get().toMillis(), TimeUnit.MILLISECONDS); } finalClient.newCall(request).enqueue(TransformingCallback.create(result)); return result; } @Inject  HttpClient(OkHttpClient client); @Deprecated /** @deprecated use {@link #createUnconfigured()} instead. */ static HttpClient create(); static HttpClient createUnconfigured(); @Override CompletionStage<com.spotify.apollo.Response<ByteString>> send(
      com.spotify.apollo.Request apolloRequest,
      Optional<com.spotify.apollo.Request> apolloIncomingRequest);  }
@Test public void testSend() throws Exception { mockServerClient.when( request() .withMethod("GET") .withPath("/foo.php") .withQueryStringParameter("bar", "baz") .withQueryStringParameter("qur", "quz") ).respond( response() .withStatusCode(204) ); String uri = format("http: Request request = Request.forUri(uri, "GET"); Response<ByteString> response = HttpClient.createUnconfigured() .send(request, empty()) .toCompletableFuture().get(); assertThat(response.status(), withCode(204)); assertThat(response.payload(), is(empty())); }