-
Notifications
You must be signed in to change notification settings - Fork 27.5k
feat($http): add xhr statusText to completeRequest callback #2665
Conversation
@jimlyndon : Thanks for this PR. In its current form, this feature would break lots of code that is already in production. It may be feasible to only add status text as the last parameter, since it would not be breaking. But I suspect that this is not going to be a useful enough addition to the core project. It is perfectly possible to access the status text if you need it by providing handlers through |
Ah, yes, I should add statusText to the end of the parameter list in the promise success/error as that interface would break for current users. Probably should write a test to check that as well.
Can you explain a little more. As far as I can tell, HttpBackend doesn't expose statusText on the XMLHttpRequest object. Providing a handler would be too late I believe. Thanks @petebacondarwin |
@jimlyndon - OK, looking through more carefully now I see that this is not available. We'll need the param moving to the end of the param list and we'll also need the core team to agree to adding this. Personally, I would just rely on the status code and create a user friendy message string mapping in my application. BTW, are statusTexts language dependent? I.E. does the browser provide different strings based on its language setting? If so, what would you do about the hard-coded statusTexts, like "No Content"? |
I agree, though it's not always an option when building clients against existing APIs.
Language settings in the browser won't affect the response, and if you want to manage something like localisation you have to do that yourself (server or client side). The browser just passes on the value, whatever the case, just like it does the response and (normally) the status code (with a few known exceptions) I'll reorder the parameters since callbacks depend on the order and I'll add some new tests to cover that exact scenario (which would be a good test to have even without including the feature). I agree with making it as non-invasive as possible. And I completely understand wanting to keep the code base small and not add every little feature, Though this is a pretty standard w3c api that's been consistently available, and should be a trivial addition (at least after I make your change request :). |
Updated. I also followed your initial suggestion and simplified the $http changes (statusText accessible through 'then') leaving success/error callbacks as they are, making this PR less invasive. Let me know what you think. |
I'll take a look tomorrow. On 20 May 2013 13:24, Jim Lyndon notifications@github.com wrote:
|
Any news on this PR? |
Is there any chance of this making it into the trunk? |
+1 on this PR. |
PR Checklist (Minor Feature)
|
CLA is signed with "Jim Lyndon" |
Makes xhr status text accessible is $http success/error callback. See www.w3.org/TR/XMLHttpRequest/#dom-xmlhttprequest-statustext Closes angular#2335
Rebased and squashed against recent master. Travis pooped out with that NgClosureRunner dependency err, which appears to happen occasionally. Thanks |
Any updates on this? We are dealing with the same thing, need to display the status text in the UI. |
Why not expose the raw xhr object? It could be helpful to have access to other properties that live there. |
This isn't in 1.2.1? arrrgghhhh.... |
Just waiting for this, any update? Should I wait for 1.2.127? |
Wow 9 month and nobody seem to care |
I don't think it's worth worrying about adding statusText to the success/error callbacks, but I don't see any reason why we couldn't get this un-bitrotten and merge it. I was just investigating and most of it, apart from changes to Mocks, could be added in very few lines of code in httpBackend.js and http.js, and create a framework for further extensions in case other objects need to be exposed in the future. @jimlyndon do you want to fix this PR up a bit? otherwise I could put one together --- edit err, I didn't mean @lennybacon, sorry about that ;) |
+1 Let's get this thing going! |
Hey friends, yes this PR got the go ahead however there was a travis build issue and I couldn't get any eyeballs from the core team. I would love this to go in, but I'm absolutely slammed with work and real life at the moment (moving, wedding planning, you know how that goes). If someone wants to rebase what I have here, it's a few changes to http and backend. Cheers! |
Sure, I'll fix the bitrot |
Makes xhr status text accessible is $http success/error callback. See www.w3.org/TR/XMLHttpRequest/#dom-xmlhttprequest-statustext Closes #2335 Closes #2665 Closes #6713
Makes xhr status text accessible is $http success/error callback.
See www.w3.org/TR/XMLHttpRequest/#dom-xmlhttprequest-statustext
Closes #2335