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

Download of a url that returns a 204 raises a TypeError; should raise CarrierWave::DownloadError #2632

Closed
BrianHawley opened this issue Sep 28, 2022 · 0 comments · Fixed by #2633

Comments

@BrianHawley
Copy link
Contributor

In lib/carrierwave/downloader/remote_file.rb you have this code:

when Net::HTTPResponse
  @file = StringIO.new(file.body)

If the response was 204 No Content, then file.body will return nil, which StringIO.new can't handle.

Given that this url download was intended to get content, and it got no content, it would make sense to explicitly raise a CarrierWave::DownloadError in this case.

BrianHawley added a commit to BrianHawley/carrierwave that referenced this issue Sep 28, 2022
Have RemoteFile raise CarrierWave::DownloadError when the HTTP response
is of a type that has no content, according to the standards.
In those cases, response.body returns nil.

There are 8 response types that have no body, 4 of which we can get, so
just check whether the body was nil.

Fixes carrierwaveuploader#2632
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant