diff options
| author | corrupt | 2013-10-18 15:42:55 +0300 | 
|---|---|---|
| committer | Igor Minar | 2013-11-26 12:36:41 -0800 | 
| commit | 68ceb17272bdd2ebc838565070973d93704f4427 (patch) | |
| tree | 47a875cbc4efc138bf780b133c09436dfcc6bec6 /src | |
| parent | 5bd6596856c9f88c0ce3d96ff1ed4daa082cbe29 (diff) | |
| download | angular.js-68ceb17272bdd2ebc838565070973d93704f4427.tar.bz2 | |
chore($httpBackend): preserve original non-zero http status code for file:// apps
Previously if an app was running from file:// origin we would always return either
http 200 or 404 depending on whether the response was present.
This changes the behavior so that we do this only if the protocol of the request
(not the origin) is file:// and only if the status code is 0.
Closes #4436
Closes #4587
Closes #4514
Diffstat (limited to 'src')
| -rw-r--r-- | src/ng/httpBackend.js | 9 | 
1 files changed, 4 insertions, 5 deletions
| diff --git a/src/ng/httpBackend.js b/src/ng/httpBackend.js index 71592a56..0a0e1f71 100644 --- a/src/ng/httpBackend.js +++ b/src/ng/httpBackend.js @@ -28,12 +28,11 @@ var XHR = window.XMLHttpRequest || function() {   */  function $HttpBackendProvider() {    this.$get = ['$browser', '$window', '$document', function($browser, $window, $document) { -    return createHttpBackend($browser, XHR, $browser.defer, $window.angular.callbacks, -        $document[0], $window.location.protocol.replace(':', '')); +    return createHttpBackend($browser, XHR, $browser.defer, $window.angular.callbacks, $document[0]);    }];  } -function createHttpBackend($browser, XHR, $browserDefer, callbacks, rawDocument, locationProtocol) { +function createHttpBackend($browser, XHR, $browserDefer, callbacks, rawDocument) {    var ABORTED = -1;    // TODO(vojta): fix the signature @@ -113,14 +112,14 @@ function createHttpBackend($browser, XHR, $browserDefer, callbacks, rawDocument,      }      function completeRequest(callback, status, response, headersString) { -      var protocol = locationProtocol || urlResolve(url).protocol; +      var protocol = urlResolve(url).protocol;        // cancel timeout and subsequent timeout promise resolution        timeoutId && $browserDefer.cancel(timeoutId);        jsonpDone = xhr = null;        // fix status code for file protocol (it's always 0) -      status = (protocol == 'file') ? (response ? 200 : 404) : status; +      status = (protocol == 'file' && status === 0) ? (response ? 200 : 404) : status;        // normalize IE bug (http://bugs.jquery.com/ticket/1450)        status = status == 1223 ? 204 : status; | 
