# get-headers

> Retrieve all HTTP(s) headers as an object with original casing

Latest version **1.0.5** (published 2017-03-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install get-headers
pnpm add get-headers
yarn add get-headers
bun add get-headers
```

## 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 | 1.0.5 |
| Published | 2017-03-18 |
| First published | 2015-08-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Blake Embrey |
| Maintainers | blakeembrey |
| Keywords | headers, raw, parse, http, object |

## Links

- npm: https://www.npmjs.com/package/get-headers
- Repository: https://github.com/blakeembrey/get-headers
- Issues: https://github.com/blakeembrey/get-headers/issues
- npm.io page: https://npm.io/package/get-headers

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2017-03-18
- 1.0.4 — 2016-06-20
- 1.0.3 — 2015-11-21
- 1.0.2 — 2015-08-17
- 1.0.1 — 2015-08-06
- 1.0.0 — 2015-08-04

## README

# Get Headers

[![NPM version][npm-image]][npm-url]
[![NPM downloads][downloads-image]][downloads-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]

> Retrieve all HTTP(s) headers as an object with original casing.

## Installation

```sh
npm install get-headers --save
```

## Usage

### Parse

Parse a headers string. Useful for `XMLHttpRequest` instances.

```js
import { parse } from 'get-headers'

parse(xhr.getAllResponseHeaders()) //=> {}
```

### HTTP

Parse headers from `http` responses. Works properly with node >= 0.12 (when the `rawHeaders` property was released) and falls back to normal headers on lower versions.

```js
import { get } from 'http'
import { http } from 'get-headers'

get('http://example.com', (res) => {
  http(res) //=> { 'Accept-Ranges': 'bytes', 'Cache-Control': 'max-age=604800', 'Content-Type': 'text/html', Date: 'Mon, 17 Aug 2015 19:53:03 GMT', Etag: '"359670651"', Expires: 'Mon, 24 Aug 2015 19:53:03 GMT', 'Last-Modified': 'Fri, 09 Aug 2013 23:54:35 GMT', Server: 'ECS (rhv/818F)', 'X-Cache': 'HIT', 'x-ec-custom-error': '1', 'Content-Length': '1270', Connection: 'close' }
})
```

### Array

Parse an array of headers (E.g. `rawHeaders`). Every odd must be the header name and evens the header value.

```js
import { array } from 'get-headers'

array(['Content-Type', 'application/json']) //=> { 'Content-Type': 'application/json' }
```

## License

MIT

[npm-image]: https://img.shields.io/npm/v/get-headers.svg?style=flat
[npm-url]: https://npmjs.org/package/get-headers
[downloads-image]: https://img.shields.io/npm/dm/get-headers.svg?style=flat
[downloads-url]: https://npmjs.org/package/get-headers
[travis-image]: https://img.shields.io/travis/blakeembrey/get-headers.svg?style=flat
[travis-url]: https://travis-ci.org/blakeembrey/get-headers
[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/get-headers.svg?style=flat
[coveralls-url]: https://coveralls.io/r/blakeembrey/get-headers?branch=master

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