From 637cbcbf990499aa2b8757bd0039ea354b77c98c Mon Sep 17 00:00:00 2001 From: lilia Date: Tue, 28 Jul 2015 13:22:06 -0700 Subject: [PATCH] Make handleRequest optional in WebSocketResources If no request handler is provided, respond with 404 to any incoming requests. --- js/libtextsecure.js | 9 ++++++++- libtextsecure/websocket-resources.js | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index e79a8529..fb4ed614 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -38563,7 +38563,14 @@ TextSecureWebSocket = function (url, opts) { ); }; - window.WebSocketResource = function(socket, handleRequest, keepalive) { + window.WebSocketResource = function(socket, opts) { + opts = opts || {}; + var handleRequest = opts.handleRequest; + if (typeof handleRequest !== 'function') { + handleRequest = function(request) { + request.respond(404); + }; + } this.sendRequest = function(options) { return new OutgoingWebSocketRequest(options, socket); }; diff --git a/libtextsecure/websocket-resources.js b/libtextsecure/websocket-resources.js index 4f0972ed..c613849a 100644 --- a/libtextsecure/websocket-resources.js +++ b/libtextsecure/websocket-resources.js @@ -92,7 +92,14 @@ ); }; - window.WebSocketResource = function(socket, handleRequest, keepalive) { + window.WebSocketResource = function(socket, opts) { + opts = opts || {}; + var handleRequest = opts.handleRequest; + if (typeof handleRequest !== 'function') { + handleRequest = function(request) { + request.respond(404); + }; + } this.sendRequest = function(options) { return new OutgoingWebSocketRequest(options, socket); };