取消这样的http请求时:
$scope.runTest = function() {
if (canceler) canceler.resolve();
canceler = $q.defer();
$http({
method: 'GET',
url: 'http://www.google.com/',
timeout: canceler.promise
})
.success(function(data) {
$scope.result.push({msg: "this won't be displayed on cancel"});
})
.error(function(data) {
$scope.result.push({msg: "this will be displayed on cancel"});
});
};
Run Code Online (Sandbox Code Playgroud)
是否可以使取消的HTTP请求具有特定的HTTP代码,如205?它会导致http拦截器以http状态0触发,该状态也用于超时或无网络连接.我希望能够区分拦截器中的两个场景
谢谢!