From 7fc1ca732fc702cd19854b58eec52f2458f17e10 Mon Sep 17 00:00:00 2001
From: Gunananthaa K B <cb.en.u4cse19021@cb.students.amrita.edu>
Date: Mon, 2 May 2022 14:36:50 +0530
Subject: [PATCH] basic working proxy

---
 proxy/proxy.js | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/proxy/proxy.js b/proxy/proxy.js
index 29e86b9..a6556dd 100644
--- a/proxy/proxy.js
+++ b/proxy/proxy.js
@@ -1,10 +1,26 @@
 const http = require('http');
 
-const PORT = 3000;
+const PORT = 8080;
 const requestListener = (req,res)=>{
-    res.writeHead(200);
+    const options = {
+        hostname:'localhost',
+        port:3000,
+        path:'/'
+    };
+    const get = http.get(options,response=>{
+        console.log(`statusCode: ${response.statusCode}`);
+        let buffer="";
+        response.on('data',d=>{buffer+=d});
+        response.on('error',err=>{console.log(`error:${err}`)});
+        response.on('end',()=>{
+            res.setHeader("Content-Type", "text/html");
+            res.writeHead(200);
+            res.end(buffer);
+        });
+    })
+    // res.writeHead(200);
     console.log(req.headers);
-    res.end("hello");
+    // res.end("hello");
 
 }
 const server = http.createServer(requestListener);
-- 
GitLab