You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/05/23 13:16:52 UTC

[3/3] git commit: [CAMEL-7462] Do not treat as final response

[CAMEL-7462] Do not treat <HTTP/1.1 100 Continue> as final response


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/72108c43
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/72108c43
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/72108c43

Branch: refs/heads/camel-2.12.x
Commit: 72108c43279cc4020c19c44128c240b2c96bde39
Parents: 291683f
Author: Grzegorz Grzybek <gr...@gmail.com>
Authored: Fri May 23 13:10:31 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri May 23 13:16:34 2014 +0200

----------------------------------------------------------------------
 .../http/handlers/HttpClientChannelHandler.java |  7 ++-
 .../http/handlers/HttpServerChannelHandler.java |  7 ---
 .../http/NettyHttpClientExpectContinueTest.java | 55 ++++++++++++++++++++
 3 files changed, 61 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/72108c43/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpClientChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpClientChannelHandler.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpClientChannelHandler.java
index 497ed45..0f3a7a9 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpClientChannelHandler.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpClientChannelHandler.java
@@ -29,6 +29,7 @@ import org.jboss.netty.channel.MessageEvent;
 import org.jboss.netty.handler.codec.http.HttpChunk;
 import org.jboss.netty.handler.codec.http.HttpChunkTrailer;
 import org.jboss.netty.handler.codec.http.HttpResponse;
+import org.jboss.netty.handler.codec.http.HttpResponseStatus;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -93,7 +94,11 @@ public class HttpClientChannelHandler extends ClientChannelHandler {
             if (LOG.isTraceEnabled()) {
                 LOG.trace("HttpResponse received: {} chunked:", response, response.isChunked());
             }
-            if (!response.isChunked()) {
+            if (response.getStatus().getCode() == HttpResponseStatus.CONTINUE.getCode()) {
+                if (LOG.isTraceEnabled()) {
+                    LOG.trace("HttpResponse received: {}: {}", response, response.getStatus());
+                }
+            } else if (!response.isChunked()) {
                 // the response is not chunked so we have all the content
                 super.messageReceived(ctx, messageEvent);
             } else {

http://git-wip-us.apache.org/repos/asf/camel/blob/72108c43/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
index 71a8aec..6cf4b7f 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
@@ -81,13 +81,6 @@ public class HttpServerChannelHandler extends ServerChannelHandler {
 
         LOG.debug("Message received: {}", request);
 
-        if (is100ContinueExpected(request)) {
-            // send back http 100 response to continue
-            HttpResponse response = new DefaultHttpResponse(HTTP_1_1, CONTINUE);
-            messageEvent.getChannel().write(response);
-            return;
-        }
-
         if (consumer.isSuspended()) {
             // are we suspended?
             LOG.debug("Consumer suspended, cannot service request {}", request);

http://git-wip-us.apache.org/repos/asf/camel/blob/72108c43/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpClientExpectContinueTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpClientExpectContinueTest.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpClientExpectContinueTest.java
new file mode 100644
index 0000000..f3f7cd5
--- /dev/null
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpClientExpectContinueTest.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty.http;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Test;
+
+public class NettyHttpClientExpectContinueTest extends BaseNettyTest {
+
+    @Test
+    public void testHttpExpect100Continue() throws Exception {
+        getMockEndpoint("mock:input").expectedBodiesReceived("request body");
+
+        String body = "request body";
+        DefaultExchange exchange = new DefaultExchange(context);
+
+        exchange.getIn().setHeader("Expect", "100-continue");
+        exchange.getIn().setBody(body);
+
+        Exchange result = template.send("netty-http:http://localhost:{{port}}/foo", exchange);
+        assertFalse(result.isFailed());
+        assertEquals("Bye World", result.getIn().getBody(String.class));
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("netty-http:http://0.0.0.0:{{port}}/foo")
+                    .to("mock:input")
+                    .transform().constant("Bye World");
+            }
+        };
+    }
+
+}