Forum: Ruby-core Net::HTTP does not handle encoding correctly

9361878d459f1709feec780518946ee5?d=identicon&s=25 naruse (Yui NARUSE) (Guest)
on 2013-02-17 15:44
(Received via mailing list)
Issue #2567 has been updated by naruse (Yui NARUSE).

Target version changed from 2.0.0 to next minor

Feature #2567: Net::HTTP does not handle encoding correctly

Author: slide_rule (Ryan Sims)
Status: Assigned
Priority: Low
Assignee: naruse (Yui NARUSE)
Category: lib
Target version: next minor

 A string returned by an HTTP get does not have its encoding set
appropriately with the charset field, nor does the content_type report
the charset. Example code demonstrating incorrect behavior is below.

 #!/usr/bin/ruby -w
 # encoding: UTF-8

 require 'net/http'

 uri = URI.parse('')
 result = Net::HTTP.start(, uri.port) {|http|

 p result['content-type']     # "text/xml; charset=UTF-8" <- correct
 p result.content_type        # "text/xml" <- incorrect; truncates the
charset field
 puts result.body.encoding    # ASCII-8BIT <- incorrect encoding, should
be UTF-8
This topic is locked and can not be replied to.