nahi/httpclient

Encoding of the response body and Ruby1.9

Closed this issue · 2 comments

ibc commented

Hi, in Ruby1.9 when httpclient gets a response wth body, that body is encoded as US-ASCII even if the HTTP response contains:

Content-Type: lalala/lololo;charset=UTF-8

This forces me to convert the got body to UTF-8 by running:
body.force-encoding(:'UTF-8')

It would be great if httpclient would, by itself, encode the retrieved body in the appropiate endoding, which could be (ir orden or preference):

  1. The value of "charset" param ni Content-Type header.
  2. A default encoding set by the user when configuring the httpclient instance (or as a new parametner in 'request' method).
ncr commented

Just got bitten by this.

same here.