aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2008-09-12 00:30:47 +0000
committerBrett Porter <brett@apache.org>2008-09-12 00:30:47 +0000
commite7adc83cf0ca025c7cfc399dee7da93c04983656 (patch)
tree11c34cfd8993ba81f58d3b84d2b1c7ee94ab3530
parent0be59c6a852fecb32b3de7be3bb2a6afcc2cb30a (diff)
downloadarchiva-e7adc83cf0ca025c7cfc399dee7da93c04983656.tar.gz
archiva-e7adc83cf0ca025c7cfc399dee7da93c04983656.zip
[MRM-834] use Apache 2.0 mod_proxy header if available for those that don't want to use ProxyPreserveHost
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@694564 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java29
1 files changed, 20 insertions, 9 deletions
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java
index 55c2e54ac..3cdb25caf 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java
@@ -80,15 +80,7 @@ public class ContextUtils
StringBuffer baseUrl = new StringBuffer();
baseUrl.append( request.getScheme() ).append( "://" );
- baseUrl.append( request.getServerName() );
- int portnum = request.getServerPort();
-
- // Only add port if non-standard.
- Integer defaultPortnum = (Integer) defaultSchemePortMap.get( request.getScheme() );
- if ( ( defaultPortnum == null ) || ( defaultPortnum.intValue() != portnum ) )
- {
- baseUrl.append( ":" ).append( String.valueOf( portnum ) );
- }
+ baseUrl.append( getServerName( request ) );
baseUrl.append( request.getContextPath() );
if ( StringUtils.isNotBlank( resource ) )
@@ -103,4 +95,23 @@ public class ContextUtils
return baseUrl.toString();
}
+
+ private static String getServerName( HttpServletRequest request )
+ {
+ String name = request.getHeader( "X-Forwarded-Host" );
+ if ( name == null )
+ {
+ name = request.getServerName();
+ int portnum = request.getServerPort();
+
+ // Only add port if non-standard.
+ Integer defaultPortnum = (Integer) defaultSchemePortMap.get( request.getScheme() );
+ if ( ( defaultPortnum == null ) || ( defaultPortnum.intValue() != portnum ) )
+ {
+ name = name + ":" + String.valueOf( portnum );
+ }
+ return name;
+ }
+ return name;
+ }
}