Adding a logging method to the HttpRequest class, since this is a proxy
This commit is contained in:
parent
33ceceaea9
commit
7357d52eed
12
index.js
12
index.js
@ -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();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user