# http-response-object

> A simple object to represent an http response

Latest version **3.0.2** (published 2019-03-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install http-response-object
pnpm add http-response-object
yarn add http-response-object
bun add http-response-object
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2019-03-20 |
| First published | 2014-08-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | ForbesLindesay |
| Maintainers | forbeslindesay |
| Keywords | http, https, response, request |

## Links

- npm: https://www.npmjs.com/package/http-response-object
- Repository: https://github.com/ForbesLindesay/http-response-object
- Homepage: https://github.com/ForbesLindesay/http-response-object#readme
- Issues: https://github.com/ForbesLindesay/http-response-object/issues
- npm.io page: https://npm.io/package/http-response-object

## Dependencies (1)

- [@types/node](https://npm.io/package/@types/node.md) ^10.0.3

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 3.0.2 (latest) — 2019-03-20
- 3.0.1 — 2018-01-31
- 3.0.0 — 2018-01-31
- 2.0.3 — 2017-06-16
- 2.0.2 — 2017-06-16
- 2.0.1 — 2017-06-14
- 2.0.0 — 2017-06-14
- 1.1.0 — 2015-10-15
- 1.0.1 — 2014-08-01
- 1.0.0 — 2014-08-01

## README

# http-response-object

A simple object to represent an http response (with flow and typescript types)

[![Build Status](https://img.shields.io/travis/ForbesLindesay/http-response-object/master.svg)](https://travis-ci.org/ForbesLindesay/http-response-object)
[![Dependency Status](https://img.shields.io/david/ForbesLindesay/http-response-object.svg)](https://david-dm.org/ForbesLindesay/http-response-object)
[![NPM version](https://img.shields.io/npm/v/http-response-object.svg)](https://www.npmjs.org/package/http-response-object)


## Installation

    npm install http-response-object

## Usage

```js
var Response = require('http-response-object');
var res = new Response(200, {}, new Buffer('A ok'), 'http://example.com');
//res.statusCode === 200
//res.headers === {}
//res.body === new Buffer('A ok')
//res.url === 'http://example.com'
res.getBody();
// => new Buffer('A ok')

var res = new Response(404, {'Header': 'value'}, new Buffer('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.getBody();
// => throws error with `statusCode`, `headers`, `body` and `url` properties copied from the response
```

## Properties

 - `statusCode`: Number - the status code of the response
 - `headers`: 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

---
_Source: https://npm.io/package/http-response-object · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
