Adding a logging method to the HttpRequest class, since this is a proxy

This commit is contained in:
Jacob Windle 2019-01-24 22:29:05 -05:00
parent 33ceceaea9
commit 7357d52eed

View File

@ -1,9 +1,19 @@
var net = require('net'); var net = require('net');
var http = require('http'); var http = require('http');
var fs = require('fs');
class HttpRequest { class HttpRequest {
constructor({attrs}) { constructor({attrs}) {
this.attrs = attrs; this.attrs = attrs;
this.logSomething = this.logSomething.bind(this);
}
// TODO - not working yet. will come back to this.
logSomething() {
fs.appendFile("proxy.log", this.attrs, (err) => {
console.log("Got an error.");
})
} }
} }
@ -50,7 +60,7 @@ var server = net.createServer((socket) => {
console.log("Client disconnected"); console.log("Client disconnected");
}); });
socket.on("data", (c) => { socket.on("data", (c) => {
parseHttpRequest(c.toString()); parseHttpRequest(c.toString()).log();
}); });
}) })