Skip to content

Commit

Permalink
adding fixes for node v0.1.101
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashley Dev authored and danwrong committed Dec 8, 2010
1 parent 7c4aa3b commit 6a3318b
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions lib/restler.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ function Request(url, options) {

this._applyBasicAuth();

this.client = this._getClient(this.url.port, this.url.domain);

this._applySSL();
this.client = this._getClient(this.url.port, this.url.domain, (this.url.protocol == 'https'));

if (this.options.multipart) this._createMultipartRequest();
else this._createRequest();
Expand All @@ -55,15 +53,6 @@ var requestMethods = {
if (this.url.query) path += '?' + this.url.query;
return path;
},
_applySSL: function() {
if (this.url.protocol == 'https') {
try {
this.client.setSecure("X509_PEM");
} catch(e) {
sys.puts('WARNING: SSL not supported in your version of node JS');
}
}
},
_applyBasicAuth: function() {
// use URL credentials over options
if (this.url.user) this.options.username = this.url.user;
Expand All @@ -74,8 +63,8 @@ var requestMethods = {
this.headers['Authorization'] = "Basic " + auth;
}
},
_getClient: function(port, host) {
return this.options.client || http.createClient(port, host);
_getClient: function(port, host, https) {
return this.options.client || http.createClient(port, host, https);
},
_responseHandler: function(response) {
var self = this;
Expand Down

0 comments on commit 6a3318b

Please sign in to comment.