Last active
July 22, 2016 15:43
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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