expressjs/serve-favicon — pull request #18 by aichholzer (2014-11-20 05:59:16+00:00)
Title: Set only actual headers

If we create a simple application, for example:

```js
var express = require('express'),
app = express(),
compress = require('compression'),
bodyParser = require('body-parser'),
favicon = require('serve-favicon');

app.use(compress());
app.use(bodyParser.json());
app.use(favicon(__dirname + '/public/img/favicon.png'));

Object.prototype.example = function myExample () {
console.log('I do not really have a plan.');
};

app.listen(8000);
```

Application runs and everything is fine, so far. Now, if we try: `http://localhost:8000/favicon.ico` - Node throws an exception:

```js
http.js:657
value = value.replace(/[\r\n]+[ \t]*/g, '');
^
TypeError: Object function myExample() {
console.log('I do not really have a plan.');
} has no method 'replace'
```

Basically the `Object.prototype` has attached itself to the headers and the loop passes the whole function as a header.
The solution is the simple `.hasOwnProperty()` fix.