diff --git a/lib/final_destination.rb b/lib/final_destination.rb index 11561f17f13..9bc5d4040ee 100644 --- a/lib/final_destination.rb +++ b/lib/final_destination.rb @@ -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