1

Closed

IO#read seems to chop off the first character

description

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
 
http://gist.github.com/111988
Closed Dec 7, 2009 at 11:16 PM by jredville
IO#read specs pass, repro passes and tcpsocket specs don't hang.

comments

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.