waiProxy: don't strip Content-Length in response for HTTP/2#45
waiProxy: don't strip Content-Length in response for HTTP/2#45snoyberg merged 2 commits intofpco:masterfrom bjin:fix-cl
Conversation
snoyberg
left a comment
There was a problem hiding this comment.
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.