Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

make sure the https redirect defaults to 443 #15

Closed
wants to merge 1 commit into from

2 participants

@databus23

This is a small addition to pull request #7.

If the source url contains a port (e.g. http://example.com:8080) the current implementation generates a redirect to https://example.com:8080 which makes no sense.

This patch makes sure the redirect target contains no port information unless specified through the options, which means it should default to port 443.

@databus23 databus23 make sure the https redirect defaults to 443
If the redirect source url contains a port e.g. (http://example.com:8080) the current implementation generates a redirect to https://example.com:8080 which seems pretty wrong to me in the general use case
626524d
@josh
Owner

You should probably just specify that port as an option.

@josh josh closed this
@databus23

That would be an solution but the default behavior (without a port) only works when the original request contains no port information (e.g. http://example.com).
As soon as the site was originally requested on a non standard port you get redirected to the same port with protocol 'https'. That makes no sense. Why leave it that way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 25, 2012
  1. @databus23

    make sure the https redirect defaults to 443

    databus23 authored
    If the redirect source url contains a port e.g. (http://example.com:8080) the current implementation generates a redirect to https://example.com:8080 which seems pretty wrong to me in the general use case
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 0 deletions.
  1. +1 −0  lib/rack/ssl.rb
View
1  lib/rack/ssl.rb
@@ -49,6 +49,7 @@ def scheme(env)
def redirect_to_https(env)
req = Request.new(env)
url = URI(req.url)
+ url.port = nil # clear out the source port, so it doesn't get used as the default
url.scheme = "https"
url.host = @host if @host
url.port = @port if @port
Something went wrong with that request. Please try again.