Updated express's response method calls.

This commit is contained in:
Payman Delshad
2015-02-23 11:04:13 +01:00
committed by Payman Delshad
parent b0a0e3d58e
commit 9f62caef33
5 changed files with 15 additions and 15 deletions
+6 -6
View File
@@ -50,7 +50,7 @@ exports.sessionBeforeFilter = function (req, res, next) {
// if we don't actually have a valid session, respond with an error
if (sessId && (!req.device || req.appium.sessionId !== sessId)) {
safely(req, function () {
res.send(404, {sessionId: null, status: status.codes.NoSuchDriver.code, value: ''});
res.status(404).send({sessionId: null, status: status.codes.NoSuchDriver.code, value: ''});
});
} else {
next();
@@ -172,7 +172,7 @@ exports.createSession = function (req, res) {
var next = function (reqHost, sessionId) {
safely(req, function () {
res.set('Location', "http://" + reqHost + "/wd/hub/session/" + sessionId);
res.send(303);
res.status(303).send("Appium session started with sessionId " + sessionId);
});
};
if (req.appium.preLaunched && req.appium.sessionId) {
@@ -953,8 +953,8 @@ exports.executeMobileMethod = function (req, res, cmd) {
if (args.length) {
if (args.length !== 1) {
safely(req, function () {
res.send(400, "Mobile methods only take one parameter, which is a " +
"hash of named parameters to send to the method");
res.status(400).send("Mobile methods only take one parameter, which is a " +
"hash of named parameters to send to the method");
});
} else {
params = args[0];
@@ -1047,7 +1047,7 @@ exports.receiveAsyncResponse = function (req, res) {
var asyncResponse = req.body;
req.device.receiveAsyncResponse(asyncResponse);
safely(req, function () {
res.send(200, 'OK');
res.sendStatus(200);
});
};
@@ -1113,7 +1113,7 @@ exports.unknownCommand = function (req, res) {
logger.debug("Responding to client that we did not find a valid resource");
safely(req, function () {
res.set('Content-Type', 'text/plain');
res.send(404, "That URL did not map to a valid JSONWP resource");
res.status(404).send("That URL did not map to a valid JSONWP resource");
});
};
+2 -2
View File
@@ -22,7 +22,7 @@ module.exports.allowCrossDomain = function (req, res, next) {
if ('OPTIONS' === req.method) {
safely(req, function () {
res.send(200);
res.sendStatus(200);
});
} else {
next();
@@ -39,7 +39,7 @@ module.exports.winstonStream = {
module.exports.catchAllHandler = function (e, req, res, next) {
safely(req, function () {
res.send(500, {
res.status(500).send({
status: status.codes.UnknownError.code
, value: "ERROR running Appium command: " + e.message
});
+1 -1
View File
@@ -77,7 +77,7 @@ module.exports.doProxy = function (req, res) {
safely(req, function () {
res.headers = response.headers;
res.set('Content-Type', response.headers['content-type']);
res.send(response.statusCode, body);
res.status(response.statusCode).send(body);
});
});
};
+5 -5
View File
@@ -24,7 +24,7 @@ var notImplementedInThisContext = function (req, res) {
logger.debug("Responding to client that a method is not implemented " +
"in this context");
safely(req, function () {
res.send(501, {
res.status(501).send({
status: status.codes.UnknownError.code
, sessionId: getSessionId(req)
, value: {
@@ -66,7 +66,7 @@ var respondError = exports.respondError = function (req, res, statusObj, value)
response.sessionId = getSessionId(req, response);
logger.debug("Responding to client with error: " + JSON.stringify(response));
safely(req, function () {
res.send(500, response);
res.status(500).send(response);
});
};
@@ -86,7 +86,7 @@ var respondSuccess = exports.respondSuccess = function (req, res, value, sid) {
res.jsonResp = JSON.stringify(printResponse);
logger.debug("Responding to client with success: " + res.jsonResp);
safely(req, function () {
res.send(response);
res.status(200).send(response);
});
};
@@ -139,7 +139,7 @@ exports.checkMissingParams = function (req, res, params, strict) {
var missingList = JSON.stringify(missingParamNames);
logger.debug("Missing params for request: " + missingList);
safely(req, function () {
res.send(400, "Missing parameters: " + missingList);
res.status(400).send("Missing parameters: " + missingList);
});
return false;
} else {
@@ -150,7 +150,7 @@ exports.checkMissingParams = function (req, res, params, strict) {
var notYetImplemented = exports.notYetImplemented = function (req, res) {
logger.debug("Responding to client that a method is not implemented");
safely(req, function () {
res.send(501, {
res.status(501).send({
status: status.codes.UnknownError.code
, sessionId: getSessionId(req)
, value: {
+1 -1
View File
@@ -21,7 +21,7 @@ CodeInjector.prototype.start = function () {
// caching code and returning 200
this.code = req.body.code;
console.log('code injector is saving code. code -->', this.code);
res.send(200);
res.sendStatus(200);
}.bind(this));
this.app.get('/code', function (req, res) {