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 497ed45c70252..0f3a7a9ef3058 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.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 void messageReceived(ChannelHandlerContext ctx, MessageEvent messageEvent 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 { 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 06bc81b8f1f0a..c287142846b3d 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 void messageReceived(ChannelHandlerContext ctx, MessageEvent messageEvent 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); 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 0000000000000..f3f7cd5c482bc --- /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"); + } + }; + } + +}