Skip to content

Instantly share code, notes, and snippets.

@sheldonh
Created May 23, 2013 08:23
Show Gist options
  • Select an option

  • Save sheldonh/5633485 to your computer and use it in GitHub Desktop.

Select an option

Save sheldonh/5633485 to your computer and use it in GitHub Desktop.
connect-restreamer that's sensitive to content-type
restreamer = (req, res, next) ->
req.removeAllListeners 'data'
req.removeAllListeners 'end'
next()
process.nextTick ->
if req.body?
if req.headers['content-type'] == 'application/x-www-form-urlencoded'
stringify = querystring.stringify
else
stringify = JSON.stringify
req.emit 'data', stringify req.body
req.emit 'end'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment