Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
node curl wrapper with fully implemented
branch: master

This branch is 71 commits behind jiangmiao:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
lib
src
.gitignore
.npmignore
.travis.yml
LICENSE-MIT
README.md
index.js
index.toffee
package.json
wscript

README.md

node-curl Build Status

node cURL wrapper, support all options and infos.

Quick Start

  • quick start

    curl = require('node-curl');
    curl('www.google.com', function(err, res) {
      console.info(res.status);
      console.info('-----');
      console.info(res.body);
      console.info('-----');
      console.info(res.info('SIZE_DOWNLOAD'));
      res.close();
    });
    
  • with options

    curl = require('node-curl')
    curl('www.google.com', {VERBOSE: 1, RAW: 1}, function(err, res) {
      console.info(res);
      res.close();
    });
    

Usage

  • curl

    curl(url, [options = {}], callback)
    callback includes 2 parameters (error, result)
    
  • result in callback

    members:
      status     - Http Response code
      body       - Http body
    
    methods:
      info(name) - Get information of result, see 'info' section
    

Options

  • Any Curl Easy Options

    eg: CURLOPT_VERBOSE will be VERBOSE, CURLOPT_HEADER will be HEADER
    
    Full list at http://curl.haxx.se/libcurl/c/curl_easy_setopt.html 
    
  • node-curl Extra Options

    RAW - Returns Buffer instead of String in result.body
    
  • About slist parameters

    node-curl support slist which map to Javascript Array
    
    eg: 
        HTTP_HEADER: ['FOO', 'BAR']
        HTTP_HEADER: 'FOO'
    
        any non-array parameter will convert to [ parameter.toString() ]
    

Infos

  • Any Curl Info options

    eg: CURLINFO_EFFECTIVE_URL will be EFFETCTIVE_URL
    
    full list at http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html
    
  • About slist

      slist will be returns in Array
      eg: CURLINFO_COOKIELIST
    

Hints

close the result to release resource of curl immediately.

or the resource will not release until gc performed.

Something went wrong with that request. Please try again.