Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

raw-body

Package Overview
Dependencies
Maintainers
2
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

raw-body - npm Package Compare versions

Comparing version 2.1.7 to 2.2.0

11

HISTORY.md

@@ -0,1 +1,12 @@

2.2.0 / 2017-01-02
==================
* deps: iconv-lite@0.4.15
- Added encoding MS-31J
- Added encoding MS-932
- Added encoding MS-936
- Added encoding MS-949
- Added encoding MS-950
- Fix GBK/GB18030 handling of Euro character
2.1.7 / 2016-06-19

@@ -2,0 +13,0 @@ ==================

19

package.json
{
"name": "raw-body",
"description": "Get and validate the raw body of a readable stream.",
"version": "2.1.7",
"version": "2.2.0",
"author": "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)",

@@ -14,12 +14,13 @@ "contributors": [

"bytes": "2.4.0",
"iconv-lite": "0.4.13",
"iconv-lite": "0.4.15",
"unpipe": "1.0.0"
},
"devDependencies": {
"bluebird": "3.4.1",
"eslint": "2.13.0",
"eslint-config-standard": "5.3.1",
"eslint-plugin-promise": "1.3.2",
"eslint-plugin-standard": "1.3.2",
"istanbul": "0.4.3",
"bluebird": "3.4.7",
"eslint": "3.12.2",
"eslint-config-standard": "6.2.1",
"eslint-plugin-markdown": "1.0.0-beta.3",
"eslint-plugin-promise": "3.4.0",
"eslint-plugin-standard": "2.0.1",
"istanbul": "0.4.5",
"mocha": "2.5.3",

@@ -39,3 +40,3 @@ "readable-stream": "2.1.2",

"scripts": {
"lint": "eslint **/*.js",
"lint": "eslint --plugin markdown --ext js,md .",
"test": "mocha --trace-deprecation --reporter spec --bail --check-leaks test/",

@@ -42,0 +43,0 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --trace-deprecation --reporter dot --check-leaks test/",

@@ -15,2 +15,4 @@ # raw-body

<!-- eslint-disable no-unused-vars -->
```js

@@ -30,7 +32,10 @@ var getRawBody = require('raw-body')

- `limit` - The byte limit of the body.
This is the number of bytes or any string format supported by
[bytes](https://www.npmjs.com/package/bytes),
for example `1000`, `'500kb'` or `'3mb'`.
If the body ends up being larger than this limit,
a `413` error code is returned.
- `encoding` - The requested encoding.
By default, a `Buffer` instance will be returned.
Most likely, you want `utf8`.
- `encoding` - The encoding to use to decode the body into a string.
By default, a `Buffer` instance will be returned when no encoding is specified.
Most likely, you want `utf-8`, so setting `encoding` to `true` will decode as `utf-8`.
You can use any type of encoding supported by [iconv-lite](https://www.npmjs.org/package/iconv-lite#readme).

@@ -63,5 +68,8 @@

```js
var contentType = require('content-type')
var express = require('express')
var getRawBody = require('raw-body')
var typer = require('media-typer')
var app = express()
app.use(function (req, res, next) {

@@ -71,3 +79,3 @@ getRawBody(req, {

limit: '1mb',
encoding: typer.parse(req.headers['content-type']).parameters.charset
encoding: contentType.parse(req).parameters.charset
}, function (err, string) {

@@ -79,2 +87,4 @@ if (err) return next(err)

})
// now access req.text
```

@@ -85,9 +95,18 @@

```js
app.use(function* (next) {
var string = yield getRawBody(this.req, {
length: this.length,
var contentType = require('content-type')
var getRawBody = require('raw-body')
var koa = require('koa')
var app = koa()
app.use(function * (next) {
this.text = yield getRawBody(this.req, {
length: this.req.headers['content-length'],
limit: '1mb',
encoding: this.charset
encoding: contentType.parse(this.req).parameters.charset
})
yield next
})
// now access this.text
```

@@ -126,3 +145,3 @@

[node-version-image]: https://img.shields.io/node/v/raw-body.svg
[node-version-url]: http://nodejs.org/download/
[node-version-url]: https://nodejs.org/en/download/
[travis-image]: https://img.shields.io/travis/stream-utils/raw-body/master.svg

@@ -129,0 +148,0 @@ [travis-url]: https://travis-ci.org/stream-utils/raw-body

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc