Skip to content

Commit

Permalink
Use an https keepalive agent.
Browse files Browse the repository at this point in the history
  • Loading branch information
yhahn committed Jun 9, 2014
1 parent a8ce18c commit c98cafc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/tilejson.js
Expand Up @@ -11,6 +11,11 @@ var agent = new Agent({
maxKeepAliveRequests: 0,
maxKeepAliveTime: 30000
});
var httpsagent = new Agent.HttpsAgent({
maxSockets: 128,
maxKeepAliveRequests: 0,
maxKeepAliveTime: 30000
});

var cache = {};

Expand Down Expand Up @@ -198,7 +203,7 @@ TileJSON.prototype.get = function(url, callback) {
uri: url,
timeout: tilejson.timeout,
headers: {Connection:'Keep-Alive'},
agent: agent
agent: url.indexOf('https:') === 0 ? httpsagent : agent
}).asBuffer(function(err, result, headers) {
// Retry if status is missing or in the 5XX range.
if (err && (!err.status || err.status >= 500)) {
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/world-bright.tilejson
@@ -1,7 +1,7 @@
{
"name": "World Bright",
"scheme": "tms",
"tiles": [ "http://a.tiles.mapbox.com/mapbox/1.0.0/world-bright/{z}/{x}/{y}.png" ],
"scheme": "xyz",
"tiles": [ "http://a.tiles.mapbox.com/v3/mapbox.world-bright/{z}/{x}/{y}.png" ],
"minzoom": 0,
"maxzoom": 11,
"bounds": [ -180, -85, 180, 85 ]
Expand Down

0 comments on commit c98cafc

Please sign in to comment.