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

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 6a7e57d  Regen
6a7e57d is described below

commit 6a7e57d309898771348fda5be9d27a580d5f7d17
Author: Andrea Cosentino <anco...@gmail.com>
AuthorDate: Wed May 15 12:39:00 2019 +0200

    Regen
---
 .../src/main/docs/netty4-http-component.adoc       |  4 +-
 .../modules/ROOT/pages/docker-component.adoc       |  2 +-
 .../modules/ROOT/pages/netty4-http-component.adoc  | 43 +++++++++++++++++++---
 3 files changed, 40 insertions(+), 9 deletions(-)

diff --git 
a/components/camel-netty4-http/src/main/docs/netty4-http-component.adoc 
b/components/camel-netty4-http/src/main/docs/netty4-http-component.adoc
index e2de392..f6ee0c0 100644
--- a/components/camel-netty4-http/src/main/docs/netty4-http-component.adoc
+++ b/components/camel-netty4-http/src/main/docs/netty4-http-component.adoc
@@ -259,12 +259,12 @@ The component supports 32 options, which are listed below.
 | *camel.component.netty4-http.configuration.ok-status-code-range* | The 
status codes which are considered a success response. The values are inclusive. 
Multiple ranges can be defined, separated by comma, e.g. 
<tt>200-204,209,301-304</tt>. Each range must be a single number or from-to 
with the dash included. <p/> The default range is <tt>200-299</tt> | 200-299 | 
String
 | *camel.component.netty4-http.configuration.path* | Resource path |  | String
 | *camel.component.netty4-http.configuration.port* | The port number. Is 
default 80 for http and 443 for https. |  | Integer
-| *camel.component.netty4-http.configuration.protocol* | The protocol to use 
which is either http or https |  | String
+| *camel.component.netty4-http.configuration.protocol* | The protocol to use 
which is either http, https or proxy - a consumer only option. |  | String
 | *camel.component.netty4-http.configuration.send503when-suspended* | Whether 
to send back HTTP status code 503 when the consumer has been suspended. If the 
option is false then the Netty Acceptor is unbound when the consumer is 
suspended, so clients cannot connect anymore. | true | Boolean
 | *camel.component.netty4-http.configuration.throw-exception-on-failure* | 
Option to disable throwing the HttpOperationFailedException in case of failed 
responses from the remote server. This allows you to get all responses 
regardless of the HTTP status code. | true | Boolean
 | *camel.component.netty4-http.configuration.transfer-exception* | 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. On the producer side the 
exception will be deserialized and thrown as is, instead of the 
HttpOperationFailedException. The caused exception is required to be 
serialized. <p/> This is by default turned off. If you enable this then be  
[...]
 | *camel.component.netty4-http.configuration.url-decode-headers* | If this 
option is enabled, then during binding from Netty to Camel Message then the 
header values will be URL decoded (eg %20 will be a space character. Notice 
this option is used by the default 
org.apache.camel.component.netty.http.NettyHttpBinding and therefore if you 
implement a custom org.apache.camel.component.netty4.http.NettyHttpBinding then 
you would need to decode the headers accordingly to this option. | false | [...]
-| *camel.component.netty4-http.configuration.use-relative-path* | Sets whether 
to use a relative path in HTTP requests. | false | Boolean
+| *camel.component.netty4-http.configuration.use-relative-path* | Sets whether 
to use a relative path in HTTP requests. | true | Boolean
 | *camel.component.netty4-http.enabled* | Enable netty4-http component | true 
| Boolean
 | *camel.component.netty4-http.executor-service* | To use the given 
EventExecutorGroup. The option is a io.netty.util.concurrent.EventExecutorGroup 
type. |  | String
 | *camel.component.netty4-http.header-filter-strategy* | To use a custom 
org.apache.camel.spi.HeaderFilterStrategy to filter headers. The option is a 
org.apache.camel.spi.HeaderFilterStrategy type. |  | String
diff --git a/docs/components/modules/ROOT/pages/docker-component.adoc 
b/docs/components/modules/ROOT/pages/docker-component.adoc
index 33982ff..dc3b283 100644
--- a/docs/components/modules/ROOT/pages/docker-component.adoc
+++ b/docs/components/modules/ROOT/pages/docker-component.adoc
@@ -63,7 +63,7 @@ with the following path and query parameters:
 | Name | Description | Default | Type
 | *email* (common) | Email address associated with the user |  | String
 | *host* (common) | *Required* Docker host | localhost | String
-| *port* (common) | *Required* Docker port | 2375 | Integer
+| *port* (common) | Docker port | 2375 | Integer
 | *requestTimeout* (common) | Request timeout for response (in seconds) |  | 
Integer
 | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the 
Camel routing Error Handler, which mean any exceptions occurred while the 
consumer is trying to pickup incoming messages, or the likes, will now be 
processed as a message and handled by the routing Error Handler. By default the 
consumer will use the org.apache.camel.spi.ExceptionHandler to deal with 
exceptions, that will be logged at WARN or ERROR level and ignored. | false | 
boolean
 | *exceptionHandler* (consumer) | To let the consumer use a custom 
ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this 
option is not in use. By default the consumer will deal with exceptions, that 
will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
diff --git a/docs/components/modules/ROOT/pages/netty4-http-component.adoc 
b/docs/components/modules/ROOT/pages/netty4-http-component.adoc
index 7dc8ee9..f6ee0c0 100644
--- a/docs/components/modules/ROOT/pages/netty4-http-component.adoc
+++ b/docs/components/modules/ROOT/pages/netty4-http-component.adoc
@@ -131,7 +131,7 @@ with the following path and query parameters:
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *protocol* | *Required* The protocol to use which is either http or https |  
| String
+| *protocol* | *Required* The protocol to use which is either http, https or 
proxy - a consumer only option. |  | String
 | *host* | *Required* The local hostname such as localhost, or 0.0.0.0 when 
being a consumer. The remote HTTP server hostname when using producer. |  | 
String
 | *port* | The host port number |  | int
 | *path* | Resource path |  | String
@@ -183,7 +183,7 @@ with the following path and query parameters:
 | *producerPoolMaxIdle* (producer) | Sets the cap on the number of idle 
instances in the pool. | 100 | int
 | *producerPoolMinEvictable Idle* (producer) | Sets the minimum amount of time 
(value in millis) an object may sit idle in the pool before it is eligible for 
eviction by the idle object evictor. | 300000 | long
 | *producerPoolMinIdle* (producer) | Sets the minimum number of instances 
allowed in the producer pool before the evictor thread (if active) spawns new 
objects. |  | int
-| *useRelativePath* (producer) | Sets whether to use a relative path in HTTP 
requests. | false | boolean
+| *useRelativePath* (producer) | Sets whether to use a relative path in HTTP 
requests. | true | boolean
 | *allowSerializedHeaders* (advanced) | Only used for TCP when 
transferExchange is true. When set to true, serializable objects in headers and 
properties will be added to the exchange. Otherwise Camel will exclude any 
non-serializable objects and log it at WARN level. | false | boolean
 | *channelGroup* (advanced) | To use a explicit ChannelGroup. |  | ChannelGroup
 | *configuration* (advanced) | To use a custom configured 
NettyHttpConfiguration for configuring this endpoint. |  | 
NettyHttpConfiguration
@@ -259,12 +259,12 @@ The component supports 32 options, which are listed below.
 | *camel.component.netty4-http.configuration.ok-status-code-range* | The 
status codes which are considered a success response. The values are inclusive. 
Multiple ranges can be defined, separated by comma, e.g. 
<tt>200-204,209,301-304</tt>. Each range must be a single number or from-to 
with the dash included. <p/> The default range is <tt>200-299</tt> | 200-299 | 
String
 | *camel.component.netty4-http.configuration.path* | Resource path |  | String
 | *camel.component.netty4-http.configuration.port* | The port number. Is 
default 80 for http and 443 for https. |  | Integer
-| *camel.component.netty4-http.configuration.protocol* | The protocol to use 
which is either http or https |  | String
+| *camel.component.netty4-http.configuration.protocol* | The protocol to use 
which is either http, https or proxy - a consumer only option. |  | String
 | *camel.component.netty4-http.configuration.send503when-suspended* | Whether 
to send back HTTP status code 503 when the consumer has been suspended. If the 
option is false then the Netty Acceptor is unbound when the consumer is 
suspended, so clients cannot connect anymore. | true | Boolean
 | *camel.component.netty4-http.configuration.throw-exception-on-failure* | 
Option to disable throwing the HttpOperationFailedException in case of failed 
responses from the remote server. This allows you to get all responses 
regardless of the HTTP status code. | true | Boolean
 | *camel.component.netty4-http.configuration.transfer-exception* | 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. On the producer side the 
exception will be deserialized and thrown as is, instead of the 
HttpOperationFailedException. The caused exception is required to be 
serialized. <p/> This is by default turned off. If you enable this then be  
[...]
 | *camel.component.netty4-http.configuration.url-decode-headers* | If this 
option is enabled, then during binding from Netty to Camel Message then the 
header values will be URL decoded (eg %20 will be a space character. Notice 
this option is used by the default 
org.apache.camel.component.netty.http.NettyHttpBinding and therefore if you 
implement a custom org.apache.camel.component.netty4.http.NettyHttpBinding then 
you would need to decode the headers accordingly to this option. | false | [...]
-| *camel.component.netty4-http.configuration.use-relative-path* | Sets whether 
to use a relative path in HTTP requests. | false | Boolean
+| *camel.component.netty4-http.configuration.use-relative-path* | Sets whether 
to use a relative path in HTTP requests. | true | Boolean
 | *camel.component.netty4-http.enabled* | Enable netty4-http component | true 
| Boolean
 | *camel.component.netty4-http.executor-service* | To use the given 
EventExecutorGroup. The option is a io.netty.util.concurrent.EventExecutorGroup 
type. |  | String
 | *camel.component.netty4-http.header-filter-strategy* | To use a custom 
org.apache.camel.spi.HeaderFilterStrategy to filter headers. The option is a 
org.apache.camel.spi.HeaderFilterStrategy type. |  | String
@@ -391,7 +391,7 @@ ProducerTemplate as shown below:
 
 And we get back "Bye World" as the output.
 
-=== How do I let Netty match wildcards
+==== How do I let Netty match wildcards
 
 By default Netty4 HTTP will only match on exact uri's. But you can
 instruct Netty to match prefixes. For example
@@ -422,7 +422,7 @@ To match *any* endpoint you can do:
 from("netty4-http:http://0.0.0.0:8123?matchOnUriPrefix=true";).to("mock:foo");
 -----------------------------------------------------------------------------
 
-=== Using multiple routes with same port
+==== Using multiple routes with same port
 
 In the same CamelContext you can have multiple
 routes from Netty4 HTTP that shares the same port (eg a
@@ -517,6 +517,37 @@ And in the routes you refer to this option as shown below
 See the Netty HTTP Server Example
 for more details and example how to do that.
 
+==== Implementing a reverse proxy
+
+Netty HTTP component can act as a reverse proxy, in that case
+`Exchange.HTTP_SCHEME`, `Exchange.HTTP_HOST` and
+`Exchange.HTTP_PORT` headers are populated from the absolute
+URL received on the request line of the HTTP request.
+
+Here's an example of a HTTP proxy that simply transforms the response
+from the origin server to uppercase.
+
+[source,java]
+------------------------------------------------------------------------------------------
+from("netty-http:proxy://0.0.0.0:8080")
+    .toD("netty-http:"
+        + "${headers." + Exchange.HTTP_SCHEME + "}://"
+        + "${headers." + Exchange.HTTP_HOST + "}:"
+        + "${headers." + Exchange.HTTP_PORT + "}")
+    .process(this::processResponse);
+
+void processResponse(final Exchange exchange) {
+    final NettyHttpMessage message = exchange.getIn(NettyHttpMessage.class);
+    final FullHttpResponse response = message.getHttpResponse();
+
+    final ByteBuf buf = response.content();
+    final String string = buf.toString(StandardCharsets.UTF_8);
+
+    buf.resetWriterIndex();
+    ByteBufUtil.writeUtf8(buf, string.toUpperCase(Locale.US));
+}
+------------------------------------------------------------------------------------------
+
 === Using HTTP Basic Authentication
 
 The Netty HTTP consumer supports HTTP basic authentication by specifying

Reply via email to