LearnBoost/socket.io — Issue #595: HEAD Request - node warning
Author: hugdubois
Created: 2011-10-25 17:15:21+00:00
State: open

if i send a head request on socket.io server that is created by port number, i have the node warning "This type of response MUST NOT have a body. Ignoring data passed to end()"

The context is :

$ npm install socket.io
$ vi app.js

```javascript
var io = require('socket.io').listen(8001);
io.configure('development', function () {
io.set('transports', ['websocket', 'xhr-polling']);
io.enable('log');
});
```

$ node app.js
info - socket.io started

$ curl http://localhost:8001
Welcome to socket.io. __==> everything is ok__

$ curl --head http://localhost:8001
__==> curl response is ok but i have in console a node warning "This type of response MUST NOT have a body. Ignoring data passed to end()"__

You can fix it with this code in __lib/socket.io.js__:

```javascript
// default response
server.on('request', function (req, res) {
res.writeHead(200);
- res.end('Welcome to socket.io.');
+ res.end((req.method === 'HEAD') ? null : 'Welcome to socket.io.');
});
```