New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Net::HTTP to timeout if the remote server doesn't read the request fast enough #1575

Open
wants to merge 1 commit into
base: trunk
from

Conversation

4 participants
@casperisfine

casperisfine commented Apr 4, 2017

Patch for https://bugs.ruby-lang.org/issues/13396

Net::HTTP currently has no way to timeout whatsoever while sending the HTTP request, if the server accept the TCP connection but never reads inside the socket, Net::HTTP can stay blocked forever.

This patch introduced a new write_timeout configuration, and change BufferedIO#write to use non-blocking IO.

As for chunked requests, since they use IO.copy_stream, I couldn't find another solution than to wrap it inside a Timeout.timeout block.

@methodmissing

LGTM

@casperisfine

This comment has been minimized.

Show comment
Hide comment
@casperisfine

casperisfine Apr 4, 2017

The build fails because of RubySpec, I've opened another PR here: ruby/spec#415

casperisfine commented Apr 4, 2017

The build fails because of RubySpec, I've opened another PR here: ruby/spec#415

@kirs

This comment has been minimized.

Show comment
Hide comment
@kirs

kirs May 17, 2017

@hsbt @sorah it would be great to know your opinion about HTTP write timeout.

kirs commented May 17, 2017

@hsbt @sorah it would be great to know your opinion about HTTP write timeout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment