Navigation Menu

Skip to content

Commit

Permalink
Use timeout parameter only when it is given
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 20, 2015
1 parent d3ea485 commit 4c0673d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/adapter/api/droonga.js
Expand Up @@ -14,7 +14,9 @@ module.exports = {
onRequest: function(request, connection) {
var messageType = pathToMessageType(request.params[0]);
var body = {};
body.timeout = body.timeout || request.query.timeout;
if (typeof body.timeout != 'number' &&
typeof request.query.timeout == 'number')
body.timeout = request.query.timeout;
connection.emit(messageType, body);
}
}),
Expand All @@ -30,7 +32,9 @@ module.exports = {
});
request.on('end', function() {
body = JSON.parse(body);
body.timeout = body.timeout || request.query.timeout;
if (typeof body.timeout != 'number' &&
typeof request.query.timeout == 'number')
body.timeout = request.query.timeout;
body.type = body.type || 'droonga-' + messageType;
connection.emit(messageType, body);
});
Expand Down

0 comments on commit 4c0673d

Please sign in to comment.