Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created November 26, 2008 20:05
Show Gist options
  • Save tenderlove/29543 to your computer and use it in GitHub Desktop.
Save tenderlove/29543 to your computer and use it in GitHub Desktop.
# Monkey patch for faster net/http io
class Net::BufferedIO #:nodoc:
alias :old_rbuf_fill :rbuf_fill
def rbuf_fill
begin
@rbuf << @io.read_nonblock(65536)
rescue Errno::EWOULDBLOCK
if IO.select([@io], nil, nil, @read_timeout)
@rbuf << @io.read_nonblock(65536)
else
raise Timeout::TimeoutError
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment