Does Fetch's Response.body chunks correspond to HTTP chunks?

橙三吉。 提交于 2020-01-05 04:38:29

问题


I'm doing a Fetch-api request where the server replies using the HTTP chunked transfer encoding (with text data). I'm consuming the data using the Response.body as a stream.

I'm wondering: Is it safe to assume that the chunks generated by the stream correspond to the HTTP chunks? I've seen some questions[1-3] where this assumption seems to be made, but I cannot find anything about this in the spec.

[1] JS Fetch use Chunked Transfer Encoding (translating curl to Fetch)
[2] Consuming chunked data asyncrhonously in javascript
[3] Read chunked binary response with Fetch API


回答1:


Per comments from the author of the Fetch spec: “no such guarantee… e.g., if there’s a delay after half of an HTTP chunk I’d expect two or so”.



来源:https://stackoverflow.com/questions/57412098/does-fetchs-response-body-chunks-correspond-to-http-chunks

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