[英]I have created a MySQL Database in Node.js. how to see if its created?
[英]Started Playing with node.js. I have a question
我只是使用以下代碼通過文檔創建了一個HTTP服務器:
var sys = require("sys"),
http = require("http");
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World!");
sys.puts('Connection');
}).listen(8080);
sys.puts("Server running at http://localhost:8080/");**
我的問題是,為什么當我進入localhost:8080時,會兩次打印“連接”? 這是一個錯誤嗎?
您的瀏覽器可能兩次請求URL,一次是HEAD請求,一次是GET請求。 嘗試使用簡單的界面,例如telnet
:
$ telnet localhost 8080
GET / HTTP/1.0
^]q
在GET
之后留空行,然后按Ctrl +] q Enter退出。
兩個請求被發送到服務器。 第一個請求是由瀏覽器自動發出的,它會請求favicon.ico,當然,第二個請求是針對URL(localhost:8080)的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.