Skip to content

Commit

Permalink
feat: show response headers, add delay
Browse files Browse the repository at this point in the history
  • Loading branch information
amitguptagwl committed Sep 20, 2021
1 parent 647da24 commit 69937f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ $ npm install -g log-my-request
#run in background
$ lproxy 9009 https://www.google.com
$ lproxy 9009 https://www.google.com --detail
$ lproxy 9009 https://www.google.com --detail --delay 1000
```
8 changes: 7 additions & 1 deletion quick-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const http = require('http');
const { random } = require('./util');

const logsDetail = process.argv.indexOf("--detail") !== -1
let delay = process.argv.indexOf("--delay");
if(delay){
delay = process.argv[++delay];
}
const port = Number.parseInt(process.argv[2]);
const server = http.createServer(requestListener);
const baseUrl = process.argv[3];
Expand Down Expand Up @@ -43,7 +47,9 @@ function requestListener(req, res) {
//reqOptions.headers["accept-encoding"] = "";
log("Headers used to make request", reqOptions.headers);

proxyReq(reqOptions, res, reqId);
setTimeout(() => {
proxyReq(reqOptions, res, reqId);
}, delay || 0);
});


Expand Down

0 comments on commit 69937f2

Please sign in to comment.