Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions lib/net/http/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -386,16 +386,18 @@ def read_body(dest = nil, &block)
@read = true
return if @body.nil?

case enc = @body_encoding
when Encoding, false, nil
# Encoding: force given encoding
# false/nil: do not force encoding
else
# other value: detect encoding from body
enc = detect_encoding(@body)
end
if @body.respond_to?(:force_encoding)
case enc = @body_encoding
when Encoding, false, nil
# Encoding: force given encoding
# false/nil: do not force encoding
else
# other value: detect encoding from body
enc = detect_encoding(@body)
end

@body.force_encoding(enc) if enc
@body.force_encoding(enc) if enc
end

@body
end
Expand Down Expand Up @@ -753,4 +755,3 @@ def read_all dest
end

end