lib/httpx/response.rb in httpx-0.1.0 vs lib/httpx/response.rb in httpx-0.2.0
- old
+ new
@@ -106,10 +106,17 @@
end
end
def to_s
rewind
- return @buffer.read.force_encoding(@encoding) if @buffer
+ if @buffer
+ content = @buffer.read
+ begin
+ return content.force_encoding(@encoding)
+ rescue ArgumentError # ex: unknown encoding name - utf
+ return content
+ end
+ end
""
ensure
close
end
alias_method :to_str, :to_s