Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 853B42009EE for ; Wed, 18 May 2016 09:26:33 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 840FF1609B1; Wed, 18 May 2016 07:26:33 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8E5D9160A15 for ; Wed, 18 May 2016 09:26:32 +0200 (CEST) Received: (qmail 25369 invoked by uid 500); 18 May 2016 07:26:31 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 25296 invoked by uid 99); 18 May 2016 07:26:31 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 May 2016 07:26:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 71C19E01BD; Wed, 18 May 2016 07:26:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: acosentino@apache.org To: commits@camel.apache.org Date: Wed, 18 May 2016 07:26:33 -0000 Message-Id: <0974e6b1587a49d2879f4570639c2f58@git.apache.org> In-Reply-To: <1c537d51d3814f10a1406f68e655a4b0@git.apache.org> References: <1c537d51d3814f10a1406f68e655a4b0@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/6] camel git commit: CAMEL-9972: Explicitly add Connection Close HTTP header with a parameter in URI - camel-jetty archived-at: Wed, 18 May 2016 07:26:33 -0000 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 Authored: Wed May 18 08:05:21 2016 +0200 Committer: Andrea Cosentino 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