Skip to content

Commit

Permalink
io.js sends 'Content-Length' here, Node does not
Browse files Browse the repository at this point in the history
  • Loading branch information
nylen committed May 13, 2015
1 parent 3ac4b27 commit 8bb8a48
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ var fixHeader = {
},
'content-type' : function(val) {
return val.replace(/^application\/x-www-form-urlencoded(; charset=utf-8)?$/, '<application/x-www-form-urlencoded>');
},
'content-length' : function(val, obj) {
// io.js has major version >= 1
var isNode = process.versions.node.test(/^0\./);
if (!isNode && obj.statusCode == 401) {
// io.js sends content-length here, Node.js does not
return null;
}
}
};
fixHeader['www-authenticate'] = fixHeader.authorization;
Expand All @@ -80,7 +88,7 @@ exports.fixVariableHeaders = function() {
for (var type in req) {
for (var header in req[type].headers) {
if (fixHeader[header]) {
var fixed = fixHeader[header](req[type].headers[header]);
var fixed = fixHeader[header](req[type].headers[header], req[type]);
if (fixed === null) {
delete req[type].headers[header];
} else {
Expand Down

0 comments on commit 8bb8a48

Please sign in to comment.