use StringIO to process String request body

This solves an Encoding compatibility issue (#266) with concatenating
the request and body. Also solves an issue with ruby-1.8.7 when using a
large string body, as the socket writes are now chunked.
close socket to fix test under 1.9.2
Merge pull request #272 from burns/encoding_compatibility

fix encoding compatibility error (#266)