You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2016/05/18 07:26:31 UTC

[1/6] camel git commit: CAMEL-9972: Explicitly add Connection Close HTTP header with a parameter in URI - camel-http4

Repository: camel
Updated Branches:
  refs/heads/master 0aba99b26 -> bfd6e49d2


CAMEL-9972: Explicitly add Connection Close HTTP header with a parameter in URI - camel-http4


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d4ade0f0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d4ade0f0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d4ade0f0

Branch: refs/heads/master
Commit: d4ade0f000ca609e26115ed059c1d436ef47d72b
Parents: 0aba99b
Author: Andrea Cosentino <an...@gmail.com>
Authored: Wed May 18 08:05:07 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Wed May 18 08:05:07 2016 +0200

----------------------------------------------------------------------
 .../camel/http/common/HttpCommonEndpoint.java   |  13 +++
 components/camel-http4/src/main/docs/http4.adoc |   5 +-
 .../camel/component/http4/HttpProducer.java     |   5 +
 .../http4/HttpProducerConnectioCloseTest.java   | 103 -------------------
 .../http4/HttpProducerConnectionCloseTest.java  | 103 +++++++++++++++++++
 ...HttpProducerExplicitConnectionCloseTest.java |  86 ++++++++++++++++
 6 files changed, 211 insertions(+), 104 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d4ade0f0/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
index 99f03ea..0622e31 100644
--- a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
@@ -82,6 +82,8 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
             + " This is by default turned off. If you enable this then be aware that Java will deserialize the incoming"
             + " data from the request to Java and that can be a potential security risk.")
     boolean transferException;
+    @UriParam(label = "producer", defaultValue = "false", description = "Specifies whether a Connection Close header must be added to HTTP Request. By default connectionClose is false.")
+    boolean connectionClose;
     @UriParam(label = "consumer",
             description = "Specifies whether to enable HTTP TRACE for this Servlet consumer. By default TRACE is turned off.")
     boolean traceEnabled;
@@ -363,6 +365,17 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
     public boolean isTransferException() {
         return transferException;
     }
+    
+	public boolean isConnectionClose() {
+		return connectionClose;
+	}
+
+    /**
+     * If this option is true, the producer will add a Connection Close header to HTTP Request
+     */
+	public void setConnectionClose(boolean connectionClose) {
+		this.connectionClose = connectionClose;
+	}
 
     /**
      * If enabled and an Exchange failed processing on the consumer side, and if the caused Exception was send back serialized

http://git-wip-us.apache.org/repos/asf/camel/blob/d4ade0f0/components/camel-http4/src/main/docs/http4.adoc
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/docs/http4.adoc b/components/camel-http4/src/main/docs/http4.adoc
index 1e15683..7dd204e 100644
--- a/components/camel-http4/src/main/docs/http4.adoc
+++ b/components/camel-http4/src/main/docs/http4.adoc
@@ -88,8 +88,9 @@ The HTTP4 component supports 13 options which are listed below.
 
 
 
+
 // endpoint options: START
-The HTTP4 component supports 31 endpoint options which are listed below:
+The HTTP4 component supports 32 endpoint options which are listed below:
 
 {% raw %}
 [width="100%",cols="2s,1,1m,1m,5",options="header"]
@@ -102,6 +103,7 @@ The HTTP4 component supports 31 endpoint options which are listed below:
 | bridgeEndpoint | producer | false | boolean | If the option is true HttpProducer will ignore the Exchange.HTTP_URI header and use the endpoint's URI for request. You may also set the option throwExceptionOnFailure to be false to let the HttpProducer send all the fault response back.
 | chunked | producer | true | boolean | If this option is false the Servlet will disable the HTTP streaming and set the content-length header on the response
 | clearExpiredCookies | producer | true | boolean | Whether to clear expired cookies before sending the HTTP request. This ensures the cookies store does not keep growing by adding new cookies which is newer removed when they are expired.
+| connectionClose | producer | false | boolean | Specifies whether a Connection Close header must be added to HTTP Request. By default connectionClose is false.
 | cookieStore | producer |  | CookieStore | To use a custom org.apache.http.client.CookieStore. By default the org.apache.http.impl.client.BasicCookieStore is used which is an in-memory only cookie store. Notice if bridgeEndpoint=true then the cookie store is forced to be a noop cookie store as cookie shouldn't be stored as we are just bridging (eg acting as a proxy).
 | copyHeaders | producer | true | boolean | If this option is true then IN exchange headers will be copied to OUT exchange headers according to copy strategy. Setting this to false allows to only include the headers from the HTTP response (not propagating IN headers).
 | headerFilterStrategy | producer |  | HeaderFilterStrategy | To use a custom HeaderFilterStrategy to filter header to and from Camel message.
@@ -135,6 +137,7 @@ The HTTP4 component supports 31 endpoint options which are listed below:
 
 
 
+
 [[HTTP4-MessageHeaders]]
 Message Headers
 ^^^^^^^^^^^^^^^

http://git-wip-us.apache.org/repos/asf/camel/blob/d4ade0f0/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
index 3b38911..e10866d 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
@@ -65,6 +65,7 @@ import org.apache.http.entity.InputStreamEntity;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.auth.BasicScheme;
 import org.apache.http.protocol.BasicHttpContext;
+import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.util.EntityUtils;
 import org.slf4j.Logger;
@@ -163,6 +164,10 @@ public class HttpProducer extends DefaultProducer {
                 httpRequest.setHeader("Host", hostHeader);
             }
         }
+        
+        if (getEndpoint().isConnectionClose()) {
+        	httpRequest.addHeader("Connection", HTTP.CONN_CLOSE);
+        }
 
         // lets store the result in the output message.
         HttpResponse httpResponse = null;

http://git-wip-us.apache.org/repos/asf/camel/blob/d4ade0f0/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerConnectioCloseTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerConnectioCloseTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerConnectioCloseTest.java
deleted file mode 100644
index 29b8c15..0000000
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerConnectioCloseTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * 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.http4;
-
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Exchange;
-import org.apache.camel.component.http4.handler.BasicValidationHandler;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.http.common.HttpHeaderFilterStrategy;
-import org.apache.camel.impl.JndiRegistry;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
-import org.apache.http.protocol.HTTP;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Unit test that show custom header filter useful to send Connection Close header
- *
- * @version 
- */
-public class HttpProducerConnectioCloseTest extends BaseHttpTest {
-
-    @EndpointInject(uri = "mock:result")
-    protected MockEndpoint mockResultEndpoint;
-    
-    private HttpServer localServer;
-    
-    @Before
-    @Override
-    public void setUp() throws Exception {
-        localServer = ServerBootstrap.bootstrap().
-                setHttpProcessor(getBasicHttpProcessor()).
-                setConnectionReuseStrategy(getConnectionReuseStrategy()).
-                setResponseFactory(getHttpResponseFactory()).
-                setExpectationVerifier(getHttpExpectationVerifier()).
-                setSslContext(getSSLContext()).
-                registerHandler("/myget", new BasicValidationHandler("GET", null, null, getExpectedContent())).
-                create();
-        localServer.start();
-
-        super.setUp();
-    }
-
-    @After
-    @Override
-    public void tearDown() throws Exception {
-        super.tearDown();
-
-        if (localServer != null) {
-            localServer.stop();
-        }
-    }
-
-    @Test
-    public void noDataDefaultIsGet() throws Exception {
-        HttpComponent component = context.getComponent("http4", HttpComponent.class);
-        component.setConnectionTimeToLive(1000L);
-        HttpEndpoint endpoiont = (HttpEndpoint) component.createEndpoint("http4://" + localServer.getInetAddress().getHostName() + ":" 
-            + localServer.getLocalPort() + "/myget?headerFilterStrategy=#myFilter");
-        HttpProducer producer = new HttpProducer(endpoiont);
-        Exchange exchange = producer.createExchange();
-        exchange.getIn().setBody(null);
-        exchange.getIn().setHeader("connection", HTTP.CONN_CLOSE);
-        producer.start();
-        producer.process(exchange);
-        producer.stop();
-
-        assertEquals(HTTP.CONN_CLOSE, exchange.getOut().getHeader("connection"));
-        assertExchange(exchange);
-    }
-    
-    @Override
-    protected JndiRegistry createRegistry() throws Exception {
-        JndiRegistry jndi = new JndiRegistry(createJndiContext());
-        ConnectionCloseHeaderFilter connectionCloseFilterStrategy = new ConnectionCloseHeaderFilter();
-        jndi.bind("myFilter", connectionCloseFilterStrategy);
-        return jndi;
-    }
-    
-    class ConnectionCloseHeaderFilter extends HttpHeaderFilterStrategy {
-        @Override
-        protected void initialize() {
-            super.initialize();
-            getOutFilter().remove("connection");
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/d4ade0f0/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerConnectionCloseTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerConnectionCloseTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerConnectionCloseTest.java
new file mode 100644
index 0000000..e51a927
--- /dev/null
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerConnectionCloseTest.java
@@ -0,0 +1,103 @@
+/**
+ * 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.http4;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.http4.handler.BasicValidationHandler;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.http.common.HttpHeaderFilterStrategy;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.http.impl.bootstrap.HttpServer;
+import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.http.protocol.HTTP;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit test that show custom header filter useful to send Connection Close header
+ *
+ * @version 
+ */
+public class HttpProducerConnectionCloseTest extends BaseHttpTest {
+
+    @EndpointInject(uri = "mock:result")
+    protected MockEndpoint mockResultEndpoint;
+    
+    private HttpServer localServer;
+    
+    @Before
+    @Override
+    public void setUp() throws Exception {
+        localServer = ServerBootstrap.bootstrap().
+                setHttpProcessor(getBasicHttpProcessor()).
+                setConnectionReuseStrategy(getConnectionReuseStrategy()).
+                setResponseFactory(getHttpResponseFactory()).
+                setExpectationVerifier(getHttpExpectationVerifier()).
+                setSslContext(getSSLContext()).
+                registerHandler("/myget", new BasicValidationHandler("GET", null, null, getExpectedContent())).
+                create();
+        localServer.start();
+
+        super.setUp();
+    }
+
+    @After
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+
+        if (localServer != null) {
+            localServer.stop();
+        }
+    }
+
+    @Test
+    public void noDataDefaultIsGet() throws Exception {
+        HttpComponent component = context.getComponent("http4", HttpComponent.class);
+        component.setConnectionTimeToLive(1000L);
+        HttpEndpoint endpoiont = (HttpEndpoint) component.createEndpoint("http4://" + localServer.getInetAddress().getHostName() + ":" 
+            + localServer.getLocalPort() + "/myget?headerFilterStrategy=#myFilter");
+        HttpProducer producer = new HttpProducer(endpoiont);
+        Exchange exchange = producer.createExchange();
+        exchange.getIn().setBody(null);
+        exchange.getIn().setHeader("connection", HTTP.CONN_CLOSE);
+        producer.start();
+        producer.process(exchange);
+        producer.stop();
+
+        assertEquals(HTTP.CONN_CLOSE, exchange.getOut().getHeader("connection"));
+        assertExchange(exchange);
+    }
+    
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = new JndiRegistry(createJndiContext());
+        ConnectionCloseHeaderFilter connectionCloseFilterStrategy = new ConnectionCloseHeaderFilter();
+        jndi.bind("myFilter", connectionCloseFilterStrategy);
+        return jndi;
+    }
+    
+    class ConnectionCloseHeaderFilter extends HttpHeaderFilterStrategy {
+        @Override
+        protected void initialize() {
+            super.initialize();
+            getOutFilter().remove("connection");
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/d4ade0f0/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerExplicitConnectionCloseTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerExplicitConnectionCloseTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerExplicitConnectionCloseTest.java
new file mode 100644
index 0000000..3694e4d
--- /dev/null
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerExplicitConnectionCloseTest.java
@@ -0,0 +1,86 @@
+/**
+ * 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.http4;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.http4.handler.BasicValidationHandler;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.http.common.HttpHeaderFilterStrategy;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.http.impl.bootstrap.HttpServer;
+import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.http.protocol.HTTP;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit test that show custom header filter useful to send Connection Close header
+ *
+ * @version 
+ */
+public class HttpProducerExplicitConnectionCloseTest extends BaseHttpTest {
+
+    @EndpointInject(uri = "mock:result")
+    protected MockEndpoint mockResultEndpoint;
+    
+    private HttpServer localServer;
+    
+    @Before
+    @Override
+    public void setUp() throws Exception {
+        localServer = ServerBootstrap.bootstrap().
+                setHttpProcessor(getBasicHttpProcessor()).
+                setConnectionReuseStrategy(getConnectionReuseStrategy()).
+                setResponseFactory(getHttpResponseFactory()).
+                setExpectationVerifier(getHttpExpectationVerifier()).
+                setSslContext(getSSLContext()).
+                registerHandler("/myget", new BasicValidationHandler("GET", null, null, getExpectedContent())).
+                create();
+        localServer.start();
+
+        super.setUp();
+    }
+
+    @After
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+
+        if (localServer != null) {
+            localServer.stop();
+        }
+    }
+
+    @Test
+    public void noDataDefaultIsGet() throws Exception {
+        HttpComponent component = context.getComponent("http4", HttpComponent.class);
+        component.setConnectionTimeToLive(1000L);
+        HttpEndpoint endpoiont = (HttpEndpoint) component.createEndpoint("http4://" + localServer.getInetAddress().getHostName() + ":" 
+            + localServer.getLocalPort() + "/myget?connectionClose=true");
+        HttpProducer producer = new HttpProducer(endpoiont);
+        Exchange exchange = producer.createExchange();
+        exchange.getIn().setBody(null);
+        producer.start();
+        producer.process(exchange);
+        producer.stop();
+
+        assertEquals(HTTP.CONN_CLOSE, exchange.getOut().getHeader("connection"));
+        assertExchange(exchange);
+    }
+}
\ No newline at end of file


[2/6] camel git commit: CAMEL-9972: Explicitly add Connection Close HTTP header with a parameter in URI - camel-http

Posted by ac...@apache.org.
CAMEL-9972: Explicitly add Connection Close HTTP header with a parameter in URI - camel-http


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5d0759cf
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5d0759cf
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5d0759cf

Branch: refs/heads/master
Commit: 5d0759cf17e126d4241f7ef50fcae23da825b176
Parents: d4ade0f
Author: Andrea Cosentino <an...@gmail.com>
Authored: Wed May 18 08:05:16 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Wed May 18 08:05:16 2016 +0200

----------------------------------------------------------------------
 .../camel/component/http/HttpProducer.java      |  4 +
 .../http/HttpExplicitConnectionCloseTest.java   | 79 ++++++++++++++++++++
 2 files changed, 83 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5d0759cf/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
index ec1b2f1..8e488c5 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
@@ -139,6 +139,10 @@ public class HttpProducer extends DefaultProducer {
                 }
             }
         }
+        
+        if (getEndpoint().isConnectionClose()) {
+        	method.addRequestHeader("Connection", "close");
+        }
 
         // lets store the result in the output message.
         try {

http://git-wip-us.apache.org/repos/asf/camel/blob/5d0759cf/components/camel-http/src/test/java/org/apache/camel/component/http/HttpExplicitConnectionCloseTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpExplicitConnectionCloseTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpExplicitConnectionCloseTest.java
new file mode 100644
index 0000000..7192d63
--- /dev/null
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpExplicitConnectionCloseTest.java
@@ -0,0 +1,79 @@
+/**
+ * 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.http;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class HttpExplicitConnectionCloseTest extends CamelTestSupport {
+    protected String expectedText = "activemq";
+    
+    @Test
+    @Ignore("ignore online tests")
+    public void testHttpGetConnectionClose() throws Exception {
+        MockEndpoint mockEndpoint = resolveMandatoryEndpoint("mock:results", MockEndpoint.class);
+        mockEndpoint.expectedMessageCount(1);
+
+        template.sendBody("direct:start", null);
+
+        mockEndpoint.assertIsSatisfied();
+        List<Exchange> list = mockEndpoint.getReceivedExchanges();
+        Exchange exchange = list.get(0);
+        assertNotNull("exchange", exchange);
+
+        Message in = exchange.getIn();
+        assertNotNull("in", in);
+
+        Map<String, Object> headers = in.getHeaders();
+
+        log.debug("Headers: " + headers);
+        checkHeaders(headers);       
+
+        String body = in.getBody(String.class);
+
+        log.debug("Body: " + body);
+        assertNotNull("Should have a body!", body);
+        assertTrue("body should contain: " + expectedText, body.contains(expectedText));
+    }
+
+    protected void checkHeaders(Map<String, Object> headers) {
+        assertTrue("Should be more than one header but was: " + headers, headers.size() > 0);
+        assertEquals("close", headers.get("Connection"));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                getContext().addComponent("http2", new HttpComponent());
+                from("direct:start").setHeader(Exchange.HTTP_QUERY, constant("hl=en&q=activemq"))
+                    .to("http2://www.google.com/search?connectionClose=true").to("mock:results");
+            }
+        };
+    }
+}


[3/6] camel git commit: CAMEL-9972: Explicitly add Connection Close HTTP header with a parameter in URI - camel-jetty

Posted by ac...@apache.org.
CAMEL-9972: Explicitly add Connection Close HTTP header with a parameter in URI - camel-jetty


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c504e012
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c504e012
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c504e012

Branch: refs/heads/master
Commit: c504e0128f7220a7a85edc88082c825fc57b044b
Parents: 5d0759c
Author: Andrea Cosentino <an...@gmail.com>
Authored: Wed May 18 08:05:21 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Wed May 18 08:05:21 2016 +0200

----------------------------------------------------------------------
 components/camel-http/src/main/docs/http.adoc   |  5 +-
 .../component/jetty/JettyHttpProducer.java      |  6 ++
 .../camel-jetty9/src/main/docs/jetty.adoc       |  5 +-
 .../jetty/HttpProducerConnectionCloseTest.java  | 61 ++++++++++++++++++++
 4 files changed, 75 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c504e012/components/camel-http/src/main/docs/http.adoc
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/docs/http.adoc b/components/camel-http/src/main/docs/http.adoc
index b0a56a5..4022639 100644
--- a/components/camel-http/src/main/docs/http.adoc
+++ b/components/camel-http/src/main/docs/http.adoc
@@ -143,8 +143,9 @@ The HTTP component supports 6 options which are listed below.
 
 
 
+
 // endpoint options: START
-The HTTP component supports 25 endpoint options which are listed below:
+The HTTP component supports 26 endpoint options which are listed below:
 
 {% raw %}
 [width="100%",cols="2s,1,1m,1m,5",options="header"]
@@ -155,6 +156,7 @@ The HTTP component supports 25 endpoint options which are listed below:
 | authMethodPriority | producer |  | String | Authentication method for proxy either as Basic Digest or NTLM.
 | bridgeEndpoint | producer | false | boolean | If the option is true HttpProducer will ignore the Exchange.HTTP_URI header and use the endpoint's URI for request. You may also set the option throwExceptionOnFailure to be false to let the HttpProducer send all the fault response back.
 | chunked | producer | true | boolean | If this option is false the Servlet will disable the HTTP streaming and set the content-length header on the response
+| connectionClose | producer | false | boolean | Specifies whether a Connection Close header must be added to HTTP Request. By default connectionClose is false.
 | copyHeaders | producer | true | boolean | If this option is true then IN exchange headers will be copied to OUT exchange headers according to copy strategy. Setting this to false allows to only include the headers from the HTTP response (not propagating IN headers).
 | headerFilterStrategy | producer |  | HeaderFilterStrategy | To use a custom HeaderFilterStrategy to filter header to and from Camel message.
 | httpBinding | producer |  | HttpBinding | To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
@@ -183,6 +185,7 @@ The HTTP component supports 25 endpoint options which are listed below:
 
 
 
+
 [[HTTP-MessageHeaders]]
 Message Headers
 ^^^^^^^^^^^^^^^

http://git-wip-us.apache.org/repos/asf/camel/blob/c504e012/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
index 2a01b39..52f32a5 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
@@ -225,6 +225,12 @@ public class JettyHttpProducer extends DefaultAsyncProducer implements AsyncProc
                 }
             }
         }
+        
+        System.out.println("Adding close");
+        if (getEndpoint().isConnectionClose()) {
+            System.out.println("in If");
+            httpExchange.addRequestHeader("Connection", "close");
+        }
 
         //In reverse proxy applications it can be desirable for the downstream service to see the original Host header
         //if this option is set, and the exchange Host header is not null, we will set it's current value on the httpExchange

http://git-wip-us.apache.org/repos/asf/camel/blob/c504e012/components/camel-jetty9/src/main/docs/jetty.adoc
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/main/docs/jetty.adoc b/components/camel-jetty9/src/main/docs/jetty.adoc
index e8abfef..5d47d69 100644
--- a/components/camel-jetty9/src/main/docs/jetty.adoc
+++ b/components/camel-jetty9/src/main/docs/jetty.adoc
@@ -101,8 +101,9 @@ The Jetty 9 component supports 30 options which are listed below.
 
 
 
+
 // endpoint options: START
-The Jetty 9 component supports 52 endpoint options which are listed below:
+The Jetty 9 component supports 53 endpoint options which are listed below:
 
 {% raw %}
 [width="100%",cols="2s,1,1m,1m,5",options="header"]
@@ -139,6 +140,7 @@ The Jetty 9 component supports 52 endpoint options which are listed below:
 | multipartFilterRef | consumer (advanced) |  | String | Allows using a custom multipart filter. Note: setting multipartFilterRef forces the value of enableMultipartFilter to true.
 | authMethodPriority | producer |  | String | Authentication method for proxy either as Basic Digest or NTLM.
 | bridgeEndpoint | producer | false | boolean | If the option is true HttpProducer will ignore the Exchange.HTTP_URI header and use the endpoint's URI for request. You may also set the option throwExceptionOnFailure to be false to let the HttpProducer send all the fault response back.
+| connectionClose | producer | false | boolean | Specifies whether a Connection Close header must be added to HTTP Request. By default connectionClose is false.
 | copyHeaders | producer | true | boolean | If this option is true then IN exchange headers will be copied to OUT exchange headers according to copy strategy. Setting this to false allows to only include the headers from the HTTP response (not propagating IN headers).
 | httpClientMaxThreads | producer | 254 | Integer | To set a value for maximum number of threads in HttpClient thread pool. This setting override any setting configured on component level. Notice that both a min and max size must be configured. If not set it default to max 254 threads used in Jettys thread pool.
 | httpClientMinThreads | producer | 8 | Integer | To set a value for minimum number of threads in HttpClient thread pool. This setting override any setting configured on component level. Notice that both a min and max size must be configured. If not set it default to min 8 threads used in Jettys thread pool.
@@ -167,6 +169,7 @@ The Jetty 9 component supports 52 endpoint options which are listed below:
 
 
 
+
 [[Jetty-MessageHeaders]]
 Message Headers
 ^^^^^^^^^^^^^^^

http://git-wip-us.apache.org/repos/asf/camel/blob/c504e012/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpProducerConnectionCloseTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpProducerConnectionCloseTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpProducerConnectionCloseTest.java
new file mode 100644
index 0000000..7dc337d
--- /dev/null
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpProducerConnectionCloseTest.java
@@ -0,0 +1,61 @@
+/**
+ * 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.jetty;
+
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class HttpProducerConnectionCloseTest extends BaseJettyTest {
+
+    private String url = "http://127.0.0.1:" + getPort() + "/cheese";
+
+    @Test
+    public void testConnectionCloseHeader() throws Exception {
+        Exchange exchange = template.request(url + "?connectionClose=true", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(Exchange.HTTP_QUERY, "quote=Camel rocks");
+            }
+        });
+        assertNotNull(exchange);
+
+        Map<?, ?> headers = exchange.getOut().getHeaders();
+
+        assertEquals("close", headers.get("Connection"));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("jetty:" + url).process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        String quote = exchange.getIn().getHeader("quote", String.class);
+                        assertEquals("Camel rocks", quote);
+                    }
+                });
+            }
+        };
+    }
+}
\ No newline at end of file


[5/6] camel git commit: Fixed CS

Posted by ac...@apache.org.
Fixed CS


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e509811a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e509811a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e509811a

Branch: refs/heads/master
Commit: e509811ade654f433e8ea6125529a045e1292e95
Parents: 989886a
Author: Andrea Cosentino <an...@gmail.com>
Authored: Wed May 18 09:00:51 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Wed May 18 09:00:51 2016 +0200

----------------------------------------------------------------------
 components/camel-ahc/src/main/docs/ahc.adoc             |  5 ++++-
 .../org/apache/camel/component/ahc/AhcEndpoint.java     | 12 ++++++------
 .../apache/camel/http/common/HttpCommonEndpoint.java    | 12 ++++++------
 .../org/apache/camel/component/http/HttpProducer.java   |  2 +-
 .../org/apache/camel/component/http4/HttpProducer.java  |  2 +-
 5 files changed, 18 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e509811a/components/camel-ahc/src/main/docs/ahc.adoc
----------------------------------------------------------------------
diff --git a/components/camel-ahc/src/main/docs/ahc.adoc b/components/camel-ahc/src/main/docs/ahc.adoc
index 6ee94f4..a44a3b8 100644
--- a/components/camel-ahc/src/main/docs/ahc.adoc
+++ b/components/camel-ahc/src/main/docs/ahc.adoc
@@ -48,8 +48,9 @@ AhcEndpoint Options
 
 
 
+
 // endpoint options: START
-The AHC component supports 12 endpoint options which are listed below:
+The AHC component supports 13 endpoint options which are listed below:
 
 {% raw %}
 [width="100%",cols="2s,1,1m,1m,5",options="header"]
@@ -59,6 +60,7 @@ The AHC component supports 12 endpoint options which are listed below:
 | binding | producer |  | AhcBinding | To use a custom AhcBinding which allows to control how to bind between AHC and Camel.
 | bridgeEndpoint | producer | false | boolean | If the option is true then the Exchange.HTTP_URI header is ignored and use the endpoint's URI for request. You may also set the throwExceptionOnFailure to be false to let the AhcProducer send all the fault response back.
 | bufferSize | producer | 4096 | int | The initial in-memory buffer size used when transferring data between Camel and AHC Client.
+| connectionClose | producer | false | boolean | Define if the Connection Close header has to be added to HTTP Request. This parameter is false by default
 | headerFilterStrategy | producer |  | HeaderFilterStrategy | To use a custom HeaderFilterStrategy to filter header to and from Camel message.
 | throwExceptionOnFailure | producer | true | boolean | Option to disable throwing the AhcOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code.
 | transferException | producer | false | boolean | If enabled and an Exchange failed processing on the consumer side and if the caused Exception was send back serialized in the response as a application/x-java-serialized-object content type (for example using Jetty or Servlet Camel components). On the producer side the exception will be deserialized and thrown as is instead of the AhcOperationFailedException. The caused exception is required to be serialized. This is by default turned off. If you enable this then be aware that Java will deserialize the incoming data from the request to Java and that can be a potential security risk.
@@ -77,6 +79,7 @@ The AHC component supports 12 endpoint options which are listed below:
 
 
 
+
 [[AHC-AhcComponentOptions]]
 AhcComponent Options
 ^^^^^^^^^^^^^^^^^^^^

http://git-wip-us.apache.org/repos/asf/camel/blob/e509811a/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java b/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java
index b488a73..bbb31d6 100644
--- a/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java
+++ b/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java
@@ -233,17 +233,17 @@ public class AhcEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade
     }
 
     public boolean isConnectionClose() {
-		return connectionClose;
-	}
+        return connectionClose;
+    }
     
     /**
      * Define if the Connection Close header has to be added to HTTP Request. This parameter is false by default
      */
-	public void setConnectionClose(boolean connectionClose) {
-		this.connectionClose = connectionClose;
-	}
+    public void setConnectionClose(boolean connectionClose) {
+        this.connectionClose = connectionClose;
+    }
 
-	@Override
+    @Override
     protected void doStart() throws Exception {
         super.doStart();
         if (client == null) {

http://git-wip-us.apache.org/repos/asf/camel/blob/e509811a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
index 0622e31..cb6e7ec 100644
--- a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
@@ -366,16 +366,16 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
         return transferException;
     }
     
-	public boolean isConnectionClose() {
-		return connectionClose;
-	}
+    public boolean isConnectionClose() {
+        return connectionClose;
+    }
 
     /**
      * If this option is true, the producer will add a Connection Close header to HTTP Request
      */
-	public void setConnectionClose(boolean connectionClose) {
-		this.connectionClose = connectionClose;
-	}
+    public void setConnectionClose(boolean connectionClose) {
+        this.connectionClose = connectionClose;
+    }
 
     /**
      * If enabled and an Exchange failed processing on the consumer side, and if the caused Exception was send back serialized

http://git-wip-us.apache.org/repos/asf/camel/blob/e509811a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
index 8e488c5..e855f92 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
@@ -141,7 +141,7 @@ public class HttpProducer extends DefaultProducer {
         }
         
         if (getEndpoint().isConnectionClose()) {
-        	method.addRequestHeader("Connection", "close");
+            method.addRequestHeader("Connection", "close");
         }
 
         // lets store the result in the output message.

http://git-wip-us.apache.org/repos/asf/camel/blob/e509811a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
index e10866d..dc60660 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
@@ -166,7 +166,7 @@ public class HttpProducer extends DefaultProducer {
         }
         
         if (getEndpoint().isConnectionClose()) {
-        	httpRequest.addHeader("Connection", HTTP.CONN_CLOSE);
+            httpRequest.addHeader("Connection", HTTP.CONN_CLOSE);
         }
 
         // lets store the result in the output message.


[6/6] camel git commit: Removed unuseful system out

Posted by ac...@apache.org.
Removed unuseful system out


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/bfd6e49d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/bfd6e49d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/bfd6e49d

Branch: refs/heads/master
Commit: bfd6e49d2007a8a3fde9d9e265c6bc30d1fd6718
Parents: e509811
Author: Andrea Cosentino <an...@gmail.com>
Authored: Wed May 18 09:04:01 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Wed May 18 09:04:01 2016 +0200

----------------------------------------------------------------------
 .../java/org/apache/camel/component/jetty/JettyHttpProducer.java   | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/bfd6e49d/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
index 52f32a5..e0595bc 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
@@ -226,9 +226,7 @@ public class JettyHttpProducer extends DefaultAsyncProducer implements AsyncProc
             }
         }
         
-        System.out.println("Adding close");
         if (getEndpoint().isConnectionClose()) {
-            System.out.println("in If");
             httpExchange.addRequestHeader("Connection", "close");
         }
 


[4/6] camel git commit: CAMEL-9972: Explicitly add Connection Close HTTP header with a parameter in URI - camel-ahc

Posted by ac...@apache.org.
CAMEL-9972: Explicitly add Connection Close HTTP header with a parameter in URI - camel-ahc


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/989886a9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/989886a9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/989886a9

Branch: refs/heads/master
Commit: 989886a96a6d3b13f169b7b9dac3fc5e7c32af9e
Parents: c504e01
Author: Andrea Cosentino <an...@gmail.com>
Authored: Wed May 18 08:05:27 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Wed May 18 08:05:27 2016 +0200

----------------------------------------------------------------------
 .../apache/camel/component/ahc/AhcEndpoint.java | 15 ++++-
 .../camel/component/ahc/DefaultAhcBinding.java  |  4 ++
 .../AhcProducerConnectionCloseHeadersTest.java  | 63 ++++++++++++++++++++
 3 files changed, 81 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/989886a9/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java b/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java
index 45cee12..b488a73 100644
--- a/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java
+++ b/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java
@@ -63,6 +63,8 @@ public class AhcEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade
     private AsyncHttpClientConfig clientConfig;
     @UriParam(label = "advanced", prefix = "clientConfig.", multiValue = true)
     private Map<String, Object> clientConfigOptions;
+    @UriParam(label = "producer", defaultValue = "false")
+    private boolean connectionClose;
 
     public AhcEndpoint(String endpointUri, AhcComponent component, URI httpUri) {
         super(endpointUri, component);
@@ -230,7 +232,18 @@ public class AhcEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade
         this.clientConfigOptions = clientConfigOptions;
     }
 
-    @Override
+    public boolean isConnectionClose() {
+		return connectionClose;
+	}
+    
+    /**
+     * Define if the Connection Close header has to be added to HTTP Request. This parameter is false by default
+     */
+	public void setConnectionClose(boolean connectionClose) {
+		this.connectionClose = connectionClose;
+	}
+
+	@Override
     protected void doStart() throws Exception {
         super.doStart();
         if (client == null) {

http://git-wip-us.apache.org/repos/asf/camel/blob/989886a9/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/DefaultAhcBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/DefaultAhcBinding.java b/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/DefaultAhcBinding.java
index 15fea80..f7160aa 100644
--- a/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/DefaultAhcBinding.java
+++ b/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/DefaultAhcBinding.java
@@ -109,6 +109,10 @@ public class DefaultAhcBinding implements AhcBinding {
                 builder.addHeader(entry.getKey(), headerValue);
             }
         }
+        
+        if (endpoint.isConnectionClose()) {
+            builder.addHeader("Connection", "close");
+        }
     }
 
     protected void populateBody(RequestBuilder builder, AhcEndpoint endpoint, Exchange exchange) throws CamelExchangeException {

http://git-wip-us.apache.org/repos/asf/camel/blob/989886a9/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerConnectionCloseHeadersTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerConnectionCloseHeadersTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerConnectionCloseHeadersTest.java
new file mode 100644
index 0000000..946184d
--- /dev/null
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerConnectionCloseHeadersTest.java
@@ -0,0 +1,63 @@
+/**
+ * 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.ahc;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+public class AhcProducerConnectionCloseHeadersTest extends BaseAhcTest {
+
+    @Test
+    public void testAhcProduce() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
+        getMockEndpoint("mock:result").expectedHeaderReceived("foo", 123);
+        getMockEndpoint("mock:result").expectedHeaderReceived("bar", "cool");
+        getMockEndpoint("mock:result").expectedHeaderReceived(Exchange.HTTP_RESPONSE_CODE, 200);
+        getMockEndpoint("mock:result").expectedHeaderReceived(Exchange.HTTP_RESPONSE_TEXT, "OK");
+        getMockEndpoint("mock:result").expectedHeaderReceived(Exchange.CONTENT_LENGTH, 9);
+        getMockEndpoint("mock:result").expectedHeaderReceived("Connection", "close");
+
+        Map<String, Object> headers = new HashMap<String, Object>();
+        headers.put("foo", 123);
+        headers.put("bar", "cool");
+
+        template.sendBodyAndHeaders("direct:start", null, headers);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to(getAhcEndpointUri() + "?connectionClose=true")
+                    .to("mock:result");
+
+                from(getTestServerEndpointUri())
+                        // Remove the message header here
+                        .removeHeaders("*")
+                        .transform(constant("Bye World"));
+            }
+        };
+    }
+}