From 49755bff68489350f67dd6114aa4dcf53ef37be8 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 4 Aug 2017 15:50:34 +0300 Subject: [PATCH] Using POST instead of JSONP for JSON-RPC calls to enable *.torrent file uploads --- js/services/rpc/jsoncall.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/js/services/rpc/jsoncall.js b/js/services/rpc/jsoncall.js index 4642467..4c15f99 100644 --- a/js/services/rpc/jsoncall.js +++ b/js/services/rpc/jsoncall.js @@ -7,28 +7,24 @@ angular this.avgTimeout = 2000; this.serverConf = conf; }, - encode: function(obj) { - return base64.btoa( JSON.stringify(obj) ); - }, ariaRequest: function(url, funcName, params, success, error) { var startTime = new Date(); var conn = this; - $.ajax({ + $.post({ url: url, timeout: this.avgTimeout, - data: { + contentType: 'application/json', + data: JSON.stringify({ jsonrpc: 2.0, id: 'webui', method: funcName, - params: params && params.length ? this.encode(params) : undefined - }, + params: params + }), success: function(data) { conn.avgTimeout = 2000 + 3 * (new Date() - startTime); return success(data); }, - error: error, - dataType: 'jsonp', - jsonp: 'jsoncallback' + error: error }); }, invoke: function(opts) {