Using POST instead of JSONP for JSON-RPC calls to enable *.torrent file uploads
This commit is contained in:
parent
fc98bc5b31
commit
49755bff68
|
@ -7,28 +7,24 @@ angular
|
||||||
this.avgTimeout = 2000;
|
this.avgTimeout = 2000;
|
||||||
this.serverConf = conf;
|
this.serverConf = conf;
|
||||||
},
|
},
|
||||||
encode: function(obj) {
|
|
||||||
return base64.btoa( JSON.stringify(obj) );
|
|
||||||
},
|
|
||||||
ariaRequest: function(url, funcName, params, success, error) {
|
ariaRequest: function(url, funcName, params, success, error) {
|
||||||
var startTime = new Date();
|
var startTime = new Date();
|
||||||
var conn = this;
|
var conn = this;
|
||||||
$.ajax({
|
$.post({
|
||||||
url: url,
|
url: url,
|
||||||
timeout: this.avgTimeout,
|
timeout: this.avgTimeout,
|
||||||
data: {
|
contentType: 'application/json',
|
||||||
|
data: JSON.stringify({
|
||||||
jsonrpc: 2.0,
|
jsonrpc: 2.0,
|
||||||
id: 'webui',
|
id: 'webui',
|
||||||
method: funcName,
|
method: funcName,
|
||||||
params: params && params.length ? this.encode(params) : undefined
|
params: params
|
||||||
},
|
}),
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
conn.avgTimeout = 2000 + 3 * (new Date() - startTime);
|
conn.avgTimeout = 2000 + 3 * (new Date() - startTime);
|
||||||
return success(data);
|
return success(data);
|
||||||
},
|
},
|
||||||
error: error,
|
error: error
|
||||||
dataType: 'jsonp',
|
|
||||||
jsonp: 'jsoncallback'
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
invoke: function(opts) {
|
invoke: function(opts) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user