Skip to content
Browse files

Don't include default ports in last_effective_url

Currently if you get a redirect to http://test.com/ the
last_effective_url will be http://test.com:80/

Solve this by not changing the Addressable::URI instance.

This also affected encode_host so only include port in host
header if it is not nil and not any standard port.
  • Loading branch information...
1 parent 8dde31c commit 043eb0586041bdc362ba1696d254bcd0fe03d983 @wader wader committed
Showing with 5 additions and 8 deletions.
  1. +4 −7 lib/em-http/http_client_options.rb
  2. +1 −1 lib/em-http/http_encoding.rb
View
11 lib/em-http/http_client_options.rb
@@ -35,17 +35,14 @@ def set_uri(uri, path = nil)
@uri = uri
@path = uri.path
+ @host = uri.host
+ @port = uri.port
# Make sure the ports are set as Addressable::URI doesn't
# set the port if it isn't there
- if @uri.scheme == "https"
- @uri.port ||= 443
- else
- @uri.port ||= 80
+ if @port.nil?
+ @port = @uri.scheme == "https" ? 443 : 80
end
- @host = @uri.host
- @port = @uri.port
-
end
end
View
2 lib/em-http/http_encoding.rb
@@ -39,7 +39,7 @@ def munge_header_keys(head)
end
def encode_host
- if @req.uri.port == 80 || @req.uri.port == 443
+ if @req.uri.port.nil? || @req.uri.port == 80 || @req.uri.port == 443
return @req.uri.host
else
@req.uri.host + ":#{@req.uri.port}"

0 comments on commit 043eb05

Please sign in to comment.
Something went wrong with that request. Please try again.