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 11:16 PM by jredville
IO#read specs pass, repro passes and tcpsocket specs don't hang.


sborde wrote Jul 23, 2009 at 12:51 AM

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 10: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 9:58 PM

wrote Dec 7, 2009 at 6:52 AM

wrote Dec 7, 2009 at 11:16 PM

wrote Dec 7, 2009 at 11:38 PM

wrote Feb 22, 2013 at 12:40 AM

wrote May 16, 2013 at 12:05 PM