304 Not Modified leads to redirect ArgumentError
ellafeldmann opened this issue · comments
Hey there!
I noticed this behavior while trying to make a request to an image resource, using If-None-Match: <etag>
in the request headers. As expected, the server returns a 304 Not Modified error when the etag matches that of the existing resource.
In net_http_request
, there is a clause that checks if the response.is_a?(Net::HTTPRedirection)
, and then attempts to verify that the redirect address (response["Location"]
) is a valid address. Although the response 304 Not Modified is a redirect code, it does not return a location field.
As a result, we pass a nil url value to ensure_uri
, and end up with ArgumentError: bad argument (expected URI object or URI string)
Is this expected behavior? It seems like it may be a good idea to add a check for Net::HTTPNotModified, and then raise an error that fits into Down's exception hierarchy, (maybe Down::NotModified
?).
If this would be a welcome change, I'm happy to help out.
Thanks!
Hi there, thanks for the report. Your proposed solution sounds good to me, it would be great if you could send a pull request 👍🏻
Addressed in #54