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

retry in streaming response causes corrupt downloads #86

Closed
jstanley0 opened this issue Dec 8, 2022 · 0 comments
Closed

retry in streaming response causes corrupt downloads #86

jstanley0 opened this issue Dec 8, 2022 · 0 comments

Comments

@jstanley0
Copy link
Contributor

If a socket error occurs while performing a streaming download via the response block provided to transport_request, a retry may cause the response block may be invoked a second time.

For code patterns like this one:

  open('some_file', 'wb') do |io|
    http.request(...) do |response|
      response.read_body do |chunk|
        io.write chunk
      end
    end
  end

The output file will be corrupted since some portion of its data near the beginning will be duplicated.

jstanley0 added a commit to jstanley0/net-http that referenced this issue Dec 8, 2022
If a socket error occurs while performing a streaming download via
the response block provided to transport_request, avoid calling
the response block again as this would result in duplicate data
received by the client.

fixes ruby#86
jeremyevans pushed a commit to jeremyevans/net-http that referenced this issue Jan 5, 2024
If a socket error occurs while performing a streaming download via
the response block provided to transport_request, avoid calling
the response block again as this would result in duplicate data
received by the client.

fixes ruby#86
matzbot pushed a commit to ruby/ruby that referenced this issue Jan 5, 2024
If a socket error occurs while performing a streaming download via
the response block provided to transport_request, avoid calling
the response block again as this would result in duplicate data
received by the client.

Fixes ruby/net-http#86
Fixes ruby/net-http#87

Fixes [Bug #11526]

ruby/net-http@114d01b092

Co-authored-by: Jeremy Stanley <jeremy@instructure.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant