Skip to content
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

Enforce write timeout when body_stream is used #27

Conversation

miguelfteixeira
Copy link

The existing implementation of Net::HTTP#write_timeout relies on
Net::BefferedIO to trigger the Net::WriteTimeout error. This commit
changes send_request_with_body_stream to remove the optimization that
was making Net::HTTP#write_timeout not work when body_stream is
used.

This issue affects multipart requests from third-party libraries that wrap
Net::HTTP like Faraday.

Open issue:
https://bugs.ruby-lang.org/issues/17933

@miguelfteixeira miguelfteixeira changed the title Use write timeout when body_stream is used Enforce write timeout when body_stream is used Jun 12, 2021
The existing implementation of `Net::HTTP#write_timeout` relies on
`Net::BefferedIO` to trigger the `Net::WriteTimeout` error. This commit
changes `send_request_with_body_stream` to remove the optimization that
was making `Net::HTTP#write_timeout` not work when `body_stream` is
used.

Open issue:
https://bugs.ruby-lang.org/issues/17933
@miguelfteixeira miguelfteixeira force-pushed the fix-net-http-write-timeout-body-stream branch from 10e416f to 9d90f85 Compare June 12, 2021 09:39
Copy link
Contributor

@jeremyevans jeremyevans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, and I think it is worth dropping the optimization in order to fix the bug. However, this is ultimately up to @nurse . I think even if we don't disable the optimization by default, we should at least offer the option to disable it.

@nurse
Copy link
Member

nurse commented Jun 30, 2021

Well, I worried that this disables the optimization of IO.copy_stream, but byroot's comment "this optimization is already disabled for SSL sockets" convinced me. Go ahead!

@jeremyevans jeremyevans merged commit a0fab1a into ruby:master Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants