# content

> HTTP Content-* headers parsing

Latest version **4.0.6** (published 2018-11-03) · BSD-3-Clause license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install content
pnpm add content
yarn add content
bun add content
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 4.0.6 |
| Published | 2018-11-03 |
| First published | 2014-10-02 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.8 KB |
| Known vulnerabilities | 1 |
| Install scripts | no |
| GitHub stars | 7 |
| Maintainers | hueniverse, marsup, nlf, wyatt |
| Keywords | HTTP, header, content, content-type, content-disposition |

## Links

- npm: https://www.npmjs.com/package/content
- Repository: https://github.com/hapijs/content
- Homepage: https://github.com/hapijs/content#readme
- Issues: https://github.com/hapijs/content/issues
- npm.io page: https://npm.io/package/content

## Dependencies (1)

- [boom](https://npm.io/package/boom.md) 7.x.x

## Alternatives

- [ext-list](https://npm.io/package/ext-list.md) — 6.3M weekly downloads
- [@lexical/selection](https://npm.io/package/@lexical/selection.md) — 3.8M weekly downloads
- [@lexical/text](https://npm.io/package/@lexical/text.md) — 3.6M weekly downloads
- [@lexical/clipboard](https://npm.io/package/@lexical/clipboard.md) — 3.0M weekly downloads
- [@tiptap/extension-mention](https://npm.io/package/@tiptap/extension-mention.md) — 3.0M weekly downloads

## Recent versions

- 4.0.6 (latest) — 2018-11-03
- 3.1.2 (v3-legacy) — 2024-01-06
- 3.0.7 (lts) — 2018-03-01
- 4.0.5 — 2018-03-31
- 4.0.4 — 2018-03-01
- 4.0.3 — 2017-11-03
- 4.0.2 — 2017-11-03
- 4.0.1 — 2017-09-26
- 4.0.0 — 2017-09-26
- 3.0.6 — 2017-09-12
- 3.0.5 — 2017-07-20
- 3.0.4 — 2017-05-28
- 3.0.3 — 2016-10-26
- 3.0.2 — 2016-07-28
- 3.0.1 — 2016-05-07
- … 5 more at https://npm.io/package/content/versions

## README

# content

HTTP Content-* headers parsing.

[![NPM Version](https://badge.fury.io/js/content.svg)](http://badge.fury.io/js/content)
[![Build Status](https://secure.travis-ci.org/hapijs/content.svg)](http://travis-ci.org/hapijs/content)
[![Dependencies](https://david-dm.org/hapijs/content.svg)](https://david-dm.org/hapijs/content)

Lead Maintainer - [Eran Hammer](https://github.com/hueniverse)

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
    - [`type(header)`](#typeheader)
    - [`disposition(header)`](#dispositionheader)

## Installation

Install via [NPM](https://www.npmjs.org).

```
$ npm install content
```

## Usage

**content** allows to parse HTTP `Content-*` headers, currently based on the rules established in both [RFC 7231 Section 3.1.1.1](https://tools.ietf.org/html/rfc7231#section-3.1.1.1) and [RFC 6266 Section 4.1](http://tools.ietf.org/html/rfc6266#section-4.1).

### `type(header)`

Generates an object containing the associated mime-type and the boundary (if specified).

```js
Content.type('application/json; some=property; and="another"');
// { mime: 'application/json' }

Content.type('application/json; boundary=asdf');
// { mime: 'application/json', boundary: 'asdf' }
```

If the header is invalid (malformed) or missing required data, such as a `multipart/form-data` header missing its `boundary`, it returns an HTTP `Bad Request` error.

### `disposition(header)`

Generates an object containing the details related to the `Content-Disposition` header for the `form-data` content type with support for `utf8` encoding.

```js
Content.disposition('form-data; name="file"; filename=file.jpg');
// { name: 'file', filename: 'file.jpg' }

Content.disposition('form-data; name="file"; filename*=utf-8\'en\'with%20space');
// { name: 'file', filename: 'with space' }
```

If the header is invalid (malformed, invalid or missing properties) or is empty/missing, it returns an explanatory error.

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