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 2011/11/22 14:55:50 UTC
svn commit: r1204996 - in /httpcomponents/httpcore/branches/4.1.x:
RELEASE_NOTES.txt
httpcore/src/main/java/org/apache/http/protocol/ResponseConnControl.java
httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
Author: olegk
Date: Tue Nov 22 13:55:49 2011
New Revision: 1204996
URL: http://svn.apache.org/viewvc?rev=1204996&view=rev
Log:
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>
Modified:
httpcomponents/httpcore/branches/4.1.x/RELEASE_NOTES.txt
httpcomponents/httpcore/branches/4.1.x/httpcore/src/main/java/org/apache/http/protocol/ResponseConnControl.java
httpcomponents/httpcore/branches/4.1.x/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
Modified: httpcomponents/httpcore/branches/4.1.x/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.1.x/RELEASE_NOTES.txt?rev=1204996&r1=1204995&r2=1204996&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.1.x/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/branches/4.1.x/RELEASE_NOTES.txt Tue Nov 22 13:55:49 2011
@@ -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.
Modified: httpcomponents/httpcore/branches/4.1.x/httpcore/src/main/java/org/apache/http/protocol/ResponseConnControl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.1.x/httpcore/src/main/java/org/apache/http/protocol/ResponseConnControl.java?rev=1204996&r1=1204995&r2=1204996&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.1.x/httpcore/src/main/java/org/apache/http/protocol/ResponseConnControl.java (original)
+++ httpcomponents/httpcore/branches/4.1.x/httpcore/src/main/java/org/apache/http/protocol/ResponseConnControl.java Tue Nov 22 13:55:49 2011
@@ -84,13 +84,15 @@ public class ResponseConnControl impleme
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);
}
}
}
Modified: httpcomponents/httpcore/branches/4.1.x/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.1.x/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java?rev=1204996&r1=1204995&r2=1204996&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.1.x/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java (original)
+++ httpcomponents/httpcore/branches/4.1.x/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java Tue Nov 22 13:55:49 2011
@@ -543,6 +543,21 @@ public class TestStandardInterceptors ex
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", "/");