On Thu, 2022-11-17 at 14:00 +0100, Jens Schulze wrote: > Hi, > > version 5.2 includes this commit > https://github.com/apache/httpcomponents-core/commit/6741e3c555b96c4a64358adcb69aa0fddeb735b1 > > > > This leads to failing requests with "ProtocolException: Header `Host` > is > illegal" also the initiating request didn't included the mentioned > header. I created a small reproducer: > > package com.commercetools.http.apachehttp; > > import org.apache.hc.client5.http.async.methods.SimpleHttpResponse; > import > org.apache.hc.client5.http.async.methods.SimpleResponseConsumer; > import > org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient; > import org.apache.hc.client5.http.impl.async.HttpAsyncClientBuilder; > import org.apache.hc.core5.concurrent.FutureCallback; > import org.apache.hc.core5.http.nio.AsyncRequestProducer; > import org.apache.hc.core5.http.nio.support.AsyncRequestBuilder; > import org.apache.hc.core5.http2.HttpVersionPolicy; > import org.junit.jupiter.api.Test; > > import java.util.concurrent.*; > > public class SupplierTest { > > @Test > public void reproduceHostError() { > final Executor executor = new ForkJoinPool(); > final CloseableHttpAsyncClient client = > HttpAsyncClientBuilder.create().setVersionPolicy(HttpVersionPolicy.NE > GOTIATE).build(); > > client.start(); > AsyncRequestProducer p = > AsyncRequestBuilder.get("https://google.com") > .build(); > > final SimpleHttpResponse response1 = execute(executor, > client, > p).join(); > final SimpleHttpResponse response2 = execute(executor, > client, > p).join(); > final SimpleHttpResponse response3 = execute(executor, > client, > p).join(); > > final int code = response1.getCode(); > } > > private CompletableFuture<SimpleHttpResponse> execute(Executor > executor, CloseableHttpAsyncClient client, AsyncRequestProducer p) { > final CompletableFuture<SimpleHttpResponse> > apacheResponseFuture = new CompletableFuture<>(); > > > client.execute(p, SimpleResponseConsumer.create(), > new FutureCallback<SimpleHttpResponse>() { > @Override public void > completed(SimpleHttpResponse > result) { > apacheResponseFuture.complete(result); > } > > @Override public void failed(Exception ex) { > > apacheResponseFuture.completeExceptionally(ex); > } > > @Override public void cancelled() { > apacheResponseFuture.cancel(true); > } > }); > return > apacheResponseFuture.thenApplyAsync(simpleHttpResponse1 > -> simpleHttpResponse1, executor); > } > } > > The 3rd request will fail with the mentioned ProtocolException. > > Greetings > > Jens >
I can confirm this is a regression. Please raise a JIRA for it. Oleg
