<code>httpsync</code> is a port of libcurl to node.js. Its interface emulates the <code>http</code> module of node.js. But in contrast to <code>http</code> module's asynchronous functions, <code>httpsync</code> provides the equivalent synchronous APIs.
httpsync is a port of libcurl to node.js. Its interface emulates the
http module of node.js. But in contrast to
http module's asynchronous
functions, node-curl provides the equivalent synchronous APIs.
$ npm install httpsync
url(required) The url to GET/POST, such as "http://host:80/index.php", just like what you input in the browser.
HEADor any other valid request. And even
FUCKif your server supports it.
headersCustom headers to be sent.
useragentThe User Agent string
timeoutMaximum time in seconds that you allow the libcurl transfer operation to take.
connectTimeoutMaximum time in seconds that you allow the connection to the server to take.
httpsyncwill print debug informations is set to true
var httpsync = require'httpsync';var req = httpsyncrequesturl: ""method: "GET"useragent: "Ultimate Web Browser"headers:Tag: "TGB3123"String: "A long string";
It's equivalent to
curl.request but the method is default to
And you can have
var httpsync = require'httpsync';var req = httpsyncget url : "";var res = reqend;console.logres;
Or just straight forward
var httpsync = require'httpsync';var req = httpsyncget"";
Write a chunk of data to the request. The type of data can be String or Buffer.
Send the request and get response.
var req = curlrequesturl: ""method: "POST";reqwrite"Some text\n";reqwrite"another text";console.logreqend;
Send a file directly. The method will default to
var req = curlrequesturl: "";reqendFile"/etc/passwd";
The response Object is what you get after req.end (), it has following fields:
dataA Buffer that stores data sent by server.
headersComplete response headers, even contains those custom ones.
ipIP address of the server.
statusCodeStatus code that sent by server.
Thanks goes to the people who have contributed code to this module, see the GitHub Contributors page.
Below is the output from
project: node-curlcommits: 33active : 8 daysfiles : 24authors:21 赵成 63.6%12 fengmk2 36.4%
(The MIT License)
Copyright (c) 2012 fengmk2 <firstname.lastname@example.org> Copyright (c) 2012 zcbenz https://github.com/zcbenz
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.