express-hijackresponse
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -1,3 +0,1 @@ | ||
var Stream = require('stream').Stream; | ||
require('http').OutgoingMessage.prototype.hijack = function (cb) { | ||
@@ -9,3 +7,3 @@ var writeHead = this.writeHead, | ||
hijacking = true, | ||
hijackedResponse = new Stream(); | ||
hijackedResponse = {}; | ||
@@ -22,16 +20,4 @@ hijackedResponse.readable = hijackedResponse.writable = true; | ||
['getHeader', 'setHeader', 'removeHeader', 'writeHead'].forEach(function (methodName) { | ||
hijackedResponse[methodName] = function () { // ... | ||
return res[methodName].apply(res, arguments); | ||
}; | ||
}); | ||
hijackedResponse.__proto__ = res; | ||
hijackedResponse.__defineGetter__('statusCode', function () { | ||
return res.statusCode; | ||
}); | ||
hijackedResponse.__defineSetter__('statusCode', function (statusCode) { | ||
res.statusCode = statusCode; | ||
}); | ||
this.writeHead = function (statusCode, headers) { | ||
@@ -67,2 +53,4 @@ if (statusCode) { | ||
this.write(chunk, encoding); | ||
} else if (!this.headerSent && this.writeHead !== writeHead) { | ||
this._implicitHeader(); | ||
} | ||
@@ -69,0 +57,0 @@ if (hijacking) { |
@@ -5,3 +5,3 @@ { | ||
"description": "Rewrite HTTP responses on their way out.", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6936
5
52