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

davsclaus pushed a commit to branch feature/CAMEL-23789-wave1-multi-dsl-docs
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 4923399df9f465e791608c7197857861a9b62db8
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Jun 17 19:26:00 2026 +0200

    CAMEL-23789: Make HTTP component docs multi-DSL friendly (Wave 1)
    
    Co-Authored-By: Claude <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../camel-http/src/main/docs/http-component.adoc   | 275 +++++++++++++++++----
 1 file changed, 229 insertions(+), 46 deletions(-)

diff --git a/components/camel-http/src/main/docs/http-component.adoc 
b/components/camel-http/src/main/docs/http-component.adoc
index d466543344fd..26fa4c622955 100644
--- a/components/camel-http/src/main/docs/http-component.adoc
+++ b/components/camel-http/src/main/docs/http-component.adoc
@@ -105,6 +105,7 @@ the HTTP component will appear to hang for that duration.
 
 To avoid this, you can disable automatic retries on the component:
 
+._Java-only: programmatic `HttpComponent` configuration_
 [source,java]
 ----
 HttpComponent httpComponent = context.getComponent("https", 
HttpComponent.class);
@@ -184,12 +185,45 @@ YAML::
 You can override the HTTP endpoint URI by adding a header with the key
 `Exchange.HTTP_URI` on the message.
 
+[tabs]
+====
+Java::
++
 [source,java]
------------------------------------------------------------
+----
 from("direct:start")
-  .setHeader(Exchange.HTTP_URI, constant("http://newhost";))
+  .setHeader("CamelHttpUri", constant("http://newhost";))
   .to("http://oldhost";);
------------------------------------------------------------
+----
+
+XML::
++
+[source,xml]
+----
+<route>
+  <from uri="direct:start"/>
+  <setHeader name="CamelHttpUri">
+    <constant>http://newhost</constant>
+  </setHeader>
+  <to uri="http://oldhost"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+    from:
+      uri: direct:start
+      steps:
+        - setHeader:
+            name: CamelHttpUri
+            constant: "http://newhost";
+        - to:
+            uri: http://oldhost
+----
+====
 
 In the sample above, Camel will call the http://newhost despite the
 endpoint is configured with http://oldhost. +
@@ -240,37 +274,67 @@ YAML::
 
 Or options provided in a header:
 
+[tabs]
+====
+Java::
++
 [source,java]
----------------------------------------------------------------------
+----
 from("direct:start")
-  .setHeader(Exchange.HTTP_QUERY, constant("order=123&detail=short"))
+  .setHeader("CamelHttpQuery", constant("order=123&detail=short"))
   .to("http://oldhost";);
----------------------------------------------------------------------
+----
+
+XML::
++
+[source,xml]
+----
+<route>
+  <from uri="direct:start"/>
+  <setHeader name="CamelHttpQuery">
+    <constant>order=123&amp;detail=short</constant>
+  </setHeader>
+  <to uri="http://oldhost"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+    from:
+      uri: direct:start
+      steps:
+        - setHeader:
+            name: CamelHttpQuery
+            constant: "order=123&detail=short"
+        - to:
+            uri: http://oldhost
+----
+====
 
 === How to set the http method (GET/PATCH/POST/PUT/DELETE/HEAD/OPTIONS/TRACE) 
to the HTTP producer
 
 The HTTP component provides a way to set the HTTP request method by
 setting the message header. Here is an example:
 
+[tabs]
+====
+Java::
++
 [source,java]
------------------------------------------------------------------------------------------------
+----
 from("direct:start")
-  .setHeader(Exchange.HTTP_METHOD, 
constant(org.apache.camel.component.http.HttpMethods.POST))
+  .setHeader("CamelHttpMethod", constant("POST"))
   .to("http://www.google.com";)
   .to("mock:results");
------------------------------------------------------------------------------------------------
-
-The method can be written a bit shorter using the string constants:
-
-[source,java]
------------------------------------------------
-.setHeader("CamelHttpMethod", constant("POST"))
------------------------------------------------
-
-And the equivalent XML DSL:
+----
 
+XML::
++
 [source,xml]
----------------------------------------------------------------------
+----
 <route>
   <from uri="direct:start"/>
   <setHeader name="CamelHttpMethod">
@@ -279,7 +343,25 @@ And the equivalent XML DSL:
   <to uri="http://www.google.com"/>
   <to uri="mock:results"/>
 </route>
----------------------------------------------------------------------
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+    from:
+      uri: direct:start
+      steps:
+        - setHeader:
+            name: CamelHttpMethod
+            constant: POST
+        - to:
+            uri: http://www.google.com
+        - to:
+            uri: mock:results
+----
+====
 
 === Using client timeout - SO_TIMEOUT
 
@@ -338,6 +420,7 @@ To avoid System properties conflicts, you can set proxy 
configuration
 only from the CamelContext or URI. +
  Java DSL :
 
+._Java-only: programmatic `CamelContext` global options configuration 
(deprecated)_
 [source,java]
 ---------------------------------------------------------------
 context.getGlobalOptions().put("http.proxyHost", "172.168.18.9");
@@ -370,6 +453,7 @@ IMPORTANT: Using GlobalOptions (as shown above) is 
deprecated. Instead, configur
 If you are using `POST` to send data you can configure the `charset`
 using the `Exchange` property:
 
+._Java-only: setting exchange property programmatically_
 [source,java]
 ----------------------------------------------------------
 exchange.setProperty(Exchange.CHARSET_NAME, "ISO-8859-1");
@@ -380,13 +464,53 @@ exchange.setProperty(Exchange.CHARSET_NAME, "ISO-8859-1");
 This sample polls the Google homepage every 10 seconds and write the
 page to the file `message.html`:
 
+[tabs]
+====
+Java::
++
 [source,java]
-------------------------------------------------------------
+----
 from("timer://foo?fixedRate=true&delay=0&period=10000")
   .to("http://www.google.com";)
-  .setHeader(FileComponent.HEADER_FILE_NAME, "message.html")
+  .setHeader("CamelFileName", constant("message.html"))
   .to("file:target/google");
-------------------------------------------------------------
+----
+
+XML::
++
+[source,xml]
+----
+<route>
+  <from uri="timer://foo?fixedRate=true&amp;delay=0&amp;period=10000"/>
+  <to uri="http://www.google.com"/>
+  <setHeader name="CamelFileName">
+    <constant>message.html</constant>
+  </setHeader>
+  <to uri="file:target/google"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+    from:
+      uri: timer://foo
+      parameters:
+        fixedRate: true
+        delay: 0
+        period: 10000
+      steps:
+        - to:
+            uri: http://www.google.com
+        - setHeader:
+            name: CamelFileName
+            constant: message.html
+        - to:
+            uri: file:target/google
+----
+====
 
 ==== URI Parameters from the endpoint URI
 
@@ -395,6 +519,7 @@ would have typed in a web browser. Multiple URI parameters 
can of course
 be set using the `&` character as separator, just as you would in the
 web browser. Camel does no tricks here.
 
+._Java-only: uses `ProducerTemplate` test API_
 [source,java]
 -----------------------------------------------------------------
 // we query for Camel at the Google page
@@ -403,6 +528,7 @@ template.sendBody("http://www.google.com/search?q=Camel";, 
null);
 
 ==== URI Parameters from the Message
 
+._Java-only: uses `ProducerTemplate` test API with headers_
 [source,java]
 ------------------------------------------------------------------
 Map headers = new HashMap();
@@ -420,15 +546,14 @@ You can get the HTTP response code from the HTTP 
component by getting
 the value from the Out message header with
 `Exchange.HTTP_RESPONSE_CODE`.
 
+._Java-only: uses `ProducerTemplate` and `Processor` to inspect response code_
 [source,java]
 
------------------------------------------------------------------------------------
-Exchange exchange = template.send("http://www.google.com/search";, new 
Processor() {
-  public void process(Exchange exchange) throws Exception {
-    exchange.getIn().setHeader(Exchange.HTTP_QUERY, 
constant("hl=en&q=activemq"));
-  }
+Exchange exchange = template.send("http://www.google.com/search";, e -> {
+    e.getIn().setHeader("CamelHttpQuery", "hl=en&q=activemq");
 });
-Message out = exchange.getOut();
-int responseCode = out.getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class);
+Message out = exchange.getMessage();
+int responseCode = out.getHeader("CamelHttpResponseCode", Integer.class);
 
------------------------------------------------------------------------------------
 
 === Defining specific properties of Apache HTTP client via Camel parameters
@@ -467,30 +592,84 @@ To get an access token from an Authorization Server and 
fill that in Authorizati
 
 In below example camel will do an underlying request to 
`https://localhost:8080/realms/master/protocol/openid-connect/token` using 
provided credentials (client id and client secret), then will get 
`access_token` from response and lastly will fill it at `Authorization` header 
of request which will be done to `https://localhost:9090`.
 
+[tabs]
+====
+Java::
++
 [source,java]
-------------------------------------------------------------------------------------
-String clientId = "my-client-id";
-String clientSecret = "my-client-secret";
-String tokenEndpoint = 
"https://localhost:8080/realms/master/protocol/openid-connect/token";;
-String scope = "my-scope"; // optional scope
-
+----
 from("direct:start")
-  .to("https://localhost:9090/?oauth2ClientId="; + clientId + 
"&oauth2ClientSecret=" + clientSecret + "&oauth2TokenEndpoint=" + tokenEndpoint 
+ "&oauth2Scope=" + scope);
-------------------------------------------------------------------------------------
+  
.to("https://localhost:9090/?oauth2ClientId=my-client-id&oauth2ClientSecret=my-client-secret&oauth2TokenEndpoint=https://localhost:8080/realms/master/protocol/openid-connect/token&oauth2Scope=my-scope";);
+----
+
+XML::
++
+[source,xml]
+----
+<route>
+  <from uri="direct:start"/>
+  <to 
uri="https://localhost:9090/?oauth2ClientId=my-client-id&amp;oauth2ClientSecret=my-client-secret&amp;oauth2TokenEndpoint=https://localhost:8080/realms/master/protocol/openid-connect/token&amp;oauth2Scope=my-scope"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+    from:
+      uri: direct:start
+      steps:
+        - to:
+            uri: "https://localhost:9090/";
+            parameters:
+              oauth2ClientId: my-client-id
+              oauth2ClientSecret: my-client-secret
+              oauth2TokenEndpoint: 
"https://localhost:8080/realms/master/protocol/openid-connect/token";
+              oauth2Scope: my-scope
+----
+====
 
 Additional support for OAuth2 is for RFC 8707 where a _Resource Indicator_ 
must be provided in the body:
 
+[tabs]
+====
+Java::
++
 [source,java]
-------------------------------------------------------------------------------------
-String clientId = "my-client-id";
-String clientSecret = "my-client-secret";
-String tokenEndpoint = 
"https://localhost:8080/realms/master/protocol/openid-connect/token";;
-String scope = "my-scope"; // optional scope
-String resourceIndicator = "https://localhost:9090";; // optional, for RFC 8707
-
+----
 from("direct:start")
-  .to("https://localhost:9090/?oauth2ClientId="; + clientId + 
"&oauth2ClientSecret=" + clientSecret + "&oauth2TokenEndpoint=" + tokenEndpoint 
+ "&oauth2Scope=" + scope + "&oauth2ResourceIndicator=" + resourceIndicator);
-------------------------------------------------------------------------------------
+  
.to("https://localhost:9090/?oauth2ClientId=my-client-id&oauth2ClientSecret=my-client-secret&oauth2TokenEndpoint=https://localhost:8080/realms/master/protocol/openid-connect/token&oauth2Scope=my-scope&oauth2ResourceIndicator=https://localhost:9090";);
+----
+
+XML::
++
+[source,xml]
+----
+<route>
+  <from uri="direct:start"/>
+  <to 
uri="https://localhost:9090/?oauth2ClientId=my-client-id&amp;oauth2ClientSecret=my-client-secret&amp;oauth2TokenEndpoint=https://localhost:8080/realms/master/protocol/openid-connect/token&amp;oauth2Scope=my-scope&amp;oauth2ResourceIndicator=https://localhost:9090"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+    from:
+      uri: direct:start
+      steps:
+        - to:
+            uri: "https://localhost:9090/";
+            parameters:
+              oauth2ClientId: my-client-id
+              oauth2ClientSecret: my-client-secret
+              oauth2TokenEndpoint: 
"https://localhost:8080/realms/master/protocol/openid-connect/token";
+              oauth2Scope: my-scope
+              oauth2ResourceIndicator: "https://localhost:9090";
+----
+====
 
 NOTE: Resource Indicator is the URL to the actual endpoint as defined in the 
component URI.
 
@@ -521,6 +700,7 @@ to use the utility with the HTTP component.
 [[HTTP-Programmaticconfigurationofthecomponent]]
 Programmatic configuration of the component
 
+._Java-only: programmatic `SSLContextParameters` setup_
 [source,java]
 
---------------------------------------------------------------------------------------
 KeyStoreParameters ksp = new KeyStoreParameters();
@@ -574,6 +754,7 @@ configuration on the http client if you need full control 
of it.
 However, if you _just_ want to specify the keystore and truststore, you
 can do this with Apache HTTP `HttpClientConfigurer`, for example:
 
+._Java-only: programmatic `KeyStore` and `SchemeRegistry` setup_
 [source,java]
 
------------------------------------------------------------------------------------------------------
 KeyStore keystore = ...;
@@ -588,6 +769,7 @@ And then you need to create a class that implements
 keystore or truststore per the example above. Then, from your camel route
 builder class, you can hook it up like so:
 
+._Java-only: programmatic `HttpClientConfigurer` setup_
 [source,java]
 
--------------------------------------------------------------------------------------
 HttpComponent httpComponent = getContext().getComponent("http", 
HttpComponent.class);
@@ -618,6 +800,7 @@ The problem was eventually resolved by providing a custom 
configured
 
 * 1. Create a (Spring) factory for HttpContexts:
 
+._Java-only: custom `HttpContext` factory for preemptive basic authentication_
 [source,java]
 ------------------------------------------------------------------
 public class HttpContextFactory {

Reply via email to