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

Remove unnecessary quoting around ETag in JSON response #1519

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

manuteleco
Copy link
Contributor

The JSON marshaller will already escape the value appropriately. Quoting the value explicitly beforehand is counterproductive, as the quotes introduced in that step would be considered legitimate part of the ETag value and would be themselves escaped when marshalling.

When setting the ETag HTTP response header, however, we do have to explicitly add the quoting. This is because double quotes are not added automatically for HTTP headers and, according to the standard, the ETag header value must be wrapped in double quotes.

Fixes #1327

The JSON marshaller will already escape the value appropriately. Quoting
the value explicitly beforehand is counterproductive, as the quotes
introduced in that step would be considered legitimate part of the ETag
value and would be themselves escaped when marshalling.

When setting the `ETag` HTTP response header, however, we do have to
explicitly add the quoting. This is because double quotes are not added
automatically for HTTP headers and, according to the [standard][1], the
`ETag` header value _must_ be wrapped in double quotes.

[1]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag
Copy link
Owner

@fsouza fsouza left a comment

Choose a reason for hiding this comment

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

Thank you! \o/

@fsouza fsouza merged commit 88f49ad into fsouza:main Mar 13, 2024
27 checks passed
@manuteleco manuteleco deleted the fix_etag_rendering_in_response branch March 14, 2024 19:21
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 this pull request may close these issues.

etag value has extra backslashes when uploading object
2 participants