1 | #subtext
|
2 |
|
3 | HTTP payload parser.
|
4 |
|
5 | [![Build Status](https://secure.travis-ci.org/hapijs/subtext.svg?branch=master)](http://travis-ci.org/hapijs/subtext)
|
6 |
|
7 | Lead Maintainer: [John Brett](https://github.com/johnbrett)
|
8 |
|
9 | **subtext** is sponsored by [Sponsorama](http://www.sponsorama.io).
|
10 |
|
11 | subtext parses the request body and exposes it in a callback.
|
12 |
|
13 | ## Example
|
14 |
|
15 | ```javascript
|
16 | const Http = require('http');
|
17 | const Subtext = require('subtext');
|
18 |
|
19 | Http.createServer((request, response) => {
|
20 |
|
21 | Subtext.parse(request, null, { parse: true, output: 'data' }, (err, parsed) => {
|
22 |
|
23 | response.writeHead(200, { 'Content-Type': 'text/plain' });
|
24 | response.end('Payload contains: ' + parsed.payload.toString());
|
25 | });
|
26 |
|
27 | }).listen(1337, '127.0.0.1');
|
28 |
|
29 | console.log('Server running at http://127.0.0.1:1337/');
|
30 |
|
31 | ```
|
32 |
|
33 | ## API
|
34 |
|
35 | See the [API Reference](API.md)
|
36 |
|
37 |
|
38 | ### Warning for subtext on Node below v4.3.2
|
39 |
|
40 | A Node bug in versions below Node v4.3.2 meant that the `Buffer.byteLength` function did not work correctly, and as such, using `maxBytes` options with multipart payloads will mistake the file buffer size to be incorrectly as bigger than it is. Your options here are either to upgrade to Node version greater than v4.3.2 or increase maxBytes to allow some error in calculation. [Background info in this issue here](https://github.com/hapijs/subtext/pull/32).
|