summaryrefslogtreecommitdiff
path: root/lib/net/http.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/net/http.rb')
-rw-r--r--lib/net/http.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 3fcf23b05c..5e64e38665 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -698,6 +698,7 @@ module Net #:nodoc:
@continue_timeout = nil
@max_retries = 1
@debug_output = nil
+ @response_body_encoding = false
@proxy_from_env = false
@proxy_uri = nil
@@ -745,6 +746,18 @@ module Net #:nodoc:
# The local port used to establish the connection.
attr_accessor :local_port
+ # The encoding to use for the response body. If Encoding, uses the
+ # specified encoding. If other true value, tries to detect the response
+ # body encoding.
+ attr_reader :response_body_encoding
+
+ # Set the encoding to use for the response body. If given a String, find
+ # the related Encoding.
+ def response_body_encoding=(value)
+ value = Encoding.find(value) if value.is_a?(String)
+ @response_body_encoding = value
+ end
+
attr_writer :proxy_from_env
attr_writer :proxy_address
attr_writer :proxy_port
@@ -1592,6 +1605,7 @@ module Net #:nodoc:
begin
res = HTTPResponse.read_new(@socket)
res.decode_content = req.decode_content
+ res.body_encoding = @response_body_encoding
end while res.kind_of?(HTTPInformation)
res.uri = req.uri