i have a TCP server which receives requests from clients. i want to make sure it is a http request.
this is my server:
var server = net.createServer(function (socket) {
socket.setEncoding("utf8");
console.log("Connections stated by:" + socket.address().address);
socket.write("hi tcp\r\n");
socket.on("data",function(chunk) {
console.log("received the following data: " + chunk);
var request = requestParser.parseRequest(chunk);
});
});
in requestParser i parse chunk and take the method and request with querystring but how do i know that it is an http request? i have to parse the 3rd parameter of the request to check it it’s equals to HTTP/1.1? is there a function that can do that for me?
thank u !
Why don’t you use the http module?