};
self.addListener("connect", function () {
+ if (this.https) {
+ this.setSecure(this.credentials);
+ } else {
+ parser.reinitialize('response');
+ debug('requests: ' + sys.inspect(requests));
+ currentRequest = requests.shift()
+ currentRequest.flush();
+ }
+ });
+
+ self.addListener("secure", function () {
parser.reinitialize('response');
debug('requests: ' + sys.inspect(requests));
currentRequest = requests.shift()
exports.Client = Client;
-exports.createClient = function (port, host) {
+exports.createClient = function (port, host, https, credentials) {
var c = new Client;
c.port = port;
c.host = host;
+ c.https = https;
+ c.credentials = credentials;
return c;
}
+exports.createCredentials = function (credentials) {
+ return net.createCredentials(credentials);
+}
Client.prototype.get = function () {
throw new Error("client.get(...) is now client.request('GET', ...)");
}
var url = require("url").parse(url);
-
+
var hasHost = false;
for (var i in headers) {
if (i.toLowerCase() === "host") {
var client = exports.createClient(url.port || 80, url.hostname);
var req = client.request((url.pathname || "/")+(url.search || "")+(url.hash || ""), headers);
+ if (url.protocol=="https:") {
+ client.https = true;
+ }
+
req.addListener('response', function (res) {
if (res.statusCode < 200 || res.statusCode >= 300) {
if (callback) callback(res.statusCode);