Source:
public <T> CompletableFuture<T> submit(final ClientInvocation request, final boolean buffered, final ResultExtractor<T> extractor, final ExecutorService executorService) { final Optional<byte[]> payload = Optional.ofNullable(request.getEntity()).map(entity -> requestContent(request)); final HttpClient.RequestSender requestSender = httpClient .headers(headerBuilder -> { final ClientRequestHeaders resteasyHeaders = request.getHeaders(); resteasyHeaders.getHeaders().entrySet().forEach(entry -> { final String key = entry.getKey(); final List<Object> valueList = entry.getValue(); valueList.forEach(value -> headerBuilder.add(key, value != null ? value : "")); }); payload.ifPresent(bytes -> { headerBuilder.set(CONTENT_LENGTH, bytes.length); if (log.isDebugEnabled() && isContentLengthInvalid(resteasyHeaders.getHeader(CONTENT_LENGTH), bytes)) { log.debug("The request's Content-Length header is replaced " + " by the size of the byte array computed from the request entity."); } }); }) .request(HttpMethod.valueOf(request.getMethod())) .uri(request.getUri().toString()); final HttpClient.ResponseReceiver<?> responseReceiver = payload.<HttpClient.ResponseReceiver<?>>map(bytes -> requestSender.send( (httpClientRequest, outbound) -> outbound.sendObject(Mono.just(outbound.alloc().buffer().writeBytes(bytes)))) ).orElse(requestSender); final Mono<T> responseMono = responseReceiver .responseSingle((response, bytes) -> bytes .asInputStream() .map(is -> extractResult(request.getClientConfiguration(), response, is, extractor)) .switchIfEmpty( Mono.defer( () -> Mono.just( extractResult( request.getClientConfiguration(), response, null, extractor))))); return timeout .map(timeout -> responseMono.timeout(timeout)) .orElse(responseMono).toFuture(); }

Target:
public <T> CompletableFuture<T> submit(final ClientInvocation request, final boolean buffered, final ResultExtractor<T> extractor, final ExecutorService executorService) { final Optional<byte[]> payload = Optional.ofNullable(request.getEntity()).map(entity -> requestContent(request)); final HttpClient.RequestSender requestSender = httpClient .headers(headerBuilder -> { final ClientRequestHeaders resteasyHeaders = request.getHeaders(); resteasyHeaders.getHeaders().entrySet().forEach(entry -> { final String key = entry.getKey(); final List<Object> valueList = entry.getValue(); valueList.forEach(value -> headerBuilder.add(key, value != null ? value : "")); }); payload.ifPresent(bytes -> { headerBuilder.set(CONTENT_LENGTH, bytes.length); if (log.isDebugEnabled() && isContentLengthInvalid(resteasyHeaders.getHeader(CONTENT_LENGTH), bytes)) { log.debug("The request's Content-Length header is replaced " + " by the size of the byte array computed from the request entity."); } }); }) .request(HttpMethod.valueOf(request.getMethod())) .uri(request.getUri().toString()); final HttpClient.ResponseReceiver<?> responseReceiver = payload.<HttpClient.ResponseReceiver<?>>map(bytes -> requestSender.send( (httpClientRequest, outbound) -> outbound.sendObject(Mono.just(outbound.alloc().buffer().writeBytes(bytes)))) ).orElse(requestSender); final Mono<T> responseMono = responseReceiver .responseSingle((response, bytes) -> bytes .asInputStream() .map(is -> extractResult(request.getClientConfiguration(), response, is, extractor)) .switchIfEmpty( Mono.defer( () -> Mono.just( extractResult( request.getClientConfiguration(), response, null, extractor))))); return requestTimeout .map(duration -> responseMono.timeout(duration)) .orElse(responseMono) .toFuture(); }