Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-07-25 23:00:25 +0400
committerisaacs <i@izs.me>2012-07-26 00:38:43 +0400
commitb0c0111b04201bf99fde0fe0616b9fdf1f33655d (patch)
tree537172b8db7ccb6051020d2ffca74230f19d2ca5 /lib
parent9eddaebb79ff1954b7ecdb209587d7db6554580d (diff)
https: Use host header as effective servername
Diffstat (limited to 'lib')
-rw-r--r--lib/http.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/http.js b/lib/http.js
index f7b2f786b69..87199ea3ac7 100644
--- a/lib/http.js
+++ b/lib/http.js
@@ -1067,7 +1067,7 @@ Agent.prototype.addRequest = function(req, host, port, localAddress) {
}
if (this.sockets[name].length < this.maxSockets) {
// If we are under maxSockets create a new one.
- req.onSocket(this.createSocket(name, host, port, localAddress));
+ req.onSocket(this.createSocket(name, host, port, localAddress, req));
} else {
// We are over limit so we'll add it to the queue.
if (!this.requests[name]) {
@@ -1076,12 +1076,21 @@ Agent.prototype.addRequest = function(req, host, port, localAddress) {
this.requests[name].push(req);
}
};
-Agent.prototype.createSocket = function(name, host, port, localAddress) {
+Agent.prototype.createSocket = function(name, host, port, localAddress, req) {
var self = this;
var options = util._extend({}, self.options);
options.port = port;
options.host = host;
options.localAddress = localAddress;
+
+ options.servername = host;
+ if (req) {
+ var hostHeader = req.getHeader('host');
+ if (hostHeader) {
+ options.servername = hostHeader.replace(/:.*$/, '');
+ }
+ }
+
var s = self.createConnection(options);
if (!self.sockets[name]) {
self.sockets[name] = [];
@@ -1122,8 +1131,9 @@ Agent.prototype.removeSocket = function(s, name, host, port, localAddress) {
}
}
if (this.requests[name] && this.requests[name].length) {
+ var req = this.requests[name][0];
// If we have pending requests and a socket gets closed a new one
- this.createSocket(name, host, port, localAddress).emit('free');
+ this.createSocket(name, host, port, localAddress, req).emit('free');
}
};