Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
}
};
}

}