From 2f102b06c3854ff421eeca05d1eef9a0d52544f3 Mon Sep 17 00:00:00 2001 From: jaketothepast Date: Sat, 26 Jan 2019 11:18:31 -0500 Subject: [PATCH] Pipe the request directly --- index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 12da6a0..2c3170a 100644 --- a/index.js +++ b/index.js @@ -26,8 +26,17 @@ function startServer() { body.push(chunk); }).on("end", () => { body = Buffer.concat(body).toString(); + + console.log(req.path); logger.info({message: "Got a message!"}); logger.info({message: req}); + let connector = http.request( + req.headers["Host"], { + headers: req.headers, + }, (resp) => { + resp.pipe(res); + }); + req.pipe(connector); }) }) @@ -40,4 +49,3 @@ function startServer() { } startServer(); -module.exports = [parseHttpRequest];