lib/down/net_http.rb in down-3.1.0 vs lib/down/net_http.rb in down-3.2.0
- old
+ new
@@ -178,26 +178,24 @@
response_error!(response) unless (200..299).cover?(response.code.to_i)
rescue => exception
request_error!(exception)
end
- down_params = {
- chunks: response.enum_for(:read_body),
- size: response["Content-Length"] && response["Content-Length"].to_i,
- on_close: -> { request.resume }, # close HTTP connnection
+ Down::ChunkedIO.new(
+ chunks: response.enum_for(:read_body),
+ size: response["Content-Length"] && response["Content-Length"].to_i,
+ encoding: response.type_params["charset"],
+ rewindable: options.fetch(:rewindable, true),
+ on_close: -> { request.resume }, # close HTTP connnection
data: {
- status: response.code.to_i,
- headers: response.each_header.inject({}) { |headers, (downcased_name, value)|
- name = downcased_name.split("-").map(&:capitalize).join("-")
- headers.merge!(name => value)
- },
+ status: response.code.to_i,
+ headers: response.each_header.inject({}) { |headers, (downcased_name, value)|
+ name = downcased_name.split("-").map(&:capitalize).join("-")
+ headers.merge!(name => value)
+ },
response: response,
- }
- }
- down_params[:rewindable] = options[:rewindable] if options.key?(:rewindable)
- down_params[:encoding] = response.type_params["charset"] if response.type_params["charset"]
-
- Down::ChunkedIO.new(down_params)
+ },
+ )
end
def copy_to_tempfile(basename, io)
tempfile = Tempfile.new(["down", File.extname(basename)], binmode: true)
if io.is_a?(OpenURI::Meta) && io.is_a?(Tempfile)