Skip to content

Commit a16611e

Browse files
authored
Merge pull request #17 from jarrodyellets/master
Move Readme to API
2 parents 2809a57 + 1c047fd commit a16611e

File tree

2 files changed

+33
-34
lines changed

2 files changed

+33
-34
lines changed

API.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
## Usage
3+
4+
**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).
5+
6+
### `type(header)`
7+
8+
Generates an object containing the associated mime-type and the boundary (if specified).
9+
10+
```js
11+
Content.type('application/json; some=property; and="another"');
12+
// { mime: 'application/json' }
13+
14+
Content.type('application/json; boundary=asdf');
15+
// { mime: 'application/json', boundary: 'asdf' }
16+
```
17+
18+
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.
19+
20+
### `disposition(header)`
21+
22+
Generates an object containing the details related to the `Content-Disposition` header for the `form-data` content type with support for `utf8` encoding.
23+
24+
```js
25+
Content.disposition('form-data; name="file"; filename=file.jpg');
26+
// { name: 'file', filename: 'file.jpg' }
27+
28+
Content.disposition('form-data; name="file"; filename*=utf-8\'en\'with%20space');
29+
// { name: 'file', filename: 'with space' }
30+
```
31+
32+
If the header is invalid (malformed, invalid or missing properties) or is empty/missing, it returns an explanatory error.

README.md

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,4 @@
44

55
HTTP Content-* headers parsing.
66

7-
[![Build Status](https://secure.travis-ci.org/hapijs/content.svg)](http://travis-ci.org/hapijs/content)
8-
9-
## Usage
10-
11-
**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).
12-
13-
### `type(header)`
14-
15-
Generates an object containing the associated mime-type and the boundary (if specified).
16-
17-
```js
18-
Content.type('application/json; some=property; and="another"');
19-
// { mime: 'application/json' }
20-
21-
Content.type('application/json; boundary=asdf');
22-
// { mime: 'application/json', boundary: 'asdf' }
23-
```
24-
25-
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.
26-
27-
### `disposition(header)`
28-
29-
Generates an object containing the details related to the `Content-Disposition` header for the `form-data` content type with support for `utf8` encoding.
30-
31-
```js
32-
Content.disposition('form-data; name="file"; filename=file.jpg');
33-
// { name: 'file', filename: 'file.jpg' }
34-
35-
Content.disposition('form-data; name="file"; filename*=utf-8\'en\'with%20space');
36-
// { name: 'file', filename: 'with space' }
37-
```
38-
39-
If the header is invalid (malformed, invalid or missing properties) or is empty/missing, it returns an explanatory error.
40-
7+
[![Build Status](https://secure.travis-ci.org/hapijs/content.svg)](http://travis-ci.org/hapijs/content)

0 commit comments

Comments
 (0)