nahi/httpclient — pull request #161 by lukebakken (2013-05-05 04:49:32+00:00)
Title: Force binary encoding for recent rubies.

Issue - with ruby 2.0.0, the following test case produces an invalid downloaded file from an object store server used by the Cloud Foundry project.

Expected SHA1 checksum is `b3ab606864606c9f980045653554bf4a12cadde2`, but when downloaded with httpclient 2.3.3 and ruby 2.0.0, the checksum is `477ed8c72b65e311b49953381ff22b88f986fa07`.

The file is `pcre-8.12.tar.gz`, which can be downloaded here:

http://sourceforge.net/projects/pcre/files/pcre/8.12/

This pull request will force binary encoding on several of the buffers used in httpclient. I didn't investigate outside of `session.rb` to see if other buffers need to be changed as well. Thanks!

```
require 'httpclient'

File.open("pcre-#{RUBY_VERSION}-httpclient.blob", 'wb') do |f|
c = HTTPClient.new
c.get('http://blob.cfblob.com/rest/objects/4e4e78bca51e121204e4e86ee8e2c904fbd4f203c8e7?uid=92b8944a45f24e94b4ad254d98ab1f25/bosh-release-uid&expires=1893484800&signature=Dn1hkvGg3Tq62uu5fcKs3tRWSUg=') do |s|
f.write(s)
end
end
```