New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

connect-hopeful-body-parser

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connect-hopeful-body-parser

Attempt to parse body data without an Accept header

  • 0.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-73.33%
Maintainers
1
Weekly downloads
 
Created
Source

build status

connect-hopeful-body-parser

For when you don't really want to be that strict, will attempt to parse

  • The request body as JSON
  • The request body as x-www-form-urlencoded
  • The urlencoded query string

Install

npm install connect-hopeful-body-parser

Usage

Add to the connect middleware chain, req.body will be set to either the parsed object, or null.

// server.js
var connect = require('connect');
var bodyParser = require('connect-hopeful-body-parser');
var server = connect(
    bodyParser(),
    function(req, res) {
        res.end(require('util').inspect(req.body));
    }
);
server.listen(9999);

# Once the server is running...
$ curl localhost:9999 -d '{"value" : {"a" : 1}}'
{ value: { a: 1 } }

$ curl localhost:9999 -d 'value[a]=1'
{ value: { a: 1 } }

$ curl "localhost:9999?value\[a\]=1"
{ value: { a: 1 } }

$ curl "localhost:9999"
null

License

MIT Licensed, copyright Glen Mailer 2011

FAQs

Package last updated on 03 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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