lib/httpx/response/body.rb in httpx-1.3.3 vs lib/httpx/response/body.rb in httpx-1.3.4
- old
+ new
@@ -15,15 +15,26 @@
def initialize(response, options)
@response = response
@headers = response.headers
@options = options
@window_size = options.window_size
- @encoding = response.content_type.charset || Encoding::BINARY
@encodings = []
@length = 0
@buffer = nil
@reader = nil
@state = :idle
+
+ # initialize response encoding
+ @encoding = if (enc = response.content_type.charset)
+ begin
+ Encoding.find(enc)
+ rescue ArgumentError
+ Encoding::BINARY
+ end
+ else
+ Encoding::BINARY
+ end
+
initialize_inflaters
end
def initialize_dup(other)
super