Browse Source

Fixed authoriser empty response

master
Igor Zhukov 10 years ago
parent
commit
24d82a5768
  1. 18
      app/js/lib/mtproto.js

18
app/js/lib/mtproto.js

@ -201,6 +201,10 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) @@ -201,6 +201,10 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
responseType: 'arraybuffer',
transformRequest: null,
transformResponse: function (responseBuffer) {
if (!responseBuffer || !responseBuffer.byteLength) {
return $q.reject({code: 406, type: 'NETWORK_BAD_RESPONSE'});
}
try {
var deserializer = new TLDeserialization(responseBuffer, {mtproto: true});
@ -216,20 +220,12 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) @@ -216,20 +220,12 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
return deserializer;
}
}).then(
function (result) {
if (!result.data || !result.data.byteLength) {
return $q.reject({code: 406, type: 'NETWORK_BAD_REQUEST'});
}
return result;
},
function (error) {
})['catch'](function (error) {
if (!error.message && !error.type) {
error = {code: 406, type: 'NETWORK_BAD_REQUEST'};
}
return $q.reject(error);
}
);
});
};
function mtpSendReqPQ (auth) {
@ -1130,7 +1126,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) @@ -1130,7 +1126,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
}).then(
function (result) {
if (!result.data || !result.data.byteLength) {
return $q.reject({code: 406, type: 'NETWORK_BAD_REQUEST'});
return $q.reject({code: 406, type: 'NETWORK_BAD_RESPONSE'});
}
return result;
},

Loading…
Cancel
Save