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 2019/10/25 04:13:48 UTC

[camel] branch camel-2.24.x updated: CAMEL-14069 Update to ignore the 100-Continue response and continue to (#3276)

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

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


The following commit(s) were added to refs/heads/camel-2.24.x by this push:
     new b0fea8c  CAMEL-14069 Update to ignore the 100-Continue response and continue to (#3276)
b0fea8c is described below

commit b0fea8cbabefea489a38e2aca2be4cad1185bb72
Author: Amos Feng <zf...@redhat.com>
AuthorDate: Fri Oct 25 12:11:55 2019 +0800

    CAMEL-14069 Update to ignore the 100-Continue response and continue to (#3276)
    
    * CAMEL-14069 Update to ignore the 100-Continue response and continue to
    wait for the answer
    
    * Fix CS of camel-netty4 and camel-netty4-http
---
 .../component/netty4/http/handlers/HttpClientChannelHandler.java   | 7 +++++++
 .../component/netty4/http/NettyHttpBindingUseRelativePath.java     | 2 +-
 .../component/netty4/http/NettyHttpClientExpectContinueTest.java   | 2 --
 .../java/org/apache/camel/component/netty4/NettyConstants.java     | 1 +
 .../apache/camel/component/netty4/codec/LineBasedFrameDecoder.java | 2 +-
 .../camel/component/netty4/handlers/ClientChannelHandler.java      | 7 +++++++
 6 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpClientChannelHandler.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpClientChannelHandler.java
index d068d53..0a3c1bc 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpClientChannelHandler.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpClientChannelHandler.java
@@ -23,6 +23,7 @@ import java.util.Map;
 
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.http.FullHttpResponse;
+import io.netty.handler.codec.http.HttpResponseStatus;
 import io.netty.handler.codec.http.HttpUtil;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
@@ -45,6 +46,12 @@ public class HttpClientChannelHandler extends ClientChannelHandler {
     @Override
     protected Message getResponseMessage(Exchange exchange, ChannelHandlerContext ctx, Object message) throws Exception {
         FullHttpResponse response = (FullHttpResponse) message;
+
+        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
             exchange.setProperty(NettyConstants.NETTY_CLOSE_CHANNEL_WHEN_COMPLETE, true);
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpBindingUseRelativePath.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpBindingUseRelativePath.java
index 1bd445d..619a5d0 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpBindingUseRelativePath.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpBindingUseRelativePath.java
@@ -1,4 +1,4 @@
-/*
+/**
  * 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.
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpClientExpectContinueTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpClientExpectContinueTest.java
index 365d76a..d41ce09 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpClientExpectContinueTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpClientExpectContinueTest.java
@@ -19,10 +19,8 @@ package org.apache.camel.component.netty4.http;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.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-netty4/src/main/java/org/apache/camel/component/netty4/NettyConstants.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConstants.java
index fa2a6da..536069d 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConstants.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConstants.java
@@ -36,6 +36,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 = "CamelNettyClientContinue";
 
     private NettyConstants() {
         // Utility class
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/codec/LineBasedFrameDecoder.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/codec/LineBasedFrameDecoder.java
index afbc9ef..2ddb3d8 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/codec/LineBasedFrameDecoder.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/codec/LineBasedFrameDecoder.java
@@ -1,4 +1,4 @@
-/*
+/**
  * 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.
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
index 05a8119..c9a88bf 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/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);