incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r1060637 - /incubator/deltacloud/trunk/server/lib/sinatra/url_for.rb
Date Wed, 19 Jan 2011 00:35:14 GMT
Author: lutter
Date: Wed Jan 19 00:35:13 2011
New Revision: 1060637

URL: http://svn.apache.org/viewvc?rev=1060637&view=rev
Log:
Fixed url generation when deltacloud is behind a proxy or load balancer.

The url_for helper wasn't properly honoring the scheme and port
forwarded from a frontend load balancer or proxy.

Modified:
    incubator/deltacloud/trunk/server/lib/sinatra/url_for.rb

Modified: incubator/deltacloud/trunk/server/lib/sinatra/url_for.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/sinatra/url_for.rb?rev=1060637&r1=1060636&r2=1060637&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/sinatra/url_for.rb (original)
+++ incubator/deltacloud/trunk/server/lib/sinatra/url_for.rb Wed Jan 19 00:35:13 2011
@@ -20,12 +20,13 @@ module Sinatra
       when :path_only
         base = request.script_name
       when :full
-        scheme = request.scheme
-        if (scheme == 'http' && request.port == 80 ||
-            scheme == 'https' && request.port == 443)
+        scheme = request.env['HTTP_X_FORWARDED_SCHEME'] || request.scheme
+        port = request.env['HTTP_X_FORWARDED_PORT'] || request.port
+        if ((scheme == 'http' && port.to_s == '80') ||
+            (scheme == 'https' && port.to_s == '443'))
           port = ""
         else
-          port = ":#{request.port}"
+          port = ":#{port}"
         end
         request_host = HOSTNAME ? HOSTNAME : request.host
         base = "#{scheme}://#{request_host}#{port}#{request.script_name}"



Mime
View raw message