Created
November 26, 2008 20:05
-
-
Save tenderlove/29543 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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