This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 245812a  CAMEL-14069 Update to ignore the 100-Continue response and 
continue to (#3279)
245812a is described below

commit 245812a9bc0cabd4fad8a125b2af6ab6c4096d34
Author: Amos Feng <zf...@redhat.com>
AuthorDate: Fri Oct 25 11:47:07 2019 +0800

    CAMEL-14069 Update to ignore the 100-Continue response and continue to 
(#3279)
    
    wait for the answer
---
 .../component/netty/http/handlers/HttpClientChannelHandler.java    | 6 ++++++
 .../component/netty/http/NettyHttpClientExpectContinueTest.java    | 2 --
 .../main/java/org/apache/camel/component/netty/NettyConstants.java | 1 +
 .../camel/component/netty/handlers/ClientChannelHandler.java       | 7 +++++++
 4 files changed, 14 insertions(+), 2 deletions(-)

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 99e50d5..7b9d3f8 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
@@ -24,6 +24,7 @@ import java.util.Map;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.http.FullHttpResponse;
 import io.netty.handler.codec.http.HttpResponse;
+import io.netty.handler.codec.http.HttpResponseStatus;
 import io.netty.handler.codec.http.HttpUtil;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
@@ -59,6 +60,11 @@ public class HttpClientChannelHandler extends 
ClientChannelHandler {
             response = streamHttpResponse.getHttpResponse();
             answer = 
producer.getEndpoint().getNettyHttpBinding().toCamelMessage(streamHttpResponse, 
exchange, producer.getConfiguration());
         }
+
+        if (response.status().equals(HttpResponseStatus.CONTINUE)) {
+            // need to continue to send the body and will ignore this response
+            exchange.setProperty(NettyConstants.NETTY_CLIENT_CONTINUE, true);
+        }
         
         if (!HttpUtil.isKeepAlive(response)) {
             // just want to make sure we close the channel if the keepAlive is 
not true
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
index 0b14b86..c4eb35a 100644
--- 
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
@@ -19,10 +19,8 @@ package org.apache.camel.component.netty.http;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.support.DefaultExchange;
-import org.junit.Ignore;
 import org.junit.Test;
 
-@Ignore("TODO Fix it, need to send the response back")
 public class NettyHttpClientExpectContinueTest extends BaseNettyTest {
 
     @Test
diff --git 
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConstants.java
 
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConstants.java
index 5510d30..68c8ded 100644
--- 
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConstants.java
+++ 
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConstants.java
@@ -34,6 +34,7 @@ public final class NettyConstants {
     public static final String NETTY_SSL_CLIENT_CERT_NOT_AFTER = 
"CamelNettySSLClientCertNotAfter";
     public static final String NETTY_REQUEST_TIMEOUT = 
"CamelNettyRequestTimeout";
     public static final String NETTY_CHANNEL = "CamelNettyChannel";
+    public static final String NETTY_CLIENT_CONTINUE = "CamelClientContinue";
 
     private NettyConstants() {
         // Utility class
diff --git 
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
 
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
index 98e1733..1947e6e 100644
--- 
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
+++ 
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
@@ -172,6 +172,13 @@ public class ClientChannelHandler extends 
SimpleChannelInboundHandler<Object> {
             return;
         }
 
+        Boolean continueWaitForAnswer = 
exchange.getProperty(NettyConstants.NETTY_CLIENT_CONTINUE, Boolean.class);
+        if (continueWaitForAnswer != null && continueWaitForAnswer) {
+            exchange.removeProperty(NettyConstants.NETTY_CLIENT_CONTINUE);
+            // Leave channel open and continue wait for an answer.
+            return;
+        }
+
         // set the result on either IN or OUT on the original exchange 
depending on its pattern
         if (ExchangeHelper.isOutCapable(exchange)) {
             exchange.setOut(message);

Reply via email to