archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r694565 - /archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java
Date Fri, 12 Sep 2008 00:34:58 GMT
Author: brett
Date: Thu Sep 11 17:34:57 2008
New Revision: 694565

URL: http://svn.apache.org/viewvc?rev=694565&view=rev
Log:
[MRM-834] use Apache 2.0 mod_proxy header if available for those that don't want to use ProxyPreserveHost
Merged from: r694564 on trunk

Modified:
    archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java

Modified: archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java?rev=694565&r1=694564&r2=694565&view=diff
==============================================================================
--- archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java
(original)
+++ archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ContextUtils.java
Thu Sep 11 17:34:57 2008
@@ -80,15 +80,7 @@
         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 @@
 
         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;
+    }
 }



Mime
View raw message