aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/middleware
diff options
context:
space:
mode:
authorAndriel Nuernberg <andriel.nuernberg@plataformatec.com.br>2014-04-09 13:48:53 -0300
committerAndriel Nuernberg <andriel.nuernberg@plataformatec.com.br>2014-04-09 14:19:53 -0300
commit85e424de6c9dea71edeb51d966014673c9631df3 (patch)
tree3efaf7d6920585a0e5e41cdf544eb37fad04b476 /actionpack/lib/action_dispatch/middleware
parent040a1dbb11495490ca3f7c882cda1815316e7256 (diff)
downloadrails-85e424de6c9dea71edeb51d966014673c9631df3.tar.gz
rails-85e424de6c9dea71edeb51d966014673c9631df3.tar.bz2
rails-85e424de6c9dea71edeb51d966014673c9631df3.zip
Avoid URI parsing
This parsing is unecessary once the Request object already has the needed information.
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware')
-rw-r--r--actionpack/lib/action_dispatch/middleware/ssl.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/ssl.rb b/actionpack/lib/action_dispatch/middleware/ssl.rb
index 999c022535..0c7caef25d 100644
--- a/actionpack/lib/action_dispatch/middleware/ssl.rb
+++ b/actionpack/lib/action_dispatch/middleware/ssl.rb
@@ -32,11 +32,14 @@ module ActionDispatch
private
def redirect_to_https(request)
- url = URI(request.url)
- url.scheme = "https"
- url.host = @host if @host
- url.port = @port if @port
- headers = { 'Content-Type' => 'text/html', 'Location' => url.to_s }
+ host = @host || request.host
+ port = @port || request.port
+
+ location = "https://#{host}"
+ location << ":#{port}" if port != 80
+ location << request.fullpath
+
+ headers = { 'Content-Type' => 'text/html', 'Location' => location }
[301, headers, []]
end