http-response-object
A simple object to represent an http response (with flow and typescript types)
Installation
npm install http-response-object
Usage
var Response = ;var res = 200 {} 'A ok' 'http://example.com';//res.statusCode === 200//res.headers === {}//res.body === new Buffer('A ok')//res.url === 'http://example.com'res;// => new Buffer('A ok') var res = 404 'Header': 'value' 'Wheres this page' 'http://example.com';//res.statusCode === 404//res.headers === {header: 'value'}//res.body === new Buffer('Wheres this page')//res.url === 'http://example.com'res;// => throws error with `statusCode`, `headers`, `body` and `url` properties copied from the response
Properties
statusCode
: Number - the status code of the responseheaders
: Object - the headers of the response. The keys are automatically made lower case.body
: Buffer | String - the body of the response. Should be a buffer on the server side, but may be a simple string for lighter weight clients.url
: String - the url that was requested. If there were redirects, this should be the last url to get requested.
License
MIT