Giter Site home page Giter Site logo

marcelaraujo / node-curl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jiangmiao/node-curl

0.0 2.0 0.0 139 KB

node curl wrapper with fully implemented

Home Page: https://npmjs.org/package/node-curl

License: MIT License

C++ 75.56% Shell 6.34% Python 2.69% JavaScript 15.40%

node-curl's Introduction

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) {
        console.info(this.status);
        console.info('-----');
        console.info(this.body);
        console.info('-----');
        console.info(this.info('SIZE_DOWNLOAD'));
      });
    
  • with options

      curl = require('node-curl')
      curl('www.google.com', {VERBOSE: 1, RAW: 1}, function(err) {
        console.info(this);
      });
    
  • run the example/test.js

      node examples/test.js
    

Usage

  • curl

      curl(url, [options = {}], callback)
      callback includes 1 parameters (error)
      result is stored in curl
    
  • Retrieve Data from curl

      members:
        status           - Http Response code
        body             - Http body
    
        url              - the url set by curl(...)
        options          - the options set by curl(...)
        defaultOptions   - the defaultOptions
        effectiveOptions - the options curl used
    
      methods:
        info(name) - Get information of result, see 'info' section
    
  • Curl Control

      members
          debug (default: false)
              - logging node-curl debug info
    
      methods:
          void reset()
              - reset curl and set options to default options
    
          void setDefaultOptions(options, reset = true)
              - set default options
    
          curl create(defaultOptions)
              - create a new curl with default options
    

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
      DEBUG - Replace curl.debug
    
  • 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
    

node-curl's People

Contributors

jiangmiao avatar marcelaraujo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.