0.0.1 • Published 11 years ago

request-shared v0.0.1

Weekly downloads
4
License
-
Repository
-
Last release
11 years ago

request-shared

Logic for normalizing arguments for an http request

Build Status Dependency Status NPM version

Installation

npm install request-shared

Request

var Request = require('request-shared').Request;
var req = new Request('http://www.example.com', {method: 'post'});

Response

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.

License

MIT