aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/middleware/ssl.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-04-09 14:20:56 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-04-09 14:20:56 -0300
commit7b75b678cf11a1aed7927a9db42fb60a38726450 (patch)
tree4635ab3771706f7a22e1ea09c4487879f0122185 /actionpack/lib/action_dispatch/middleware/ssl.rb
parent7142ff8f3dd0eda4c3cabd5d2ca5eefc0aebb22b (diff)
parent85e424de6c9dea71edeb51d966014673c9631df3 (diff)
downloadrails-7b75b678cf11a1aed7927a9db42fb60a38726450.tar.gz
rails-7b75b678cf11a1aed7927a9db42fb60a38726450.tar.bz2
rails-7b75b678cf11a1aed7927a9db42fb60a38726450.zip
Merge pull request #14665 from andrielfn/avoid-uri-parsing
Avoid URI parsing
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware/ssl.rb')
-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