admin管理员组文章数量:1277885
This question shows how to read a chunked response in Javascript, but I would like to send a chunked HTTP POST from Javascript. The documentation for XMLHttpRequest doesn't mention anything. Does the answer to this question mean that it's not possible due to browser restrictions on setting the header?
This question shows how to read a chunked response in Javascript, but I would like to send a chunked HTTP POST from Javascript. The documentation for XMLHttpRequest doesn't mention anything. Does the answer to this question mean that it's not possible due to browser restrictions on setting the header?
Share Improve this question edited May 23, 2017 at 10:30 CommunityBot 11 silver badge asked Feb 25, 2016 at 17:45 skunkwerkskunkwerk 3,0703 gold badges41 silver badges64 bronze badges 1- 3 You could do this with simple polling on the client and making periodic POST(s). As long as your remote process does not serialize access then you should be fine. You could add a custom header to identify the sequence or task for server side correlations. – Ross Bush Commented Dec 16, 2017 at 3:17
3 Answers
Reset to default 2I don't think you can with XMLHttpRequest
- it's old and somewhat limited, it's really just a backwards patibility hack for a long-gone IE ActiveX ponent.
However, at the bleeding edge (not in Firefox yet) you can with fetch
and TransformStream
. This lets you send a stream from JS.
Refer to this MDN page about Transfer-Encoding. You can set the type to chunked.
You have to specify how long each chunk will be, but it allows you to send data in chunks.
I think XMLHttpRequest is very old, I think the alternative is to use Axios
which is a newer JavaScript package which helps to handle network requests. It is much more easier than fetch
and ajax
in JavaScript.
本文标签: ajaxSending Chunked HTTP request from JavascriptStack Overflow
版权声明:本文标题:ajax - Sending Chunked HTTP request from Javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741233168a2362483.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论