Commit 637c7d8b authored by Robert Knight's avatar Robert Knight

Treat responses with status >= 500 as invalid responses

Do not expect to be able to parse valid session data out of responses
with 5xx status codes - eg. gateway errors, internal server errors.
parent cb7c1a7c
......@@ -155,7 +155,7 @@ function session($http, $resource, $rootScope, flash, raven, settings) {
};
function process(data, headersGetter, status) {
if (status < 200) {
if (status < 200 || status >= 500) {
return;
}
......
......@@ -159,10 +159,20 @@ describe('h:session', function () {
$httpBackend.flush();
});
it('should tolerate failed requests', function () {
$httpBackend.expectGET(url).respond(-1, null);
session.load();
$httpBackend.flush();
var failedRequestCases = [{
status: -1,
body: null,
},{
status: 504,
body: 'Gateway Timeout',
}];
failedRequestCases.forEach(function (testCase) {
it('should tolerate failed requests', function () {
$httpBackend.expectGET(url).respond(testCase.status, testCase.body);
session.load();
$httpBackend.flush();
});
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment