rest-client/rest-client — pull request #278 by dhamidi (2014-04-13 19:46:04+00:00)
Title: Set encoding of the response string, if specified by server.

The encoding of the response string is always reported as 'ASCII-8BIT',
even when the underlying byte sequence is valid UTF-8 and the server
advertises it as UTF-8 in the Content-Type header.

With this commit, the Content-Type header in the server response is
checked for a charset defintion and the response string encoding set
accordingly. If there is a mismatch between the advertised and the
actual encoding, the response encoding is left as 'ASCII-8BIT'.

The following irb session illustrates the problem:

```
irb(main):001:0> require 'restclient'
=> true
irb(main):002:0> response = RestClient.get 'http://www.goldenerunkelruebe.de'; response.code
=> 200
irb(main):003:0> response.encoding
=> #
irb(main):004:0> response.headers[:content_type]
=> "text/html; charset=UTF-8"
```