Tag: httpclient

发送RESTClient Firefox POST并在node.js中尝试相同的操作

我用FireFoxrest客户端发送以下post: POST /WSPublic.asmx HTTP/1.1 Content-Type: application/soap+xml; charset=utf-8 Content-Length: 462 Host: host Connection: close <?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"><soap12:Body><ContadoresTR xmlns="https://xxxxx"><Usuario>user</Usuario><Contrasena>password</Contrasena><NInstalacion>inst</NInstalacion><VersionFicheroEsperado>1</VersionFicheroEsperado></ContadoresTR></soap12:Body></soap12:Envelope> 它的工作原理,我收到服务器的响应。 在Wireshark对话中,我看到RESTClient首先发送以下stream: ………..fe….0..S…. ..L0g….!…zP _….N.im3….8.q.'…6.9…..p>. .+./. ………..3.2.9./.5. …….c…….. ges.leako.com…… ……………..#..3t…..!…h2-14.spdy/3.1.spdy/3.http/1.1……… 然后我尝试使用node.js来做同样的事情。 HTTP客户端发送相同的post,我没有收到服务器的响应。 看着Wireshark对话,我看到第一个HTTP Clientstream的格式与firefox的RESTClient不同。 POST /WSPublic.asmx HTTP/1.1 Content-Type: application/soap+xml; charset=utf-8 Content-Length: 462 Host: host Connection: close <?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"><soap12:Body><ContadoresTR xmlns="https://xxxxxx"><Usuario>user</Usuario><Contrasena>password</Contrasena><NInstalacion>inst</NInstalacion><VersionFicheroEsperado>1</VersionFicheroEsperado></ContadoresTR></soap12:Body></soap12:Envelope> […]

NodeJS模块导出

我有一个简单的http客户端模块(api.js),它返回一个承诺,如下所示: exports.endpoint = ''; exports.GET = function(args){ args.method = 'GET'; args.uri = this.endpoint + args.uri; return asyncApiCall(args); }; exports.POST = function(args){ args.method = 'POST'; args.uri = this.endpoint + args.uri; return asyncApiCall(args); }; exports.PUT = function(args){ args.method = 'PUT'; args.uri = this.endpoint + args.uri; return asyncApiCall(args); }; exports.DELETE= function(args){ args.method = 'DELETE'; args.uri = this.endpoint + […]

request.on(“response”,)永远不会被解雇

我目前正忙于使用NodeJS并尝试使用Twitter-Search API。 curl它工作正常 – 所以我的防火墙或任何没有错。 然而,我从来没有在NodeJS中得到回应。 var sys = require("sys"), http = require("http"), events = require("events"); sys.puts("Hi there… "); var client = http.createClient(80, "search.twitter.com"), body = "", query = "foobar"; function getResults() { sys.puts("fetching for "+query); var request = client.request("GET", "/search.json?q="+query); request.on("response", function(data){ /* this somehow never gets fired 🙁 */ sys.puts("BODY:"+ data); }); } […]

我的node.js https客户端总是工作,不pipe证书的有效性

该testing程序连接到https服务器并获取一些内容。 我在浏览器中检查了我的服务器并使用了curl,证书正常工作。 如果我运行curl从服务器获取数据,它会正确地抱怨证书未知,除非我使用–cacert传入或使用-kclosures安全性。 所以我现在面临的问题是,尽pipe我认为我的客户应该做证书authentication,而且我正在告诉它公共证书在哪里,它总是有效的。 如果我删除ca:选项,所以它不知道服务器的证书是什么,那么它默默地工作。 我想赶上authentication错误,但我似乎无法这样做。 var https = require('https'); var fs = require('fs'); function main() { var data = ''; var get = https.get({ path: '/', host: 'localhost', port: 8000, agent: false, ca: [ fs.readFileSync('https_simple/cacert.pem') ] }, function(x) { x.setEncoding('utf8'); x.on('data', function(c) {data += c}); x.on('error', function(e) { throw e; }); x.on('end', function() { […]

具有模块请求的node.js中的代理authentication

我试图在我的node.js应用程序中使用模块请求 ,我需要configuration代理设置与身份validation。 我的设置是这样的: proxy:{ host:"proxy.foo.com", port:8080, user:"proxyuser", password:"123" } 当我提出请求时,如何设置我的代理configuration? 有人能给我一个例子吗? 谢谢

Http请求与节点?

如何使用与此代码等效的node.js创buildHttp请求: curl -X PUT http://localhost:3000/users/1