接收大容量数据的POST方法在Node.js中的实现方式是什么?
请注意
这是我写的备忘录。没有解释。
代码
var http = require("http"),
url = require("url"),
request = require("request"),
qs = require("querystring"),
server = http.createServer();
server.on("request", function(a, b) {
if ("GET" === a.method) var c = url.parse(a.url, !0).query;
else if ("POST" === a.method) {
var d = "";
a.on("data", function(a) { d += a; });
a.on("end", function() { c = qs.parse(d); });
}
b.writeHead(200,{'Access-Control-Allow-Origin' : '*'}),b.end("start" + c.functionName + " url: " + c.sp_url);
request.get("https://script.google.com/a/earthship.co.jp/macros/s/AKfycbw7oix_3gO5k8yMzCNsx5dbduHrSKAVTWi1LZbe2P5NhKZOtvZs/exec?functionName=" + c.functionName + "&sp_url=" + c.sp_url);
});
server.listen(process.env.PORT, process.env.HOST);
console.log("server listening...");