首页 > 解决方案 > 如何从客户端javascript(而不是Nodejs)发送分块的HTTP请求?

问题描述

我找不到任何方法来启动和管理来自客户端 javascript 的分块请求(无论是浏览器还是 React Native)。

相反,Node.js 提供了 http 模块,您可以使用它write()逐步执行相同的任务和请求正文。

我的问题:是否有从客户端 javascript 发起分块 HTTP 请求?

注意:该问题与接收分块响应无关。我想发送一个分块请求

例子:

var http = new XMLHttpRequest();
var url = 'some_url';
var body = 'The whole body data';
http.open('POST', url, true);

// Whatever the content type
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

// The whole data has to be ready and sent at once.
// How to stream the body? send it in chunks?
http.send(body);

标签: javascripthttp

解决方案


我建议你通过下面的链接它可能会帮助你 https://gist.github.com/CMCDragonkai/6bfade6431e9ffb7fe88 在此处输入链接描述

希望这能清除你!


推荐阅读