diff --git a/lib/file_helper.rb b/lib/file_helper.rb index 956019c6690..d87da5a85e0 100644 --- a/lib/file_helper.rb +++ b/lib/file_helper.rb @@ -49,7 +49,8 @@ class FileHelper max_redirects: follow_redirect ? 5 : 0, skip_rate_limit: skip_rate_limit, verbose: verbose, - validate_uri: validate_uri + validate_uri: validate_uri, + timeout: read_timeout ) fd.get do |response, chunk, uri| diff --git a/lib/final_destination.rb b/lib/final_destination.rb index 0c0db2e6220..73f7ce30302 100644 --- a/lib/final_destination.rb +++ b/lib/final_destination.rb @@ -101,8 +101,7 @@ class FinalDestination status_code, response_headers = nil catch(:done) do - Net::HTTP.start(@uri.host, @uri.port, use_ssl: @uri.is_a?(URI::HTTPS)) do |http| - http.open_timeout = timeout + Net::HTTP.start(@uri.host, @uri.port, use_ssl: @uri.is_a?(URI::HTTPS), open_timeout: timeout) do |http| http.read_timeout = timeout http.request_get(@uri.request_uri, request_headers) do |resp| status_code = resp.code.to_i @@ -431,9 +430,8 @@ class FinalDestination end def safe_session(uri) - Net::HTTP.start(uri.host, uri.port, use_ssl: (uri.scheme == "https")) do |http| + Net::HTTP.start(uri.host, uri.port, use_ssl: (uri.scheme == "https"), open_timeout: timeout) do |http| http.read_timeout = timeout - http.open_timeout = timeout yield http end end