hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1412159 - in /httpcomponents/httpcore/trunk: httpcore-nio/src/test/java/org/apache/http/nio/integration/ httpcore/src/examples/org/apache/http/examples/ httpcore/src/main/java/org/apache/http/protocol/ httpcore/src/test/java/org/apache/htt...
Date Wed, 21 Nov 2012 15:59:00 GMT
Author: olegk
Date: Wed Nov 21 15:58:58 2012
New Revision: 1412159

URL: http://svn.apache.org/viewvc?rev=1412159&view=rev
Log:
Reverted changes introducing 'expect-continue' context attribute

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java
    httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpGet.java
    httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/ExecutionContext.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpCoreContext.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestExpectContinue.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java?rev=1412159&r1=1412158&r2=1412159&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java
Wed Nov 21 15:58:58 2012
@@ -61,7 +61,6 @@ import org.apache.http.nio.protocol.UriH
 import org.apache.http.nio.reactor.IOReactorStatus;
 import org.apache.http.nio.reactor.ListenerEndpoint;
 import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpProcessor;
@@ -426,8 +425,6 @@ public class TestHttpAsyncHandlers exten
             request.setEntity(entity);
 
             HttpContext context = new BasicHttpContext();
-            context.setAttribute(ExecutionContext.HTTP_EXPECT_CONT, Boolean.TRUE);
-
             Future<HttpResponse> future = this.client.execute(target, request, context);
             queue.add(future);
         }
@@ -486,8 +483,6 @@ public class TestHttpAsyncHandlers exten
         Queue<Future<HttpResponse>> queue = new ConcurrentLinkedQueue<Future<HttpResponse>>();
         for (HttpRequest request : requests) {
             HttpContext context = new BasicHttpContext();
-            context.setAttribute(ExecutionContext.HTTP_EXPECT_CONT, Boolean.TRUE);
-
             Future<HttpResponse> future = this.client.execute(target, request, context);
             queue.add(future);
         }
@@ -631,8 +626,6 @@ public class TestHttpAsyncHandlers exten
         Queue<Future<HttpResponse>> queue = new ConcurrentLinkedQueue<Future<HttpResponse>>();
         for (HttpRequest request : requests) {
             HttpContext context = new BasicHttpContext();
-            context.setAttribute(ExecutionContext.HTTP_EXPECT_CONT, Boolean.TRUE);
-
             Future<HttpResponse> future = this.client.execute(target, request, context);
             queue.add(future);
         }

Modified: httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpGet.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpGet.java?rev=1412159&r1=1412158&r2=1412159&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpGet.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpGet.java
Wed Nov 21 15:58:58 2012
@@ -67,7 +67,6 @@ public class ElementalHttpGet {
         HttpCoreContext coreContext = HttpCoreContext.create();
         HttpHost host = new HttpHost("localhost", 8080);
         coreContext.setTargetHost(host);
-        coreContext.setExpectContinue();
 
         DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(8 * 1024);
         ConnectionReuseStrategy connStrategy = DefaultConnectionReuseStrategy.INSTANCE;

Modified: httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java?rev=1412159&r1=1412158&r2=1412159&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java
Wed Nov 21 15:58:58 2012
@@ -72,7 +72,6 @@ public class ElementalHttpPost {
         HttpCoreContext coreContext = HttpCoreContext.create();
         HttpHost host = new HttpHost("localhost", 8080);
         coreContext.setTargetHost(host);
-        coreContext.setExpectContinue();
 
         DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(8 * 1024);
         ConnectionReuseStrategy connStrategy = DefaultConnectionReuseStrategy.INSTANCE;

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/ExecutionContext.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/ExecutionContext.java?rev=1412159&r1=1412158&r2=1412159&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/ExecutionContext.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/ExecutionContext.java
Wed Nov 21 15:58:58 2012
@@ -74,13 +74,4 @@ public interface ExecutionContext {
      */
     public static final String HTTP_REQ_SENT    = "http.request_sent";
 
-    /**
-     * Attribute name of a {@link Boolean} object that represents the
-     * the flag indicating whether or not the 'expect: continue'
-     * handshaking is to be used for entity enclosing requests.
-     *
-     * @since 4.3
-     */
-    public static final String HTTP_EXPECT_CONT = "http.expect-continue";
-
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpCoreContext.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpCoreContext.java?rev=1412159&r1=1412158&r2=1412159&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpCoreContext.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpCoreContext.java
Wed Nov 21 15:58:58 2012
@@ -97,15 +97,6 @@ public class HttpCoreContext implements 
         return getAttribute(HTTP_CONNECTION, HttpConnection.class);
     }
 
-    public boolean isExpectContinue() {
-        Boolean b = getAttribute(HTTP_EXPECT_CONT, Boolean.class);
-        return b != null ? b.booleanValue() : false;
-    }
-
-    public void setExpectContinue() {
-        setAttribute(HTTP_EXPECT_CONT, Boolean.TRUE);
-    }
-
     public HttpRequest getRequest() {
         return getAttribute(HTTP_REQUEST, HttpRequest.class);
     }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestExpectContinue.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestExpectContinue.java?rev=1412159&r1=1412158&r2=1412159&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestExpectContinue.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/RequestExpectContinue.java
Wed Nov 21 15:58:58 2012
@@ -37,7 +37,7 @@ import org.apache.http.HttpRequestInterc
 import org.apache.http.HttpVersion;
 import org.apache.http.ProtocolVersion;
 import org.apache.http.annotation.Immutable;
-import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.params.CoreProtocolPNames;
 import org.apache.http.util.Args;
 
 /**
@@ -59,16 +59,16 @@ public class RequestExpectContinue imple
             throws HttpException, IOException {
         Args.notNull(request, "HTTP request");
 
-        HttpCoreContext corecontext = HttpCoreContext.adapt(context);
-
         if (!request.containsHeader(HTTP.EXPECT_DIRECTIVE)) {
             if (request instanceof HttpEntityEnclosingRequest) {
                 ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
                 HttpEntity entity = ((HttpEntityEnclosingRequest)request).getEntity();
                 // Do not send the expect header if request body is known to be empty
-                if (entity != null && entity.getContentLength() != 0 && !ver.lessEquals(HttpVersion.HTTP_1_0))
{
-                    if (corecontext.isExpectContinue()
-                            || HttpProtocolParams.useExpectContinue(request.getParams()))
{
+                if (entity != null
+                        && entity.getContentLength() != 0 && !ver.lessEquals(HttpVersion.HTTP_1_0))
{
+                    Boolean b = (Boolean) request.getParams().getParameter(
+                            CoreProtocolPNames.USE_EXPECT_CONTINUE);
+                    if (b == null || b.booleanValue() == true) {
                         request.addHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);
                     }
                 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java?rev=1412159&r1=1412158&r2=1412159&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
Wed Nov 21 15:58:58 2012
@@ -56,7 +56,6 @@ import org.apache.http.entity.StringEnti
 import org.apache.http.impl.DefaultBHttpClientConnection;
 import org.apache.http.message.BasicHttpEntityEnclosingRequest;
 import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpExpectationVerifier;
@@ -468,8 +467,6 @@ public class TestSyncHttp {
         this.server.start();
 
         // Activate 'expect: continue' handshake
-        this.client.getContext().setAttribute(ExecutionContext.HTTP_EXPECT_CONT, true);
-
         DefaultBHttpClientConnection conn = client.createConnection();
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 
@@ -560,9 +557,6 @@ public class TestSyncHttp {
 
         this.server.start();
 
-        // Activate 'expect: continue' handshake
-        this.client.getContext().setAttribute(ExecutionContext.HTTP_EXPECT_CONT, true);
-
         DefaultBHttpClientConnection conn = client.createConnection();
         HttpHost host = new HttpHost("localhost", this.server.getPort());
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java?rev=1412159&r1=1412158&r2=1412159&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
Wed Nov 21 15:58:58 2012
@@ -293,8 +293,7 @@ public class TestStandardInterceptors {
 
     @Test
     public void testRequestExpectContinueGenerated() throws Exception {
-        HttpContext context = new BasicHttpContext(null);
-        context.setAttribute(ExecutionContext.HTTP_EXPECT_CONT, true);
+        HttpContext context = new BasicHttpContext();
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST",
"/");
         String s = "whatever";
         StringEntity entity = new StringEntity(s, "US-ASCII");
@@ -307,23 +306,8 @@ public class TestStandardInterceptors {
     }
 
     @Test
-    public void testRequestExpectContinueNotGenerated() throws Exception {
-        HttpContext context = new BasicHttpContext(null);
-        context.setAttribute(ExecutionContext.HTTP_EXPECT_CONT, false);
-        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST",
"/");
-        String s = "whatever";
-        StringEntity entity = new StringEntity(s, "US-ASCII");
-        request.setEntity(entity);
-        RequestExpectContinue interceptor = new RequestExpectContinue();
-        interceptor.process(request, context);
-        Header header = request.getFirstHeader(HTTP.EXPECT_DIRECTIVE);
-        Assert.assertNull(header);
-    }
-
-    @Test
     public void testRequestExpectContinueHTTP10() throws Exception {
-        HttpContext context = new BasicHttpContext(null);
-        context.setAttribute(ExecutionContext.HTTP_EXPECT_CONT, true);
+        HttpContext context = new BasicHttpContext();
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest(
                 "POST", "/", HttpVersion.HTTP_1_0);
         String s = "whatever";
@@ -337,8 +321,7 @@ public class TestStandardInterceptors {
 
     @Test
     public void testRequestExpectContinueZeroContent() throws Exception {
-        HttpContext context = new BasicHttpContext(null);
-        context.setAttribute(ExecutionContext.HTTP_EXPECT_CONT, true);
+        HttpContext context = new BasicHttpContext();
         BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST",
"/");
         String s = "";
         StringEntity entity = new StringEntity(s, "US-ASCII");



Mime
View raw message