Repository navigation
Conversation
| del self.headers["content-encoding"] | ||
| self.raw_content = value | ||
| self.headers["content-length"] = str(len(self.raw_content)) | ||
| if not "transfer-encoding" in self.headers: |
There was a problem hiding this comment.
I'm still not sure if this should be: if self.is_http2 or not "transfer-encoding" in self.headers: since we probably still want to set content-length if (the unused/unsupported) "transfer-encoding" header is given in a HTTP/2 request. What do you think?
There was a problem hiding this comment.
HTTP/2 does not have transfer-encoding headers (we would reject an incoming request with one), so I think it's really good enough to do the check below.
4182881 to
b290f01
Compare
|
Thanks for tackling this! Let's copy this check here so that things are consistent: A stylistic device I like to use for cases like this is to have an explicit if "chunked" in headers.get("transfer-encoding", "").lower():
pass # http://tools.ietf.org/html/rfc7230#section-3.3: do not add a content-length header to a chunked message.
else:
self.headers["content-length"] = str(len(self.raw_content)) |
|
I've pushed the second part for #4824 on top of your commit so that we have everything in one place. :) |
|
Thanks for the review!
Perfect, thanks
Good idea, done with c5036d7
I think these are separate checks: I said in the issue that this was only for 'chunked' transfer encodings, but I believe it's for any request with a |
|
Ah, yes, you are right. Thanks for checking this so thoroughly! 🍰 |
When updating the response content for a response, avoid adding the 'content-length' header if the response contains a 'transfer-encoding' header, from the spec [1]: > When a message does not have a Transfer-Encoding header field, a Content-Length header field can provide the anticipated size, as a decimal number of octets, for a potential payload body Note the 'transfer-encoding' header is not used with HTTP/2 https://httpwg.org/specs/rfc7230.html#header.content-length
c5036d7 to
4a3fefd
Compare
When updating the response content for a response, avoid adding the
'content-length' header if the response contains a 'transfer-encoding'
header, from the spec [1]:
Note the 'transfer-encoding' header is not used with HTTP/2
https://httpwg.org/specs/rfc7230.html#header.content-length
Description
Checklist