Log all http requests at start and end
// FREEBIE
This commit is contained in:
@@ -38931,6 +38931,7 @@ TextSecureServer = function () {
|
|||||||
*/
|
*/
|
||||||
function ajax(url, options) {
|
function ajax(url, options) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
|
console.log(options.type, url);
|
||||||
var error = new Error(); // just in case, save stack here.
|
var error = new Error(); // just in case, save stack here.
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open(options.type, url, true /*async*/);
|
xhr.open(options.type, url, true /*async*/);
|
||||||
@@ -38955,12 +38956,15 @@ TextSecureServer = function () {
|
|||||||
try { result = JSON.parse(xhr.responseText + ''); } catch(e) {}
|
try { result = JSON.parse(xhr.responseText + ''); } catch(e) {}
|
||||||
}
|
}
|
||||||
if ( 0 <= xhr.status && xhr.status < 400) {
|
if ( 0 <= xhr.status && xhr.status < 400) {
|
||||||
|
console.log('Success', xhr.status);
|
||||||
resolve(result, xhr.status);
|
resolve(result, xhr.status);
|
||||||
} else {
|
} else {
|
||||||
|
console.log('Error', xhr.status);
|
||||||
reject(HTTPError(xhr.status, result, error.stack));
|
reject(HTTPError(xhr.status, result, error.stack));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.onerror = function() {
|
xhr.onerror = function() {
|
||||||
|
console.log('Error', xhr.status);
|
||||||
reject(HTTPError(xhr.status, null, error.stack));
|
reject(HTTPError(xhr.status, null, error.stack));
|
||||||
};
|
};
|
||||||
xhr.send( options.data || null );
|
xhr.send( options.data || null );
|
||||||
|
@@ -42,6 +42,7 @@ TextSecureServer = function () {
|
|||||||
*/
|
*/
|
||||||
function ajax(url, options) {
|
function ajax(url, options) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
|
console.log(options.type, url);
|
||||||
var error = new Error(); // just in case, save stack here.
|
var error = new Error(); // just in case, save stack here.
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open(options.type, url, true /*async*/);
|
xhr.open(options.type, url, true /*async*/);
|
||||||
@@ -66,12 +67,15 @@ TextSecureServer = function () {
|
|||||||
try { result = JSON.parse(xhr.responseText + ''); } catch(e) {}
|
try { result = JSON.parse(xhr.responseText + ''); } catch(e) {}
|
||||||
}
|
}
|
||||||
if ( 0 <= xhr.status && xhr.status < 400) {
|
if ( 0 <= xhr.status && xhr.status < 400) {
|
||||||
|
console.log('Success', xhr.status);
|
||||||
resolve(result, xhr.status);
|
resolve(result, xhr.status);
|
||||||
} else {
|
} else {
|
||||||
|
console.log('Error', xhr.status);
|
||||||
reject(HTTPError(xhr.status, result, error.stack));
|
reject(HTTPError(xhr.status, result, error.stack));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.onerror = function() {
|
xhr.onerror = function() {
|
||||||
|
console.log('Error', xhr.status);
|
||||||
reject(HTTPError(xhr.status, null, error.stack));
|
reject(HTTPError(xhr.status, null, error.stack));
|
||||||
};
|
};
|
||||||
xhr.send( options.data || null );
|
xhr.send( options.data || null );
|
||||||
|
Reference in New Issue
Block a user