lib/down.rb in down-2.5.0 vs lib/down.rb in down-2.5.1
- old
+ new
@@ -71,14 +71,14 @@
downloaded_file = uri.open(open_uri_options)
rescue OpenURI::HTTPRedirect => redirect
uri = redirect.uri
retry if (tries -= 1) > 0
- raise Down::NotFound, "too many redirects: #{uri.to_s}"
+ raise Down::NotFound, "too many redirects"
rescue => error
raise if error.is_a?(Down::Error)
- raise Down::NotFound, "file not found: #{uri.to_s}"
+ raise Down::NotFound, "file not found"
end
# open-uri will return a StringIO instead of a Tempfile if the filesize is
# less than 10 KB, so if it happens we convert it back to Tempfile. We want
# to do this with a Tempfile as well, because open-uri doesn't preserve the
@@ -125,15 +125,15 @@
end
http.cert_store = store
end
request_headers = options.select { |key, value| key.is_a?(String) }
+ get = Net::HTTP::Get.new(uri.request_uri, request_headers)
+ get.basic_auth(uri.user, uri.password) if uri.user || uri.password
request = Fiber.new do
http.start do
- req = Net::HTTP::Get.new(uri.request_uri, request_headers)
- req.basic_auth(uri.user, uri.password) if uri.user || uri.password
- http.request(req) do |response|
+ http.request(get) do |response|
Fiber.yield response
response.instance_variable_set("@read", true)
end
end
end