readthedocs.org icon indicating copy to clipboard operation
readthedocs.org copied to clipboard

HTTP headers don't have Content-Length or Transfer-Encoding:chunked?

Open imba-tjd opened this issue 2 years ago • 4 comments

For example run curl -I https://requests.readthedocs.io/en/latest/

I see there is no Content-Length or Transfer-Encoding:chunked in the HTTP headers. I don't know if it's by design?

Although the spec allows this, I think it's not normal.

imba-tjd avatar Jun 30 '22 11:06 imba-tjd

Hi @imba-tjd! I wasn't aware of this. I'm not sure why we are not sending Content-Length, but I'm not sure how useful it is either. Do you know some particular use case where this header would be helpful?

On the other hand, Transfer-Encoding: chunked seems to not be supported by HTTP/2, which is the protocol we are using:

Note: HTTP/2 doesn't support HTTP 1.1's chunked transfer encoding mechanism, as it provides its own, more efficient, mechanisms for data streaming.

Let me know if this clarifies the situation and if there is any actionable from our side that would be useful.


Adding the documentation reference:

  • Content-Length: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Length
  • Transfer-Encoding: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding

humitos avatar Jun 30 '22 19:06 humitos

I found this because I have a L7 proxy program that firstly checks target's Content-Length. If it's too large, it refuse to response.

imba-tjd avatar Jun 30 '22 22:06 imba-tjd

0918039995 avatar Jul 04 '22 16:07 0918039995

This appears to be something that Cloudflare is doing because it's streaming the responses: https://support.cloudflare.com/hc/en-us/articles/200168386-Why-is-my-dynamic-content-being-sent-with-chunked-encoding-

Note -- it isn't possible to have chunked encoding and content-length at the same time so this would explain why content-length would not be sent with these dynamic resource passing through Cloudflare.

We can work to enable this, but we'll have to look at what this would do to performance of larger pages.

ericholscher avatar Jul 05 '22 15:07 ericholscher

Is this something we are still considering trying out or we can just close this issue? I'm not seeing too much value on it, honestly.

humitos avatar Sep 15 '23 14:09 humitos

I think it's 🆗 to close. Others can leave comments if they have needs.

imba-tjd avatar Sep 16 '23 12:09 imba-tjd