0.5.0 • Published 10 years ago

shttp-client v0.5.0

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

shttp-client

Simple Http Client

Installation

npm install shttp-client

Quick Example

const shttpClient = require('shttp-client');

shttpClient.request({
    host: 'www.naver.com',
    method: 'get',
    path: '/',
    encoding: 'utf8',
}, (err, res, code, message, headers, body) => {

    if (err) {
        throw err;
    }

    console.log(`code: ${code}`);
    console.log(`message: ${message}`);
    console.log(`headers: ${headers}`);
    console.log(`body: ${body}`);
});

Body Example

const body = {

    // object
    object: {
        key1: 'value1',
        value2: 'value2'
    },

    // array
    array: [
        object: {
            key1: 'value1',
            value2: 'value2'
        }
    ],

    file: 'file:////home/test.jpg', // alias: 'file:///'
    image: 'url:///http://test.com/test.jpg' // alias: 'url///'
}

Options

  • protocol - http: http:, https: https:, (default: http:)
  • host - domain name or ip (ex: www.naver.com)
  • port - port (default: 80)
  • method - http request method (default: get)
  • path - http request uri (default: /)
  • headers - http request headers
  • query - http request querystring object (ex: { a: 'b'. c: 'd' })
  • body - http body object (ex: { a: 'b'. c: 'd', file: 'file:///path', image: 'url:///url' })
  • encoding - http encoding (default: utf8)
  • timeout - http request timeout (default: 120000)
0.5.0

10 years ago

0.4.1

10 years ago

0.4.0

10 years ago

0.3.3

10 years ago

0.3.2

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago