Permalink
Browse files

Specify fully qualified hostname for endpoint.

With this commit, you can specify both an endpoint identifier, or the
fully qualified domain name of the endpoint host.

Closes #25.
Closes #3.
  • Loading branch information...
1 parent f7a5430 commit 0cbbd553dce263a391858ba51cdaa1aae2c5dd98 @bigeasy bigeasy committed Jun 28, 2012
Showing with 4 additions and 5 deletions.
  1. +4 −5 lib/request.js
View
@@ -57,19 +57,18 @@ invoke = function(endpoint, key, secret, command, parameters, callback) {
name = names[_i];
query.push(querystring.escape(name) + "=" + querystring.escape(map[name]));
}
- toSign = "GET\n" + ("ec2." + endpoint + ".amazonaws.com\n") + "/\n" + query.join("&");
+ if (!~endpoint.indexOf(".")) endpoint = "ec2." + endpoint + ".amazonaws.com";
+ toSign = "GET\n" + (endpoint + "\n") + "/\n" + query.join("&");
hmac = crypto.createHmac("sha256", secret);
hmac.update(toSign);
digest = querystring.escape(hmac.digest("base64"));
query.push("Signature=" + digest);
request = http.request({
port: 443,
- host: "ec2." + endpoint + ".amazonaws.com",
+ host: endpoint,
method: "GET",
path: "/?" + query.join("&"),
- headers: {
- host: "ec2." + endpoint + ".amazonaws.com"
- }
+ headers: { host: endpoint }
}, function(response) {
var body;
body = "";

0 comments on commit 0cbbd55

Please sign in to comment.