|
|
@ -457,18 +457,35 @@ exports.createClient = function (port, host) { |
|
|
|
var requests = []; |
|
|
|
var currentRequest; |
|
|
|
|
|
|
|
client.tcpSetSecure = client.setSecure; |
|
|
|
client.setSecure = function(format_type, ca_certs, crl_list, private_key, certificate) { |
|
|
|
secure_credentials.secure = true; |
|
|
|
secure_credentials.format_type = format_type; |
|
|
|
secure_credentials.ca_certs = ca_certs; |
|
|
|
secure_credentials.crl_list = crl_list; |
|
|
|
secure_credentials.private_key = private_key; |
|
|
|
secure_credentials.certificate = certificate; |
|
|
|
} |
|
|
|
|
|
|
|
client._reconnect = function () { |
|
|
|
if (client.readyState != "opening") { |
|
|
|
//sys.debug("HTTP CLIENT: reconnecting readyState = " + client.readyState);
|
|
|
|
client.connect(port, host); |
|
|
|
if (secure_credentials.secure) { |
|
|
|
client.tcpSetSecure(secure_credentials.format_type, |
|
|
|
secure_credentials.ca_certs, |
|
|
|
secure_credentials.crl_list, |
|
|
|
secure_credentials.private_key, |
|
|
|
secure_credentials.certificate); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
client._pushRequest = function (req) { |
|
|
|
req.addListener("flush", function () { |
|
|
|
if (client.readyState == "closed") { |
|
|
|
//sys.debug("HTTP CLIENT request flush. reconnect. readyState = " + client.readyState);
|
|
|
|
client.connect(port, host); // reconnect
|
|
|
|
if (secure_credentials.secure) { |
|
|
|
client.tcpSetSecure(secure_credentials.format_type, |
|
|
|
secure_credentials.ca_certs, |
|
|
|
secure_credentials.crl_list, |
|
|
|
secure_credentials.private_key, |
|
|
|
secure_credentials.certificate); |
|
|
|
} |
|
|
|
client._reconnect(); |
|
|
|
return; |
|
|
|
} |
|
|
|
//sys.debug("client flush readyState = " + client.readyState);
|
|
|
@ -477,16 +494,6 @@ exports.createClient = function (port, host) { |
|
|
|
requests.push(req); |
|
|
|
}; |
|
|
|
|
|
|
|
client.tcpSetSecure = client.setSecure; |
|
|
|
client.setSecure = function(format_type, ca_certs, crl_list, private_key, certificate) { |
|
|
|
secure_credentials.secure = true; |
|
|
|
secure_credentials.format_type = format_type; |
|
|
|
secure_credentials.ca_certs = ca_certs; |
|
|
|
secure_credentials.crl_list = crl_list; |
|
|
|
secure_credentials.private_key = private_key; |
|
|
|
secure_credentials.certificate = certificate; |
|
|
|
} |
|
|
|
|
|
|
|
client.addListener("connect", function () { |
|
|
|
client.resetParser(); |
|
|
|
currentRequest = requests.shift(); |
|
|
@ -507,16 +514,8 @@ exports.createClient = function (port, host) { |
|
|
|
//sys.debug("HTTP CLIENT onClose. readyState = " + client.readyState);
|
|
|
|
|
|
|
|
// If there are more requests to handle, reconnect.
|
|
|
|
if (requests.length > 0 && client.readyState != "opening") { |
|
|
|
//sys.debug("HTTP CLIENT: reconnecting readyState = " + client.readyState);
|
|
|
|
client.connect(port, host); // reconnect
|
|
|
|
if (secure_credentials.secure) { |
|
|
|
client.tcpSetSecure(secure_credentials.format_type, |
|
|
|
secure_credentials.ca_certs, |
|
|
|
secure_credentials.crl_list, |
|
|
|
secure_credentials.private_key, |
|
|
|
secure_credentials.certificate); |
|
|
|
} |
|
|
|
if (requests.length > 0) { |
|
|
|
client._reconnect(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|