3
var http = require("http");

function onRequest(request, response) {
  console.log("Request received.");
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.write("Hello World");
  response.end();
}

http.createServer(onRequest).listen(8888);

console.log("Server has started.");

this writes to console on a request from my chrome browser:

Request received Request received

Two times? Why?

Piddien
  • 1,436
  • 4
  • 18
  • 38
  • 7
    it is because of the favicon request. I am sorry for not reading the text fully :( it is a saturday and I had wine and beer for dinner :/ – Piddien Mar 10 '12 at 21:25
  • 1
    log(request) instead of logging the unhelpful string "Request received" and you can see for yourself that Per was correct. It's always better to log relevant stateful data, not generic debugging strings :) – Rylab Mar 11 '12 at 21:25
  • Please write an answer for your question and accept it! – Daniel Mendel Mar 13 '12 at 18:53
  • This is a known bug in Chrome, see this question: http://stackoverflow.com/q/7904867/133 and this answer: http://stackoverflow.com/a/4941800/133 – Luke Girvin Mar 15 '12 at 22:40

1 Answers1

7

It was your browser asking for favicon.ico

dwerner
  • 6,462
  • 4
  • 30
  • 44