$ gnpm install request-shared
Logic for normalizing arguments for an http request
npm install request-shared
var Request = require('request-shared').Request;
var req = new Request('http://www.example.com', {method: 'post'});
var Response = require('request-shared').Response;
var res = new Response(200, {}, new Buffer('A ok'));
//res.statusCode === 200
//res.headers === {}
//res.body === new Buffer('A ok')
res.getBody();
// => new Buffer('A ok')
var res = new Response(404, {'Header': 'value'}, new Buffer('Wheres this page'));
//res.statusCode === 404
//res.headers === {header: 'value'}
//res.body === new Buffer('Wheres this page')
res.getBody();
// => throws error with `statusCode`, `headers` and `body` properties.
MIT
Copyright 2013 - present © cnpmjs.org | Home |