-
Notifications
You must be signed in to change notification settings - Fork 25
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
waiProxy: don't strip Content-Length in response for HTTP/2 #45
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have enough experience with proxying and HTTP/2-3 to approve this. @kazu-yamamoto any thoughts?
The explanation by @bjin is correct, I think. |
I would like to emphasize that this change is crucial for reverse proxying the Docker registry ( |
In that case could you add a minor version bump and changelog entry for this? |
HTTP/2 (and newer HTTP/3) don't use chunked encoding so it's fine to preserve 'Content-Length' in proxied response header. Also do the same to HEAD requests and empty-body responses, because in both cases, chunked encoding won't be used.
Pushed a new commit bumping minor package version (and Changelog change), also edited commit message to reflect HEAD request changes. |
This is a proper fix to fpco#45. In previous merge request (fpco#45), for HTTP/2 connections, Content-Length header is retained in order to avoid problems with Docker client rejecting chunked encoding responses from Docker registry. However, this approach failed when the upstream response was encoded (e.g. with 'Content-Encoding: gzip' in header). The retained 'Content-Length' header then mismatched the actual content size after decoding. To fix this, we now strip the Content-Length header if Content-Encoding header is present, along with our existing checks for cases where chunked encoding is not used (HTTP/2 and HEAD requests).
This is a proper fix to fpco#45. In previous merge request (fpco#45), for HTTP/2 connections, Content-Length header is retained in order to avoid problems with Docker client rejecting chunked encoding responses from Docker registry. However, this approach failed when the upstream response was encoded (e.g. with 'Content-Encoding: gzip' in header). The retained 'Content-Length' header then mismatched the actual content size after decoding. To fix this, we now strip the Content-Length header if Content-Encoding header is present, along with our existing checks for cases where chunked encoding is not used (HTTP/2 and HEAD requests).
HTTP/2 (and newer HTTP/3) don't use chunked encoding so it's fine to keep Content-Length header in responses.
Also include cases for HEAD requests and empty-body responses, because in both cases, chunked encoding won't be used.