From 7b337096c9d373617d8989c7afd67a4f4573ca9b Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 30 Sep 2009 11:54:14 +0200 Subject: [PATCH] Add a third argument to http.cat to specify req headers. --- lib/http.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/http.js b/lib/http.js index 097e8cefab..b30ebd6987 100644 --- a/lib/http.js +++ b/lib/http.js @@ -548,14 +548,19 @@ node.http.Client.prototype.put = function (uri, headers) { }; -exports.cat = function (url, encoding) { +exports.cat = function (url, encoding, headers) { var promise = new node.Promise(); encoding = encoding || "utf8"; var uri = exports.parseUri(url); + headers = headers || {}; + if (!headers["Host"] && uri.host) { + headers["Host"] = uri.host; + } + var client = exports.createClient(uri.port || 80, uri.host); - var req = client.get(uri.path || "/", uri.host ? {"Host" : uri.host} : {}); + var req = client.get(uri.path || "/", headers); client.addListener("error", function () { promise.emitError();