This is an automated email from the ASF dual-hosted git repository. nfilotto pushed a commit to branch CAMEL-17792/doc-message-headers in repository https://gitbox.apache.org/repos/asf/camel.git
commit f770ef345d843ec1b287bc7ef3ff7f49f45e65ac Author: Nicolas Filotto <[email protected]> AuthorDate: Wed Mar 30 11:43:01 2022 +0200 CAMEL-17792: Add doc about the message headers of camel-jetty --- .../component/jetty/CamelContinuationServlet.java | 6 ++-- .../camel/component/jetty/JettyHttpConstants.java | 33 ++++++++++++++++++++++ .../org/apache/camel/component/jetty9/jetty.json | 4 +++ .../camel-jetty/src/main/docs/jetty-component.adoc | 6 +++- .../camel/component/jetty9/JettyHttpEndpoint9.java | 4 ++- 5 files changed, 48 insertions(+), 5 deletions(-) diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java index a1b9a4a..3a54272 100644 --- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java +++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java @@ -208,7 +208,7 @@ public class CamelContinuationServlet extends CamelServlet { } // set context path as header String contextPath = consumer.getEndpoint().getPath(); - exchange.getIn().setHeader("CamelServletContextPath", contextPath); + exchange.getIn().setHeader(JettyHttpConstants.SERVLET_CONTEXT_PATH, contextPath); updateHttpPath(exchange, contextPath); @@ -293,13 +293,13 @@ public class CamelContinuationServlet extends CamelServlet { } private void updateHttpPath(Exchange exchange, String contextPath) { - String httpPath = (String) exchange.getIn().getHeader(Exchange.HTTP_PATH); + String httpPath = (String) exchange.getIn().getHeader(JettyHttpConstants.HTTP_PATH); // encode context path in case it contains unsafe chars, because HTTP_PATH isn't decoded at this moment String encodedContextPath = UnsafeUriCharactersEncoder.encodeHttpURI(contextPath); // here we just remove the CamelServletContextPath part from the HTTP_PATH if (contextPath != null && httpPath.startsWith(encodedContextPath)) { - exchange.getIn().setHeader(Exchange.HTTP_PATH, httpPath.substring(encodedContextPath.length())); + exchange.getIn().setHeader(JettyHttpConstants.HTTP_PATH, httpPath.substring(encodedContextPath.length())); } } diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpConstants.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpConstants.java new file mode 100644 index 0000000..c12e223 --- /dev/null +++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpConstants.java @@ -0,0 +1,33 @@ +/* + * 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 org.apache.camel.Exchange; +import org.apache.camel.spi.Metadata; + +public final class JettyHttpConstants { + + @Metadata(description = "The servlet context path used", javaType = "String") + public static final String SERVLET_CONTEXT_PATH = "CamelServletContextPath"; + @Metadata(description = "Request URI's path, the header will be used to build the request URI\n" + + "with the HTTP_URI.", + javaType = "String") + public static final String HTTP_PATH = Exchange.HTTP_PATH; + + private JettyHttpConstants() { + } +} diff --git a/components/camel-jetty/src/generated/resources/org/apache/camel/component/jetty9/jetty.json b/components/camel-jetty/src/generated/resources/org/apache/camel/component/jetty9/jetty.json index 67a5948..dd9ccbf 100644 --- a/components/camel-jetty/src/generated/resources/org/apache/camel/component/jetty9/jetty.json +++ b/components/camel-jetty/src/generated/resources/org/apache/camel/component/jetty9/jetty.json @@ -57,6 +57,10 @@ "sslSocketConnectors": { "kind": "property", "displayName": "Ssl Socket Connectors", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "java.util.Map<java.lang.Integer, org.eclipse.jetty.server.Connector>", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A map which contains per port number specific SSL connectors." }, "useGlobalSslContextParameters": { "kind": "property", "displayName": "Use Global Ssl Context Parameters", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "description": "Enable usage of global SSL context parameters" } }, + "headers": { + "CamelServletContextPath": { "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The servlet context path used" }, + "CamelHttpPath": { "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Request URI's path, the header will be used to build the request URI\nwith the HTTP_URI." } + }, "properties": { "httpUri": { "kind": "path", "displayName": "Http Uri", "group": "common", "label": "common", "required": true, "type": "string", "javaType": "java.net.URI", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The url of the HTTP endpoint to call." }, "chunked": { "kind": "parameter", "displayName": "Chunked", "group": "consumer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "If this option is false the Servlet will disable the HTTP streaming and set the content-length header on the response" }, diff --git a/components/camel-jetty/src/main/docs/jetty-component.adoc b/components/camel-jetty/src/main/docs/jetty-component.adoc index 040e239..90ae00c 100644 --- a/components/camel-jetty/src/main/docs/jetty-component.adoc +++ b/components/camel-jetty/src/main/docs/jetty-component.adoc @@ -67,7 +67,7 @@ include::partial$component-endpoint-options.adoc[] Camel uses the same message headers as the xref:http-component.adoc[HTTP] component. It also uses (Exchange.HTTP_CHUNKED,CamelHttpChunked) -header to turn on or turn off the chuched encoding on the camel-jetty +header to turn on or turn off the chunked encoding on the camel-jetty consumer. Camel also populates *all* request.parameter and request.headers. For @@ -78,6 +78,10 @@ header named `orderid` with the value 123. You can get the request.parameter from the message header not only from Get Method, but also other HTTP method. +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END + == Usage The Jetty component supports consumer endpoints. diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/JettyHttpEndpoint9.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/JettyHttpEndpoint9.java index 8efbc77..52157b9 100644 --- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/JettyHttpEndpoint9.java +++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/JettyHttpEndpoint9.java @@ -23,6 +23,7 @@ import org.apache.camel.AsyncEndpoint; import org.apache.camel.Category; import org.apache.camel.component.jetty.JettyContentExchange; import org.apache.camel.component.jetty.JettyHttpComponent; +import org.apache.camel.component.jetty.JettyHttpConstants; import org.apache.camel.component.jetty.JettyHttpEndpoint; import org.apache.camel.http.common.HttpBinding; import org.apache.camel.spi.Metadata; @@ -32,7 +33,8 @@ import org.apache.camel.spi.UriEndpoint; * Expose HTTP endpoints using Jetty 9. */ @UriEndpoint(firstVersion = "1.2.0", scheme = "jetty", extendsScheme = "http", title = "Jetty", syntax = "jetty:httpUri", - category = { Category.HTTP }, consumerOnly = true, lenientProperties = true) + category = { Category.HTTP }, consumerOnly = true, lenientProperties = true, + headersClass = JettyHttpConstants.class) @Metadata(excludeProperties = "authMethod,authMethodPriority,authUsername,authPassword,authDomain,authHost" + "proxyAuthScheme,proxyAuthMethod,proxyAuthUsername,proxyAuthPassword,proxyAuthHost,proxyAuthPort,proxyAuthDomain") public class JettyHttpEndpoint9 extends JettyHttpEndpoint implements AsyncEndpoint {
