节点js获取HTTP请求名称

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); }); 

我看到,即使我也试图做一个GET,PUT命令是开始执行的。 有什么基本我失踪? 所有我需要的是我的程序应该读取基于方法的所有标题。

应该是if (request.method === 'PUT') {

即你需要两三个等号,而不只是一个。