hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [25/35] httpcomponents-core git commit: HTTPCORE-281: ResponseConnControl protocol interceptor does not correctly populate connection persistence control headers when sending a HTTP/1.1 response message in response to a HTTP/1.0 request message (merged f
Date Tue, 09 May 2017 20:03:54 GMT
HTTPCORE-281: ResponseConnControl protocol interceptor does not correctly populate connection
persistence control headers when sending a HTTP/1.1 response message in response to a HTTP/1.0
request message (merged from trunk)
Contributed by William R. Speirs <bill.speirs at gmail.com>

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.1.x@1204996
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/24802042
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/24802042
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/24802042

Branch: refs/heads/4.1.x
Commit: 24802042ed42554b1860977317a0f79e30626f5a
Parents: a32882c
Author: Oleg Kalnichevski <olegk@apache.org>
Authored: Tue Nov 22 13:55:49 2011 +0000
Committer: Oleg Kalnichevski <olegk@apache.org>
Committed: Tue Nov 22 13:55:49 2011 +0000

----------------------------------------------------------------------
 RELEASE_NOTES.txt                                    |  5 +++++
 .../apache/http/protocol/ResponseConnControl.java    |  4 +++-
 .../http/protocol/TestStandardInterceptors.java      | 15 +++++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/24802042/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 38bad2b..a5148fb 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,6 +1,11 @@
 Changes since 4.1.3
 -------------------
 
+* [HTTPCORE-281] ResponseConnControl protocol interceptor does not correctly populate connection
+  persistence control headers when sending a HTTP/1.1 response message in response to a HTTP/1.0

+  request message.
+  Contributed by William R. Speirs <bill.speirs at gmail.com>
+
 * [HTTPCORE-282] The default value of the internal event mask of newly created non-blocking
I/O 
   is not correctly initialized, which causes the READ interest bit to get cleared in the
interest 
   op queuing mode unless the event mask is explicitly reset.

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/24802042/httpcore/src/main/java/org/apache/http/protocol/ResponseConnControl.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/protocol/ResponseConnControl.java b/httpcore/src/main/java/org/apache/http/protocol/ResponseConnControl.java
index 7541a09..ad738a9 100644
--- a/httpcore/src/main/java/org/apache/http/protocol/ResponseConnControl.java
+++ b/httpcore/src/main/java/org/apache/http/protocol/ResponseConnControl.java
@@ -84,13 +84,15 @@ public class ResponseConnControl implements HttpResponseInterceptor {
                 return;
             }
         }
-        // Drop connection if requested by the client
+        // Drop connection if requested by the client or request was <= 1.0
         HttpRequest request = (HttpRequest)
             context.getAttribute(ExecutionContext.HTTP_REQUEST);
         if (request != null) {
             Header header = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
             if (header != null) {
                 response.setHeader(HTTP.CONN_DIRECTIVE, header.getValue());
+            } else if (request.getProtocolVersion().lessEquals(HttpVersion.HTTP_1_0)) {
+                response.setHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/24802042/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 b35382b..4c5412f 100644
--- a/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
+++ b/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
@@ -543,6 +543,21 @@ public class TestStandardInterceptors extends TestCase {
         assertNull(header);
     }
 
+    public void testResponseConnControl10Client11Response() throws Exception {
+        HttpContext context = new BasicHttpContext(null);
+        BasicHttpRequest request = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_0);
+        context.setAttribute(ExecutionContext.HTTP_REQUEST, request);
+
+        HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
+        StringEntity entity = new StringEntity("whatever");
+        response.setEntity(entity);
+        ResponseConnControl interceptor = new ResponseConnControl();
+        interceptor.process(response, context);
+        Header header = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
+        assertNotNull(header);
+        assertEquals(HTTP.CONN_CLOSE, header.getValue());
+    }
+
     public void testResponseConnControlStatusCode() throws Exception {
         HttpContext context = new BasicHttpContext(null);
         BasicHttpRequest request = new BasicHttpRequest("GET", "/");


Mime
View raw message