Skip to content

Commit

Permalink
Add a third argument to http.cat to specify req headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Sep 30, 2009
1 parent 45f5402 commit 7b33709
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 7b33709

Please sign in to comment.