这个问题很简单。我想使用 Node.js 服务器作为代理来记录、验证 HTTP 查询并将其转发到后端 HTTP 服务器(PUT、GET 和 DELETE 请求)。
为此我应该使用什么库?恐怕我找不到。
最佳答案
NodeJS 支持 http.request 作为标准模块: http://nodejs.org/docs/v0.4.11/api/http.html#http.request
var http = require('http');
var options = {
host: 'example.com',
port: 80,
path: '/foo.html'
};
http.get(options, function(resp){
resp.on('data', function(chunk){
//do something with chunk
});
}).on("error", function(e){
console.log("Got error: " + e.message);
});
关于http - 如何使用 Node.js 发出外部 HTTP 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7967037/