How to determine content-data length from chunked encoding if HTTP header not sent

老子叫甜甜 提交于 2019-12-10 21:56:21

问题


How to determine the content-data length if the header is not sent and instead you receive Transfer-Encoding: chunked header?


回答1:


With chunked encoding there will be no Content-Length header. So after you've read the headers and the pair of CRLFs that mark the end of the headers, you're ready to read the first chunk. Each chunk payload is preceded by its own mini-header - the length in hex followed by CRLF. And there's another CRLF after the payload, before the next chunk's mini-header. A chunk can also be followed by some optional trailers. The end of the message is indicated by a zero-length chunk.

You can find the definitive details in the HTTP RFC, RFC2616.



来源:https://stackoverflow.com/questions/4929484/how-to-determine-content-data-length-from-chunked-encoding-if-http-header-not-se

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!