From 9ad43778b7e80cd49d2aa3e96ec2376a7fc0db2d Mon Sep 17 00:00:00 2001 From: Tymoteusz Paszun Date: Tue, 13 May 2014 09:24:08 +0200 Subject: [PATCH] fixed Host header replacement - remembers if header is already replaced and does not remove _transform method --- client.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/client.js b/client.js index c6e6164..a52287c 100644 --- a/client.js +++ b/client.js @@ -30,10 +30,14 @@ HeaderHostTransformer.prototype._transform = function (chunk, enc, cb) { // after replacing the first instance of the Host header // we just become a regular passthrough - self.push(chunk.replace(/(\r\nHost: )\S+/, function(match, $1) { - self._transform = undefined; - return $1 + self.host; - })); + if (!self.replaced) { + self.push(chunk.replace(/(\r\nHost: )\S+/, function(match, $1) { + self.replaced = true; + return $1 + self.host; + })); + } else { + self.push(chunk); + } cb(); };