-
Notifications
You must be signed in to change notification settings - Fork 27.5k
fix(angular.js): wrong $httpBackend status code #4514
Conversation
Thanks for the PR!
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
Can you please move this issue into the 1.2 milestone ? Angularjs is being used by more phonegap/cordova users every day and this issue makes angular working with remote data impossible. |
I'm happily using Angular 1.2rc3 on phonegap right now with no issues--I also don't use file:// urls, I use relative urls; that may make all the difference. |
@lord2800 I also use relative paths and the problem exists. Have you tried with $http.post() with backend returning HTTP_400 for example ? |
Ah, I haven't tried POSTing to myself. I can give that a try. |
+1, thank you @c0rrupt for this fix, this is a major bug, and should be in 1.2 release. Currently if you are using phonegap/cordova (or anything that serves your app over a file:// protocol) and $http with a backend that responds with a non-200 status code (e.g. 400-500) with a response it will be considered a 200 status code, and the success function will be called. |
@ADmad yep, CLA has been signed as requested (all checkboxes are checked in @mary-poppins bot's comment). Core devs mark this PR for 1.2.1 milestone. |
@c0rrupt Okay cool, let's hope it gets merged soon or at least some feedback from the devs. |
Spent today trying to find the same problem used the following as a temporary fix:
|
+1.. Need fix soon |
@c0rrupt unfortunately I'm unable to verify your CLA signature. Can you please sign it again and make sure that you use the same email address as the one associated with your commit in this PR. |
@@ -1,6 +1,7 @@ | |||
'use strict'; | |||
|
|||
var PATH_MATCH = /^([^\?#]*)(\?([^#]*))?(#(.*))?$/, | |||
var SERVER_MATCH = /^([^:]+):\/\/(\w+:{0,1}\w*@)?(\{?[\w\.-]*\}?)(:([0-9]+))?(\/[^\?#]*)?(\?([^#]*))?(#(.*))?$/, | |||
PATH_MATCH = /^([^\?#]*)(\?([^#]*))?(#(.*))?$/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this hunk is obsolete
@IgorMinar Has been updated PR, re-signed CLA |
@c0rrupt that looks much better! Thanks |
…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 angular#4436 Closes angular#4587 Closes angular#4514
…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 angular#4436 Closes angular#4587 Closes angular#4514
I'm using 1.2.21, but even now for HTTP 400 requests the |
more than likely it's one of your interceptors returning a value which is not a rejected promise, @adityamenon. |
Ah, yep, I just began returning |
Okay, sorry just read the relevant part of the docs that says I can directly modify the objects in case of the |
It's not that it's compulsory, but it's just how promises work --- subsequent chained promises are fulfilled with the result of the promise handler --- if that value is not a rejected promise, then you fulfill the next promise with a value and the subsequent success handler is called. |
Ah, I get it now. I just wanted to make sure future me or someone else doesn't repeat this mistake, but there is no non-redundant way of warning in that area of the docs... thanks a lot! |
If I run html document as a file in browser (e.g. file:///index.html), then all ajax responses have a protocol "file" (and therefore response status code can be 200 or 404)
locationProtocol has higher priority in completeRequest function.
It's critical in mobile hybrid applications which use angularjs (index.html run from local filesystem)