Last active
August 29, 2015 14:00
-
-
Save Epskampie/11281368 to your computer and use it in GitHub Desktop.
nodejs uppercase headers hack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var automaticHeaders = { | |
connection: true, | |
'content-length': true, | |
'transfer-encoding': true, | |
date: true | |
}; | |
http.OutgoingMessage.prototype.setHeader = function(name, value) { | |
if (arguments.length < 2) { | |
throw new Error('`name` and `value` are required for setHeader().'); | |
} | |
if (this._header) { | |
throw new Error('Can\'t set headers after they are sent.'); | |
} | |
// NO LOWER CASE | |
var key = name//.toLowerCase(); | |
this._headers = this._headers || {}; | |
this._headerNames = this._headerNames || {}; | |
this._headers[key] = value; | |
this._headerNames[key] = name; | |
if (automaticHeaders[key]) { | |
this._removedHeader[key] = false; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
oh yea.. i suppose automaticHeaders is defined in express somewhere and I didn't transfer that over in my implementation.. whoops!