curler
A native c++ node.js module for asynchronous http requests via libcurl.
Install
$ npm install curler
request(options, callback[err, res, bodyData])
Options
url
: request url. (required)method
: HTTP method type. Defaults toGET
. (can be anything)headers
: Optional JSON key/value array of the request headers.userAgent
: Optional custom user agent.proxy
: Optional proxy support. (i.e. http://proxy.example.com:80)data
: Optional request body data.timeout
: Total request timeout (connection/response) in milliseconds.connectionTimeout
: Connection timeout in milliseconds.
Examples
GET request
var curler = Curler;var curl = ;var options =method: "GET"url: 'http://www.google.com';var startDate = Date;curl;
POST request (body data)
var curler = Curler;var curl = ;var data = JSON;var options =method: "POST"url: 'http://www.example.com/'userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3'headers:'Content-Type': 'application/json''Connection': 'Keep-Alive'data: datatimeout: 5000connectionTimeout: 5000;var startDate = Date;curl;
TODO
- Allow Expect: 100-Continue to be configurable, rather than always off
- Load a queue of curl handles when the module loads (ghetto connection pooling). Need a deconstructor in curler.cc that works first!