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

raw-body

Package Overview
Dependencies
Maintainers
1
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 1.0.0 to 1.0.1

38

index.js

@@ -11,2 +11,15 @@ var bytes = require('bytes')

if (!stream._readableState) {
// dump the stream, though it's probably unnecessary
if (typeof stream.resume === 'function')
stream.resume()
process.nextTick(function () {
var err = new Error('only readable streams are supported')
err.status = 500
done(err)
})
return defer
}
var limit = null

@@ -23,8 +36,8 @@ if (typeof options.limit === 'number')

if (limit !== null && length !== null && length > limit) {
var err = new Error('request entity too large')
err.status = 413
err.length = length
err.limit = limit
stream.resume() // dump stream
process.nextTick(function () {
var err = new Error('request entity too large')
err.status = 413
err.length = length
err.limit = limit
done(err)

@@ -67,7 +80,14 @@ })

} else if (length !== null && received !== length) {
var err = new Error('request size did not match content length')
err.status = 400
err.received = received
err.length = length
done(err)
var state = stream._readableState
if (!state || state.encoding === null) {
err = new Error('request size did not match content length')
err.status = 400
err.received = received
err.length = length
done(err)
} else {
err = new Error('raw-body expects a buffer stream, but a string chunk was received. please do not set an encoding')
err.status = 500
done(err)
}
} else {

@@ -74,0 +94,0 @@ done(null, Buffer.concat(buffers))

{
"name": "raw-body",
"description": "Get and validate the raw body of a readable stream.",
"version": "1.0.0",
"version": "1.0.1",
"author": {

@@ -6,0 +6,0 @@ "name": "Jonathan Ong",

@@ -6,4 +6,2 @@ # Raw Body [![Build Status](https://travis-ci.org/stream-utils/raw-body.png)](https://travis-ci.org/stream-utils/raw-body)

This is the callback version of [cat-stream](https://github.com/jonathanong/cat-stream), which is much more convoluted because streams suck.
## API

@@ -28,3 +26,3 @@

or in Koa generator:
or in a Koa generator:

@@ -31,0 +29,0 @@ ```js

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