0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-03-11 02:15:57 -05:00

various bugfixes, camelcase for http headers

This commit is contained in:
Alex Kocharin 2013-12-09 08:00:16 +04:00
parent bbb402f762
commit 7f7c056ecd
2 changed files with 13 additions and 12 deletions

View file

@ -67,6 +67,14 @@ Storage.prototype.add_package = function(name, metadata, callback) {
// something weird
if (err && err.status !== 404) return cb(err)
// checking package
if (results) {
return cb(new UError({
status: 409,
msg: 'this package is already present'
}))
}
for (var i=0; i<err_results.length; i++) {
// checking error
// if uplink fails with a status other than 404, we report failure
@ -80,14 +88,6 @@ Storage.prototype.add_package = function(name, metadata, callback) {
}
}
// checking package
if (results) {
return cb(new UError({
status: 409,
msg: 'this package is already present'
}))
}
return cb()
})
}
@ -473,6 +473,7 @@ Storage.prototype.get_package = function(name, options, callback) {
for (var i in result['dist-tags']) {
if (Array.isArray(result['dist-tags'][i])) {
result['dist-tags'][i] = result['dist-tags'][i][result['dist-tags'][i].length-1]
if (result['dist-tags'][i] == null) delete result['dist-tags'][i]
}
}

View file

@ -85,8 +85,8 @@ function _setupProxy(hostname, config, mainconfig, isHTTPS) {
Storage.prototype.request = function(options, cb) {
var self = this
, headers = options.headers || {}
headers.accept = headers.accept || 'application/json'
headers['user-agent'] = headers['user-agent'] || this.userAgent
headers.Accept = headers.Accept || 'application/json'
headers['User-Agent'] = headers['User-Agent'] || this.userAgent
var method = options.method || 'GET'
, uri = options.uri_full || (this.config.url + options.uri)
@ -98,7 +98,7 @@ Storage.prototype.request = function(options, cb) {
if (utils.is_object(options.json)) {
var json = JSON.stringify(options.json)
headers['content-type'] = headers['content-type'] || 'application/json'
headers['Content-Type'] = headers['Content-Type'] || 'application/json'
}
var req = request({
@ -224,7 +224,7 @@ Storage.prototype.add_tarball = function(name, filename, options) {
uri: '/' + escape(name) + '/-/' + escape(filename) + '/whatever',
method: 'PUT',
headers: {
'content-type': 'application/octet-stream'
'Content-Type': 'application/octet-stream'
},
})