IO#read seems to chop off the first character


WEBrick uses IO#read to process POST requests, but it hangs because IO#read chops off the first character, making WEBrick wait for that character, and never getting it. A work-around is to use recv instead:
class TCPSocket; def read size; recv size; end; end
Closed Dec 7, 2009 at 10:16 PM by jredville
IO#read specs pass, repro passes and tcpsocket specs don't hang.


sborde wrote Jul 22, 2009 at 11:51 PM

This is a simple repro. It runs to completion with MRI, but hangs with IronRuby.

require 'net/http'
require 'uri'
postit = Net::HTTP.post_form(URI.parse('http://zip4.usps.com/zip4/zcl_3_results.jsp'), {'zip5'=>'37998'})
puts postit.body[0..5]

sborde wrote Jul 23, 2009 at 9:24 PM

HTTP.post_form has been fixed. Not sure if the WebBrick issue was exactly the same or not.

wrote Oct 5, 2009 at 8:58 PM

wrote Dec 7, 2009 at 5:52 AM

wrote Dec 7, 2009 at 10:16 PM

wrote Dec 7, 2009 at 10:38 PM

wrote Feb 21, 2013 at 11:40 PM

wrote May 16, 2013 at 11:05 AM