DEV: Remove unused uri parameter (#16179)

The parameter is not used and it did not work properly anyway
because sometimes `@uri` is used instead of `uri`, which can
be different.
This commit is contained in:
Bianca Nenciu 2022-03-16 16:42:25 +02:00 committed by GitHub
parent 44c8f4940e
commit b0f414f7f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -133,18 +133,18 @@ class FinalDestination
# this is a new interface for simply getting
# N bytes accounting for all internal logic
def get(uri = @uri, redirects = @limit, extra_headers: {}, &blk)
def get(redirects = @limit, extra_headers: {}, &blk)
raise "Must specify block" unless block_given?
if uri && uri.port == 80 && FinalDestination.is_https_domain?(uri.hostname)
uri.scheme = "https"
uri = URI(uri.to_s)
if @uri && @uri.port == 80 && FinalDestination.is_https_domain?(@uri.hostname)
@uri.scheme = "https"
@uri = URI(@uri.to_s)
end
return if !validate_uri
return if @stop_at_blocked_pages && blocked_domain?(uri)
return if @stop_at_blocked_pages && blocked_domain?(@uri)
result, headers_subset = safe_get(uri, &blk)
result, headers_subset = safe_get(@uri, &blk)
cookie = headers_subset.set_cookie
location = headers_subset.location
@ -153,23 +153,23 @@ class FinalDestination
end
if result == :redirect
old_port = uri.port
location = "#{uri.scheme}://#{uri.host}#{location}" if location[0] == "/"
uri = uri(location)
old_port = @uri.port
location = "#{@uri.scheme}://#{@uri.host}#{location}" if location[0] == "/"
@uri = uri(location)
# https redirect, so just cache that whole new domain is https
if old_port == 80 && uri&.port == 443 && (URI::HTTPS === uri)
FinalDestination.cache_https_domain(uri.hostname)
if old_port == 80 && @uri&.port == 443 && (URI::HTTPS === @uri)
FinalDestination.cache_https_domain(@uri.hostname)
end
return nil if !uri
return nil if !@uri
extra = nil
extra = { 'Cookie' => cookie } if cookie
get(uri, redirects - 1, extra_headers: extra, &blk)
get(redirects - 1, extra_headers: extra, &blk)
elsif result == :ok
uri.to_s
@uri.to_s
else
nil
end