Skip to content

Instantly share code, notes, and snippets.

@dthtvwls
Last active July 22, 2016 15:43
Show Gist options
  • Save dthtvwls/efa34cad3e5f25b470e0f01413314103 to your computer and use it in GitHub Desktop.
Save dthtvwls/efa34cad3e5f25b470e0f01413314103 to your computer and use it in GitHub Desktop.
Send back the raw HTTP request (for elastic beanstalk, use node 6.2.2)
require('http')
.createServer((req, res) => {
let body = []
req
.on('data', chunk => body.push(chunk))
.on('end', () => res.end(
req.rawHeaders
.filter((el, i) => i % 2 === 0)
.reduce(
(a, key, i) => a.concat(`${key}: ${req.rawHeaders[i * 2 + 1]}`),
[`${req.method} ${req.url} HTTP/${req.httpVersion}`]
)
.concat(['', Buffer.concat(body).toString()])
.join('\r\n')
))
})
.listen(8081)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment