From eeb3f4f1ca4d2c1578dd2eb3b0032b486f387d0a Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Wed, 2 Oct 2013 07:28:04 +0000 Subject: [PATCH] HTTPCLIENT-1405: CONNECT HTTP/1.1 requests lack mandatory 'Host' header git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1528325 13f79535-47bb-0310-9956-ffa450edef68 --- RELEASE_NOTES.txt | 3 +++ .../main/java/org/apache/http/impl/client/ProxyClient.java | 5 +++-- .../java/org/apache/http/impl/execchain/MainClientExec.java | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 4414027f5..38850e5da 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,6 +1,9 @@ Changes since 4.3 ------------------- +* [HTTPCLIENT-1405] CONNECT HTTP/1.1 requests lack mandatory 'Host' header. + Contributed by Oleg Kalnichevski + * [HTTPCLIENT-1402] Cache default User-Agent value. Contributed by yuexiaojun diff --git a/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java b/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java index 920bf085c..bc1f0b980 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java @@ -73,6 +73,7 @@ import org.apache.http.protocol.HttpCoreContext; import org.apache.http.protocol.HttpProcessor; import org.apache.http.protocol.HttpRequestExecutor; import org.apache.http.protocol.ImmutableHttpProcessor; +import org.apache.http.protocol.RequestTargetHost; import org.apache.http.protocol.RequestUserAgent; import org.apache.http.util.Args; import org.apache.http.util.EntityUtils; @@ -105,8 +106,8 @@ public class ProxyClient { this.connFactory = connFactory != null ? connFactory : ManagedHttpClientConnectionFactory.INSTANCE; this.connectionConfig = connectionConfig != null ? connectionConfig : ConnectionConfig.DEFAULT; this.requestConfig = requestConfig != null ? requestConfig : RequestConfig.DEFAULT; - this.httpProcessor = new ImmutableHttpProcessor(new RequestClientConnControl(), - new RequestUserAgent()); + this.httpProcessor = new ImmutableHttpProcessor( + new RequestTargetHost(), new RequestClientConnControl(), new RequestUserAgent()); this.requestExec = new HttpRequestExecutor(); this.proxyAuthStrategy = new ProxyAuthenticationStrategy(); this.authenticator = new HttpAuthenticator(); diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java index d57a17d20..7b19c3eaf 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java @@ -69,6 +69,7 @@ import org.apache.http.message.BasicHttpRequest; import org.apache.http.protocol.HttpProcessor; import org.apache.http.protocol.HttpRequestExecutor; import org.apache.http.protocol.ImmutableHttpProcessor; +import org.apache.http.protocol.RequestTargetHost; import org.apache.http.protocol.RequestUserAgent; import org.apache.http.util.Args; import org.apache.http.util.EntityUtils; @@ -117,7 +118,7 @@ public class MainClientExec implements ClientExecChain { Args.notNull(userTokenHandler, "User token handler"); this.authenticator = new HttpAuthenticator(); this.proxyHttpProcessor = new ImmutableHttpProcessor( - new RequestClientConnControl(), new RequestUserAgent()); + new RequestTargetHost(), new RequestClientConnControl(), new RequestUserAgent()); this.routeDirector = new BasicRouteDirector(); this.requestExecutor = requestExecutor; this.connManager = connManager;