Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

make sure the https redirect defaults to 443 #15

Closed
wants to merge 1 commit into from

2 participants

Fabian Ruff Joshua Peek
Fabian Ruff

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.

Fabian Ruff 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
Joshua Peek
Owner

You should probably just specify that port as an option.

Joshua Peek josh closed this
Fabian Ruff

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

Showing 1 unique commit by 1 author.

Sep 25, 2012
Fabian Ruff 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
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 1 addition and 0 deletions. Show diff stats Hide diff stats

  1. +1 0  lib/rack/ssl.rb
1  lib/rack/ssl.rb
@@ -49,6 +49,7 @@ def scheme(env)
49 49 def redirect_to_https(env)
50 50 req = Request.new(env)
51 51 url = URI(req.url)
  52 + url.port = nil # clear out the source port, so it doesn't get used as the default
52 53 url.scheme = "https"
53 54 url.host = @host if @host
54 55 url.port = @port if @port

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.