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.