(wrapped)
| 1532 | } |
| 1533 | |
| 1534 | function wrapResponse(wrapped) { |
| 1535 | if (!$browser && timeout) { |
| 1536 | if (timeout.then) { |
| 1537 | timeout.then(function() { |
| 1538 | handlePrematureEnd(angular.isDefined(timeout.$$timeoutId) ? 'timeout' : 'abort'); |
| 1539 | }); |
| 1540 | } else { |
| 1541 | $timeout(function() { |
| 1542 | handlePrematureEnd('timeout'); |
| 1543 | }, timeout); |
| 1544 | } |
| 1545 | } |
| 1546 | |
| 1547 | handleResponse.description = method + ' ' + url; |
| 1548 | return handleResponse; |
| 1549 | |
| 1550 | function handleResponse() { |
| 1551 | var response = wrapped.response(method, url, data, headers, wrapped.params(url)); |
| 1552 | xhr.$$respHeaders = response[2]; |
| 1553 | callback(copy(response[0]), copy(response[1]), xhr.getAllResponseHeaders(), |
| 1554 | copy(response[3] || ''), copy(response[4])); |
| 1555 | } |
| 1556 | |
| 1557 | function handlePrematureEnd(reason) { |
| 1558 | for (var i = 0, ii = responses.length; i < ii; i++) { |
| 1559 | if (responses[i] === handleResponse) { |
| 1560 | responses.splice(i, 1); |
| 1561 | callback(-1, undefined, '', undefined, reason); |
| 1562 | break; |
| 1563 | } |
| 1564 | } |
| 1565 | } |
| 1566 | } |
| 1567 | |
| 1568 | function createFatalError(message) { |
| 1569 | var error = new Error(message); |
no test coverage detected