Comparing version 1.1.2 to 1.1.3
# Changelog | ||
## 1.1.3 | ||
* Support zero-byte JSON HTTP bodies (#2) | ||
## 1.1.2 | ||
@@ -4,0 +8,0 @@ |
@@ -575,24 +575,24 @@ /** | ||
try { | ||
response = JSON.parse(body); | ||
if (this.debug) { | ||
this.debug( | ||
'[OVH]', | ||
'API response to', | ||
options.method, options.path, ':', | ||
body | ||
); | ||
if (body.length > 0) { | ||
try { | ||
response = JSON.parse(body); | ||
} | ||
} catch (e) { | ||
if (res.statusCode !== 200) { | ||
return callback('[OVH] Error in response, HTTP code is ' + res.statusCode, res.statusCode); | ||
} | ||
else { | ||
catch (e) { | ||
return callback('[OVH] Unable to parse JSON reponse'); | ||
} | ||
} | ||
else { | ||
response = null; | ||
} | ||
if (this.debug) { | ||
this.debug( | ||
'[OVH] API response to', | ||
options.method, options.path, ':', | ||
body | ||
); | ||
} | ||
if (res.statusCode !== 200) { | ||
callback(res.statusCode, response.message); | ||
callback(res.statusCode, response ? response.message : response); | ||
} | ||
@@ -599,0 +599,0 @@ else { |
{ | ||
"name": "ovh", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Official Node.js wrapper for the OVH APIs", | ||
@@ -5,0 +5,0 @@ "homepage": "http://ovh.github.io/node-ovh", |
@@ -75,7 +75,8 @@ /** | ||
.intercept('/1.0/me', 'GET') | ||
.reply(401); | ||
.reply(401, {'message': 'You must login first'}); | ||
var rest = ovh({ appKey: 'XXX', appSecret: 'XXX', apis: [] }); | ||
rest.request('GET', '/me', function (err, message) { | ||
assert.equal(message, 401); | ||
assert.equal(err, 401); | ||
assert.equal(message, 'You must login first'); | ||
done(); | ||
@@ -82,0 +83,0 @@ }); |
@@ -257,4 +257,25 @@ /** | ||
}); | ||
}, | ||
'DELETE /todelete - 0 bytes JSON body': function (done) { | ||
'use strict'; | ||
nock('https://eu.api.ovh.com') | ||
.intercept('/1.0/auth/time', 'GET') | ||
.reply(200, Math.round(Date.now() / 1000)) | ||
.intercept('/1.0/todelete', 'DELETE') | ||
.reply(200, ''); | ||
var rest = ovh({ | ||
appKey: APP_KEY, | ||
appSecret: APP_SECRET, | ||
consumerKey: CONSUMER_KEY | ||
}); | ||
rest.request('DELETE', '/todelete', function (err, message) { | ||
assert.ok(!err); | ||
assert.equal(message, null); | ||
done(); | ||
}); | ||
} | ||
}; | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90109
1978