You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2017/05/09 20:03:53 UTC
[05/22] httpcomponents-core git commit: HTTPCORE-198: CONNECT request
includes Host header for HTTP 1.1 connections
HTTPCORE-198: CONNECT request includes Host header for HTTP 1.1 connections
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.0.x@781114 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/5f9ab8e2
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/5f9ab8e2
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/5f9ab8e2
Branch: refs/heads/4.0.x
Commit: 5f9ab8e229c57d46cc27c7414f7316e8ccedc1b5
Parents: 4e87e34
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Tue Jun 2 18:23:51 2009 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Tue Jun 2 18:23:51 2009 +0000
----------------------------------------------------------------------
RELEASE_NOTES.txt | 3 +++
.../apache/http/protocol/RequestTargetHost.java | 4 ++--
.../http/protocol/TestStandardInterceptors.java | 23 ++++++++++++++++++++
3 files changed, 28 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/5f9ab8e2/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index d68e822..c52abc5 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,6 +1,9 @@
Changes since 4.0
-------------------
+* [HTTPCORE-198] CONNECT request includes Host header for HTTP 1.1 connections.
+ Contributed by Oleg Kalnichevski <olegk at apache.org>
+
* [HTTPCORE-196] SSLIOSession now unwraps encrypted data more aggressively eliminating long
pauses when receiving data over non-blocking connections.
Contributed by Oleg Kalnichevski <olegk at apache.org>
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/5f9ab8e2/httpcore/src/main/java/org/apache/http/protocol/RequestTargetHost.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/protocol/RequestTargetHost.java b/httpcore/src/main/java/org/apache/http/protocol/RequestTargetHost.java
index d853f1f..4383da6 100644
--- a/httpcore/src/main/java/org/apache/http/protocol/RequestTargetHost.java
+++ b/httpcore/src/main/java/org/apache/http/protocol/RequestTargetHost.java
@@ -68,8 +68,9 @@ public class RequestTargetHost implements HttpRequestInterceptor {
throw new IllegalArgumentException("HTTP context may not be null");
}
+ ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
String method = request.getRequestLine().getMethod();
- if (method.equalsIgnoreCase("CONNECT")) {
+ if (method.equalsIgnoreCase("CONNECT") && ver.lessEquals(HttpVersion.HTTP_1_0)) {
return;
}
@@ -89,7 +90,6 @@ public class RequestTargetHost implements HttpRequestInterceptor {
}
}
if (targethost == null) {
- ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
if (ver.lessEquals(HttpVersion.HTTP_1_0)) {
return;
} else {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/5f9ab8e2/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java b/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
index 609b8e2..1592b29 100644
--- a/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
+++ b/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
@@ -399,6 +399,29 @@ public class TestStandardInterceptors extends TestCase {
}
}
+ public void testRequestTargetHostConnectHttp11() throws Exception {
+ HttpContext context = new BasicHttpContext(null);
+ HttpHost host = new HttpHost("somehost", 8080, "http");
+ context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, host);
+ BasicHttpRequest request = new BasicHttpRequest("CONNECT", "/");
+ RequestTargetHost interceptor = new RequestTargetHost();
+ interceptor.process(request, context);
+ Header header = request.getFirstHeader(HTTP.TARGET_HOST);
+ assertNotNull(header);
+ assertEquals("somehost:8080", header.getValue());
+ }
+
+ public void testRequestTargetHostConnectHttp10() throws Exception {
+ HttpContext context = new BasicHttpContext(null);
+ HttpHost host = new HttpHost("somehost", 8080, "http");
+ context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, host);
+ BasicHttpRequest request = new BasicHttpRequest("CONNECT", "/", HttpVersion.HTTP_1_0);
+ RequestTargetHost interceptor = new RequestTargetHost();
+ interceptor.process(request, context);
+ Header header = request.getFirstHeader(HTTP.TARGET_HOST);
+ assertNull(header);
+ }
+
public void testRequestUserAgentGenerated() throws Exception {
HttpContext context = new BasicHttpContext(null);
BasicHttpRequest request = new BasicHttpRequest("GET", "/");