各位前輩好:
我看到一個例子,程式碼如下:
var http=require("http");
var server=http.createServer((req,res)=>
{
res.writeHead(200,{'Content-Type':'text/plain'});
res.end("Hello my name is Nicole!!");
});
server.on("connection",(req,res)=>
{
console.log("connection is ready!!");
});
server.on("request",(req,res)=>
{
if(req.url !== "/favicon.ico")//取消/favicon.ico
{
console.log("request");
// console.log(req.url);
res.end();
}
});.
server.listen(1600);
執行結果是:
connection is ready!!
connection is ready!!
request
想請問為什麼 server的connection事件會執行二次? 謝謝.