Merge branch 'master' of github.com:rlidwka/sinopia

This commit is contained in:
Alex Kocharin 2013-12-06 21:49:31 +04:00
commit cc7165dd3c
2 changed files with 8 additions and 0 deletions

View File

@ -12,6 +12,10 @@ uplinks:
npmjs: npmjs:
url: https://registry.npmjs.org/ url: https://registry.npmjs.org/
# amount of time to wait for repository to respond before giving up
# and use the local cached copy
timeout: 3000
# maximum time (in seconds) in which data is considered up to date # maximum time (in seconds) in which data is considered up to date
# #
# default is 2 minutes, so server won't request the same data from # default is 2 minutes, so server won't request the same data from

View File

@ -32,6 +32,9 @@ function Storage(config, mainconfig) {
_setupProxy.call(this, this.url.hostname, config, mainconfig, this.url.protocol === 'https:') _setupProxy.call(this, this.url.hostname, config, mainconfig, this.url.protocol === 'https:')
this.config.url = this.config.url.replace(/\/$/, '') this.config.url = this.config.url.replace(/\/$/, '')
if (isNaN(parseFloat(this.config.timeout)) || !isFinite(this.config.timeout)) {
this.config.timeout = 5000
}
return this return this
} }
@ -105,6 +108,7 @@ Storage.prototype.request = function(options, cb) {
body: json, body: json,
ca: this.ca, ca: this.ca,
proxy: this.proxy, proxy: this.proxy,
timeout: this.config.timeout
}, function(err, res, body) { }, function(err, res, body) {
var error var error
if (!err) { if (!err) {