http.createServer(function (request, response) {
request.on("end", function () {
if(request.method='PUT')
{
buf1='This is PUT';
console.log('received PUT');
}
response.writeHead(200, {
'Content-Type': 'text/plain'
});
response.end('Hello HTTP!'+buf1);
});
I see that even I just try to do a GET also, the PUT command is gettingexecuted. is there anything basic I am missing? all I need is my program should read all headers based on method.
Should be if (request.method === 'PUT') {
I.e. you need two or three equals signs, not just one.