[ https://issues.apache.org/jira/browse/HTTPCLIENT-2355?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17914444#comment-17914444 ]
Oleg Kalnichevski commented on HTTPCLIENT-2355: ----------------------------------------------- [~polybios] By the way, one should be able to work around the problem with the actual version of the client by explicitly setting the version hint on the request object {code:java} final HttpHost target = new HttpHost("https", "httpbin.org", 443); final HttpHost proxy = new HttpHost("http", "127.0.0.1", 8080); try (final CloseableHttpClient httpclient = HttpClients.custom() .setProxy(proxy) .build()) { final RequestConfig config = RequestConfig.custom() .build(); final HttpGet request = new HttpGet("/get"); request.setVersion(HttpVersion.HTTP_1_1); request.setConfig(config); System.out.println("Executing request " + request.getMethod() + " " + request.getUri() + " via " + proxy); httpclient.execute(target, request, response -> { System.out.println("----------------------------------------"); System.out.println(request + "->" + new StatusLine(response)); EntityUtils.consume(response.getEntity()); return null; }); } {code} Oleg > Error "Chunked transfer encoding not allowed for HTTP/1.0" with proxy and > HttpClient 5.4 > ---------------------------------------------------------------------------------------- > > Key: HTTPCLIENT-2355 > URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2355 > Project: HttpComponents HttpClient > Issue Type: Bug > Components: HttpClient (classic) > Affects Versions: 5.4.1 > Reporter: V. S. > Priority: Major > Fix For: 5.4.2, 5.5-alpha1 > > > Exception org.apache.hc.core5.http.ProtocolException: "Chunked transfer > encoding not allowed for HTTP/1.0" is thrown when sending request through > corporate proxy (using Spring's RestClient). That did not occur with > HttpClient 5.3. > Wire protocol (see below) shows proxy replies to CONNECT request with > "HTTP/1.{*}0{*} 200 Connection Established". Since 5.4., this protocol > version seems to be interpreted and set on the HTTP connection that is made > after establishing the TLS connection through the TCP tunnel set up by the > proxy. > The corporate proxies are very hard to change to e.g. return "HTTP/1.{*}1{*} > 200 ..." instead. > > *Wire protocol* (target and proxy host names have been replaced) : > {{h.i.i.DefaultHttpClientConnectionOperator http-outgoing-0 > http://PROXY_HOST:8080 connected [...]}} > {{h.i.i.PoolingHttpClientConnectionManager ep-0000000001 executing exchange > ex-0000000001 over http-outgoing-0}} > {{[...]}} > {{org.apache.hc.client5.http.wire http-outgoing-0 >> "CONNECT > TARGET_HOST:443 HTTP/1.1[\r][\n]"}} > {{org.apache.hc.client5.http.wire http-outgoing-0 >> "Host > TARGET_HOST:443[\r][\n]"}} > {{org.apache.hc.client5.http.wire http-outgoing-0 >> "User-Agent: > ApacheHttpClient/5.4.1 (Java/17.[...])[\r][\n]"}} > {{org.apache.hc.client5.http.wire http-outgoing-0 >> "[\r][\n]"}} > {{org.apache.hc.client5.http.wire http-outgoing-0 << "HTTP/1.0 200 > Connection Established[\r][\n]"}} > {{org.apache.hc.client5.http.wire http-outgoing-0 << "[\r][\n]"}} > {{[...]}} > {{h.i.i.DefaultHttpClientConnectionOperator http-outgoing-0 upgrading to TLS > TARGET_HOST:443}} > {{[...]}} > {{o.a.h.c.ssl.AbstractClientTlsStrategy Secure session established}} > {{o.a.h.c.ssl.AbstractClientTlsStrategy negotiated protocol: TLSv1.3}} > {{[...]}} > {{h.i.i.DefaultHttpClientConnectionOperator http-outgoing-0 upgraded to TLS > TARGET_HOST:443}} > {{o.a.h.c.h.impl.classic.MainClientExec ex-0000000001 executing POST /path > HTTP/1.1}} > {{h.i.i.DefaultManagedHttpClientConnection http-outgoing-0 close connection > IMMEDIATE }} > > *Stack trace:* > {{org.apache.hc.core5.http.ProtocolException: Chunked transfer encoding not > allowed for HTTP/1.0}} > {{ at > org.apache.hc.core5.http.protocol.RequestContent.process(RequestContent.java:127) > ~[httpcore5-5.3.1.jar:5.3.1]}} > {{ at > org.apache.hc.core5.http.protocol.DefaultHttpProcessor.process(DefaultHttpProcessor.java:107) > ~[httpcore5-5.3.1.jar:5.3.1]}} > {{ at > org.apache.hc.client5.http.impl.classic.MainClientExec.execute(MainClientExec.java:119) > ~[httpclient5-5.4.1.jar:5.4.1]}} > {{ at > org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51) > ~[httpclient5-5.4.1.jar:5.4.1]}} > {{ at > org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:199) > ~[httpclient5-5.4.1.jar:5.4.1]}} > {{ at > org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51) > ~[httpclient5-5.4.1.jar:5.4.1]}} > {{ at > org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:192) > ~[httpclient5-5.4.1.jar:5.4.1]}} > {{ at > org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51) > ~[httpclient5-5.4.1.jar:5.4.1]}} > {{ at > org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:150) > ~[httpclient5-5.4.1.jar:5.4.1]}} > {{ at > org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51) > ~[httpclient5-5.4.1.jar:5.4.1]}} > {{ at > org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:113) > ~[httpclient5-5.4.1.jar:5.4.1]}} > {{ at > org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51) > ~[httpclient5-5.4.1.jar:5.4.1]}} > {{ at > org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:110) > ~[httpclient5-5.4.1.jar:5.4.1]}} > {{ at > org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51) > ~[httpclient5-5.4.1.jar:5.4.1]}} > {{ at > org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:174) > ~[httpclient5-5.4.1.jar:5.4.1]}} > {{ at > org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:87) > ~[httpclient5-5.4.1.jar:5.4.1]}} > {{ at > org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:55) > ~[httpclient5-5.4.1.jar:5.4.1]}} > {{ at > org.apache.hc.client5.http.classic.HttpClient.executeOpen(HttpClient.java:183) > ~[httpclient5-5.4.1.jar:5.4.1]}} > {{ at > org.springframework.http.client.HttpComponentsClientHttpRequest.executeInternal(HttpComponentsClientHttpRequest.java:99) > ~[spring-web-6.2.1.jar:6.2.1] }} > -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org