{
  "name": "raw-body",
  "description": "Get and validate the raw body of a readable stream.",
  "version": "1.1.2",
  "author": {
    "name": "Jonathan Ong",
    "email": "me@jongleberry.com",
    "url": "http://jongleberry.com"
  },
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "https://github.com/stream-utils/raw-body.git"
  },
  "bugs": {
    "url": "https://github.com/stream-utils/raw-body/issues"
  },
  "dependencies": {
    "bytes": "~0.2.1"
  },
  "devDependencies": {
    "readable-stream": "~1.0.17",
    "co": "2",
    "gnode": "~0.0.4",
    "mocha": "~1.14.0",
    "through": "~2.3.4",
    "request": "~2.27.0",
    "assert-tap": "~0.1.4"
  },
  "scripts": {
    "test": "NODE=gnode make test && node ./test/acceptance.js"
  },
  "engines": {
    "node": ">= 0.8.0"
  },
  "readme": "# Raw Body [![Build Status](https://travis-ci.org/stream-utils/raw-body.png)](https://travis-ci.org/stream-utils/raw-body)\n\nGets the entire buffer of a stream either as a `Buffer` or a string.\nValidates the stream's length against an expected length and maximum limit.\nIdeal for parsing request bodies.\n\n## API\n\n```js\nvar getRawBody = require('raw-body')\n\napp.use(function (req, res, next) {\n  getRawBody(req, {\n    length: req.headers['content-length'],\n    limit: '1mb',\n    encoding: 'utf8'\n  }, function (err, string) {\n    if (err)\n      return next(err)\n\n    req.text = string\n    next()\n  })\n})\n```\n\nor in a Koa generator:\n\n```js\napp.use(function* (next) {\n  var string = yield getRawBody(this.req, {\n    length: this.length,\n    limit: '1mb',\n    encoding: 'utf8'\n  })\n})\n```\n\n### getRawBody(stream, [options], [callback])\n\nReturns a thunk for yielding with generators.\n\nOptions:\n\n- `length` - The length length of the stream.\n  If the contents of the stream do not add up to this length,\n  an `400` error code is returned.\n- `limit` - The byte limit of the body.\n  If the body ends up being larger than this limit,\n  a `413` error code is returned.\n- `encoding` - The requested encoding.\n  By default, a `Buffer` instance will be returned.\n  Most likely, you want `utf8`.\n  You can use any type of encoding supported by [StringDecoder](http://nodejs.org/api/string_decoder.html).\n  You can also pass `true` which sets it to the default `utf8`\n\n`callback(err, res)`:\n\n- `err` - the following attributes will be defined if applicable:\n\n    - `limit` - the limit in bytes\n    - `length` and `expected` - the expected length of the stream\n    - `received` - the received bytes\n    - `status` and `statusCode` - the corresponding status code for the error\n    - `type` - either `entity.too.large`, `request.size.invalid`, or `stream.encoding.set`\n\n- `res` - the result, either as a `String` if an encoding was set or a `Buffer` otherwise.\n\nIf an error occurs, the stream will be paused,\nand you are responsible for correctly disposing the stream.\nFor HTTP requests, no handling is required if you send a response.\nFor streams that use file descriptors, you should `stream.destroy()` or `stream.close()` to prevent leaks.\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2013 Jonathan Ong me@jongleberry.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n",
  "readmeFilename": "README.md",
  "homepage": "https://github.com/stream-utils/raw-body",
  "_id": "raw-body@1.1.2",
  "_from": "raw-body@1.1.2"
}
