Skip to content

Commit 7b33709

Browse files
committed
Add a third argument to http.cat to specify req headers.
1 parent 45f5402 commit 7b33709

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/http.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -548,14 +548,19 @@ node.http.Client.prototype.put = function (uri, headers) {
548548
};
549549

550550

551-
exports.cat = function (url, encoding) {
551+
exports.cat = function (url, encoding, headers) {
552552
var promise = new node.Promise();
553553

554554
encoding = encoding || "utf8";
555555

556556
var uri = exports.parseUri(url);
557+
headers = headers || {};
558+
if (!headers["Host"] && uri.host) {
559+
headers["Host"] = uri.host;
560+
}
561+
557562
var client = exports.createClient(uri.port || 80, uri.host);
558-
var req = client.get(uri.path || "/", uri.host ? {"Host" : uri.host} : {});
563+
var req = client.get(uri.path || "/", headers);
559564

560565
client.addListener("error", function () {
561566
promise.emitError();

0 commit comments

Comments
 (0)