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

Bad ETag handling in rebar_pkg_resource #1741

Closed
tothlac opened this issue Apr 9, 2018 · 3 comments
Closed

Bad ETag handling in rebar_pkg_resource #1741

tothlac opened this issue Apr 9, 2018 · 3 comments
Labels
bug enhancement new behaviour or additional functionality help wanted unlikely to be tackled by core maintainers

Comments

@tothlac
Copy link
Contributor

tothlac commented Apr 9, 2018

The following line in rebar_pkg_resource

case httpc:request(get, {Url, [{"if-none-match", ETag} || ETag =/= false]++[{"User-Agent", rebar_utils:user_agent()}]},

sends out the request to the hexpm server. Here the ETag variable contains a string, which goes through httpc.
Unfortunately the 'if-none-match' field when arriving on the other side does not contain quotes. The specification for this field says it should be quoted. References:

https://tools.ietf.org/html/rfc2616#page-132
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-None-Match

Because of this I suggest this line should look like this:

Request = {Url, [{"if-none-match", "\"" ++ ETag ++ "\""} || ETag =/= false] ++
            [{"User-Agent", rebar_utils:user_agent()}]},

The reason why we need this modification is that we have implemented a hexpm server,
which used cowboy1 where handling values without quotes in header values was possible but now
we can't do the same as we started using cowboy2 some weeks ago which complains about bad header format.

@ferd ferd added bug enhancement new behaviour or additional functionality help wanted unlikely to be tackled by core maintainers labels Apr 9, 2018
@ericmj
Copy link
Contributor

ericmj commented Apr 9, 2018

The etag should be stored along with the cached object since there is no guarantee that it is based on the md5 hash of the object.

@tothlac
Copy link
Contributor Author

tothlac commented Apr 9, 2018

Thanks. We will look into it. Right now the used method works, but you are right, if it is sent, it should be stored somewhere.

tothlac pushed a commit to tothlac/rebar3 that referenced this issue Apr 9, 2018
@tothlac
Copy link
Contributor Author

tothlac commented Apr 9, 2018

I have created this PR for the issue:
#1742

ferd added a commit that referenced this issue Apr 9, 2018
(#1741): Fix quotes in etag values
@ferd ferd closed this as completed Apr 9, 2018
uwiger pushed a commit to aeternity/rebar3 that referenced this issue Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug enhancement new behaviour or additional functionality help wanted unlikely to be tackled by core maintainers
Projects
None yet
Development

No branches or pull requests

3 participants