hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r781114 - in /httpcomponents/httpcore/branches/4.0.x: RELEASE_NOTES.txt httpcore/src/main/java/org/apache/http/protocol/RequestTargetHost.java httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
Date Tue, 02 Jun 2009 18:23:52 GMT
Author: olegk
Date: Tue Jun  2 18:23:51 2009
New Revision: 781114

URL: http://svn.apache.org/viewvc?rev=781114&view=rev
Log:
HTTPCORE-198: CONNECT request includes Host header for HTTP 1.1 connections

Modified:
    httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt
    httpcomponents/httpcore/branches/4.0.x/httpcore/src/main/java/org/apache/http/protocol/RequestTargetHost.java
    httpcomponents/httpcore/branches/4.0.x/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java

Modified: httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt?rev=781114&r1=781113&r2=781114&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/branches/4.0.x/RELEASE_NOTES.txt Tue Jun  2 18:23:51 2009
@@ -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> 

Modified: httpcomponents/httpcore/branches/4.0.x/httpcore/src/main/java/org/apache/http/protocol/RequestTargetHost.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.0.x/httpcore/src/main/java/org/apache/http/protocol/RequestTargetHost.java?rev=781114&r1=781113&r2=781114&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.0.x/httpcore/src/main/java/org/apache/http/protocol/RequestTargetHost.java
(original)
+++ httpcomponents/httpcore/branches/4.0.x/httpcore/src/main/java/org/apache/http/protocol/RequestTargetHost.java
Tue Jun  2 18:23:51 2009
@@ -68,8 +68,9 @@
             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 @@
                     }
                 }
                 if (targethost == null) {
-                    ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
                     if (ver.lessEquals(HttpVersion.HTTP_1_0)) {
                         return;
                     } else {

Modified: httpcomponents/httpcore/branches/4.0.x/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.0.x/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java?rev=781114&r1=781113&r2=781114&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.0.x/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
(original)
+++ httpcomponents/httpcore/branches/4.0.x/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
Tue Jun  2 18:23:51 2009
@@ -399,6 +399,29 @@
         }
     }
 
+    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", "/");



Mime
View raw message