Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

angularjs incorrectly returns status 0 on Android when fetching from the application cache #1720

Closed
@tokafish

Description

@tokafish

I'm building a mobile web application using AngularJS, and I'm encountering the following issue. My application is cached using an HTML5 Application cache. It loads fine, but if I manually kill the browser (or cause Android WebKit to unload the document), I encounter a problem in $httpBackend:

    function completeRequest(callback, status, response, headersString) {
      // URL_MATCH is defined in src/service/location.js
      var protocol = (url.match(URL_MATCH) || ['', locationProtocol])[1];

      // fix status code for file protocol (it's always 0)
      status = (protocol == 'file') ? (response ? 200 : 404) : status;

      // normalize IE bug (http://bugs.jquery.com/ticket/1450)
      status = status == 1223 ? 204 : status;

      console.log(callback);

      callback(status, response, headersString);
      $browser.$$completeOutstandingRequest(noop);
    }

In the case of loading a file from the appcache (in this case, the template to a particular route for ng-view), status == 0. Because of this, $http rejects the promise instead of resolving it, and the view is never loaded.

I'm wondering if this line could be added after the file protocol check:

      status = (status == 0 && response) ? 200 : status;

This solves the appcache problem correctly, but I'm not sure if that solution exposes another problem.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions