Skip to content

Commit 438e86a

Browse files
committed
Merge pull request #314 from kylekyle/issue-312
fixes #312
2 parents b6d8370 + 2951f2c commit 438e86a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/http/response/body.rb

+9-2
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,18 @@ def to_s
3535

3636
fail StateError, "body is being streamed" unless @streaming.nil?
3737

38+
# see issue 312
39+
begin
40+
encoding = Encoding.find @encoding
41+
rescue ArgumentError
42+
encoding = Encoding::BINARY
43+
end
44+
3845
begin
3946
@streaming = false
40-
@contents = "".force_encoding(@encoding)
47+
@contents = "".force_encoding(encoding)
4148
while (chunk = @client.readpartial)
42-
@contents << chunk.force_encoding(@encoding)
49+
@contents << chunk.force_encoding(encoding)
4350
end
4451
rescue
4552
@contents = nil

0 commit comments

Comments
 (0)