Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 53B0111242 for ; Fri, 23 May 2014 11:16:51 +0000 (UTC) Received: (qmail 13266 invoked by uid 500); 23 May 2014 11:16:51 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 13122 invoked by uid 500); 23 May 2014 11:16:51 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 13044 invoked by uid 99); 23 May 2014 11:16:51 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 May 2014 11:16:51 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id F184C99FE2A; Fri, 23 May 2014 11:16:50 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Date: Fri, 23 May 2014 11:16:52 -0000 Message-Id: In-Reply-To: <328788530cad4ca8b7dd5c7732deecaf@git.apache.org> References: <328788530cad4ca8b7dd5c7732deecaf@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/3] git commit: [CAMEL-7462] Do not treat as final response [CAMEL-7462] Do not treat 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 Authored: Fri May 23 13:10:31 2014 +0200 Committer: Claus Ibsen 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"); + } + }; + } + +}