Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sendReport(report) {
request.put({
url: 'https://nim-test-ingress.appspot.com',
json: report,
}, (err) => {
if (err) {
console.log('err', err);
return;
}
// console.log('status', response.statusCode);
});
}
function putToCollection(item, callback) {
request.put({url: testUtils.getRootUrl() + '/api/collections/' + firstCollection._id + '/items/' + item._id, headers: secondUserHeaders}, callback);
}
});
updateDb: function(dbname){
console.log("please wait for the server config to finished updating")
request.put('http://localhost:8002/manage/v2/servers/repl-http/properties?group-id=Default',
{
auth: {user:this.user, pass:this.password, sendImmediately:false},
json: {'content-database':dbname},
scope: this
},
function(err,resp, body){
if(err){
console.log(err);
} else {
this.scope.database = dbname;
console.log(body);
}
});
},
fetchConfig: function(init){
headers: headers ? headers : undefined,
},
(err: any, res: request.Response) => {
this.verifyRequest(
err,
res,
'delete',
paramaterisedPath,
validateFn,
);
},
);
break;
}
case 'put': {
request.put(
{
url: `${rootUrl}${paramaterisedPath}`,
headers: headers ? headers : undefined,
body: body ? body : undefined,
json: true,
},
(err: any, res: request.Response) => {
this.verifyRequest(err, res, 'put', paramaterisedPath, validateFn);
},
);
break;
}
case 'patch': {
request.patch(
{
url: `${rootUrl}${paramaterisedPath}`,
function adduser (username, password, email, cb) {
if (password.indexOf(":") !== -1) return cb(new Error(
"Sorry, ':' chars are not allowed in passwords.\n"+
"See for why."));
var salt = "na"
, userobj = {name : username
, salt : salt
, password_sha : crypto.createHash("sha1").update(password+salt).digest("hex")
, email : email
, _id : 'org.couchdb.user:'+username
, type : "user"
, roles : []
, date: new Date().toISOString()};
logger.info("adding user "+JSON.stringify(userobj));
request.put({uri:regBase+'/-/user/org.couchdb.user:'+encodeURIComponent(username), json:true, body:userobj}, cb);
}
}else {
var initializeNeeded = false;
if(response.statusCode === 404){
initializeNeeded = true;
}else if(response.statusCode === 200){
if( 'template_api' in body ) {
if (!('version' in body.template_api) || (body.template_api.version < requiredTemplateVersion)) {
initializeNeeded = true;
}
}
}
if(initializeNeeded){
request.put(putOptions, function (error, response, body) {
if(error) {
debug("Failed to update template:", JSON.stringify(error));
}
});
}
}
});
resumableUpload.prototype.getProgress = function(handler) {
var self = this;
var options = {
url: self.location,
headers: {
'Authorization': 'Bearer ' + self.tokens.access_token,
'Content-Length': 0,
'Content-Range': 'bytes */' + fs.statSync(self.filepath).size
}
};
request.put(options, handler);
}
err.statusMessage = http.STATUS_CODES[response.statusCode];
}
callback(err, body);
};
switch (method.toLowerCase())
{
case "get":
request.get(options, requestCallback);
break;
case "post":
request.post(options, requestCallback);
break;
case "put":
request.put(options, requestCallback);
break;
case "delete":
request.delete(options, requestCallback);
break;
}
};
}
let afterUpdate =
function(e, result) {
if (conn.verbosity>0) {
if (e) {
utility.logWrite('Update error: ' + JSON.stringify(e));
}
else {
utility.logWrite('Update result: ' + JSON.stringify(result));
}
}
return cb(e, result);
};
fs.createReadStream(options.filename)
.pipe(request.put(requestOptions, common.callback(conn, [200], afterUpdate)));
});
}
return new Promise(function (resolve, reject) {
request
.put({
'url': c.url + '/users/' + order.general.user_id + '/orders/' + order.id + '/',
headers: {
'authentication': auth.getAuth(),
"Content-Type": "application/json"
},
body: JSON.stringify(order)
}, helper.handleResponse(resolve, reject));
});
};