title: Websocket server returned empty reply
body: <p>I ran a websocket server using socket.io:</p>
  
  <pre><code>var http = require('http'),
  fs = require('fs'),
  // NEVER use a Sync function except at start-up!
  index = fs.readFileSync(__dirname + '/index.html');
  
  // Send index.html to all requests
  var app = http.createServer(function(req, res) {
      res.writeHead(200, {'Content-Type': 'text/html'});
      res.end(index);
  });
  
  // Socket.io server listens to our app
  var io = require('socket.io').listen(app);
  
  // Send current time to all connected clients
  function sendTime() {
     io.emit('time', { time: new Date().toJSON() });
  }
  
  // Send current time every 10 secs
  setInterval(sendTime, 10000);
  
  // Emit welcome message on connection
  io.on('connection', function(socket) {
      // Use socket to communicate with this particular client only, sending it it's own id
      socket.emit('welcome', { message: 'Welcome!', id: socket.id });
  
      socket.on('i am client', console.log);
  });
  
  app.listen(3000);
  </code></pre>
  
  <p>This server works fine withe a simple socket-io client:</p>
  
  <pre><code>var socket = require('socket.io-client')('http://127.0.0.1:1337');
  socket.on('connect', function(){});
  socket.on('time', function(data){console.log(data);});
  socket.on('disconnect', function(){});
  </code></pre>
  
  <p>I tried to use cURL to send the connection request but it failed:</p>
  
  <pre><code>curl --verbose -i -N -H "Upgrade: websocket" -H "Connection: Upgrade" -H "Host: 127.0.0.1" -H "Origin: http://127.0.0.1" http://127.0.0.1:3000/
  
  * Connected to 127.0.0.1 (127.0.0.1) port 3000 (#0)
  &gt; GET /socket.io HTTP/1.1
  &gt; User-Agent: curl/7.37.1
  &gt; Accept: */*
  &gt; Upgrade: websocket
  &gt; Connection: Upgrade
  &gt; Host: 127.0.0.1
  &gt; Origin: http://127.0.0.1
  &gt; 
  * Empty reply from server
  * Connection #0 to host 127.0.0.1 left intact
  curl: (52) Empty reply from server
  </code></pre>
  
  <p>If I removed the "Upgrade: websocket", then the server will send back the html page. The "Upgrade: websocket" is supposed to tell the server to upgrade the HTTP connection to websocket connection. Why it didn't work?</p>