geemus/excon — pull request #272 by burns (2013-09-18 06:34:23+00:00)
Title: fix encoding compatibility error (#266)

- set BINARY encoding for both a String datum[:body] and request+headers
- use File::Stat#size for ruby-1.8.7

When concatenating the request+headers with the datum[:body], if both
contain multi-byte characters and both are not encoded BINARY, this
results in an Encoding::CompatibilityError.

---

I'd rather fix this with StringIO, but I'm having some issues with the tests. See [this branch](https://github.com/burns/excon/commits/use_stringio)
There are two commits there.

The first is just to show that if you simply split the concatenated write into 2 writes,
it produces SocketErrors in several SSL tests. See [this gist](https://gist.github.com/burns/6605267)

The second would be the StringIO changes.
However under ruby-1.9.2, I get a Broken Pipe error under one of the SSL tests,
which appears to leave the test server broken. See [this gist](https://gist.github.com/burns/6605280)

I'm not sure how these changes could cause these errors.
I'm suspicious that the problem may be the test server.
Any ideas?