camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [1/2] camel git commit: CAMEL-10270: Jetty 9 X-Forwarded-For Configuration. Thanks to Remco Schoen.
Date Fri, 26 Aug 2016 09:27:44 GMT
Repository: camel
Updated Branches:
  refs/heads/master e7eca7c6b -> cff69b0cb


CAMEL-10270: Jetty 9 X-Forwarded-For Configuration. Thanks to Remco Schoen.


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

Branch: refs/heads/master
Commit: 08f46a76de7c697d8c816a7129bb3d4053f3f5a6
Parents: e7eca7c
Author: Andrea Cosentino <ancosen@gmail.com>
Authored: Fri Aug 26 11:16:35 2016 +0200
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Fri Aug 26 11:26:38 2016 +0200

----------------------------------------------------------------------
 .../camel/component/jetty/JettyHttpComponent.java  | 17 +++++++++++++++++
 .../component/jetty9/JettyHttpComponent9.java      |  5 ++++-
 2 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/08f46a76/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
index 72e7419..8e06626 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
@@ -129,6 +129,7 @@ public abstract class JettyHttpComponent extends HttpCommonComponent implements
     protected Integer responseHeaderSize;
     protected String proxyHost;
     protected ErrorHandler errorHandler;
+    protected boolean useXForwardedForHeader;
     private Integer proxyPort;
     private boolean sendServerVersion = true;
 
@@ -993,6 +994,22 @@ public abstract class JettyHttpComponent extends HttpCommonComponent
implements
     public boolean isSendServerVersion() {
         return sendServerVersion;
     }
+    
+    /**
+     * To use the X-Fowarded-For header in HttpServletRequest.getRemoteAddr.
+     */
+    @Metadata(description = "To use the X-Fowarded-For header in HttpServletRequest.getRemoteAddr.")
+    public boolean isUseXForwardedForHeader() {
+        return useXForwardedForHeader;
+    }
+
+    /**
+     * To use a http proxy to configure the port number.
+     */
+    @Metadata(description = "To use the X-Fowarded-For header in HttpServletRequest.getRemoteAddr.")
+    public void setUseXForwardedForHeader(boolean useXForwardedForHeader) {
+        this.useXForwardedForHeader = useXForwardedForHeader;
+    }
 
     /**
      * If the option is true, jetty will send the server header with the jetty version information
to the client which sends the request.

http://git-wip-us.apache.org/repos/asf/camel/blob/08f46a76/components/camel-jetty9/src/main/java/org/apache/camel/component/jetty9/JettyHttpComponent9.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/main/java/org/apache/camel/component/jetty9/JettyHttpComponent9.java
b/components/camel-jetty9/src/main/java/org/apache/camel/component/jetty9/JettyHttpComponent9.java
index 66a49cf..0b2177f 100644
--- a/components/camel-jetty9/src/main/java/org/apache/camel/component/jetty9/JettyHttpComponent9.java
+++ b/components/camel-jetty9/src/main/java/org/apache/camel/component/jetty9/JettyHttpComponent9.java
@@ -30,6 +30,7 @@ import org.apache.camel.util.ObjectHelper;
 import org.eclipse.jetty.server.AbstractConnector;
 import org.eclipse.jetty.server.ConnectionFactory;
 import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.ForwardedRequestCustomizer;
 import org.eclipse.jetty.server.HttpConnectionFactory;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.ServerConnector;
@@ -91,7 +92,9 @@ public class JettyHttpComponent9 extends JettyHttpComponent {
             if (responseHeaderSize != null) {
                 httpConfig.setResponseHeaderSize(responseHeaderSize);
             }
-            
+            if (useXForwardedForHeader) {
+                httpConfig.addCustomizer(new ForwardedRequestCustomizer());
+            }            
             HttpConnectionFactory httpFactory = new org.eclipse.jetty.server.HttpConnectionFactory(httpConfig);

 
             ArrayList<ConnectionFactory> connectionFactories = new ArrayList<ConnectionFactory>();


Mime
View raw message