-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feat($http): add option for unsafe xhr requests in FirefoxOS #7903
Conversation
@@ -8,7 +8,7 @@ function createXhr(method) { | |||
!window.XMLHttpRequest)) { | |||
return new window.ActiveXObject("Microsoft.XMLHTTP"); | |||
} else if (window.XMLHttpRequest) { | |||
return new window.XMLHttpRequest(); | |||
return new window.XMLHttpRequest(config); |
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 will possibly cause IDL arity errors in other browsers...
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.
not chromium at least =) a lot of the blink bindings will throw when the arity does not match though.... Guess that doesn't apply to constructors
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.
I didn't know that was a thing :(. Better safe than sorry, so have updated. Thanks for the feedback :)
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.
nah I wouldn't worry about it if tests are passing
Previously, it was not possible to pass settings to the constructor of the XMLHttpRequest. This adds an optional config property `xhrConfig` to the $http constructor, allowing us to do so. This is required for use of the mozAnon and mozSystem options for FirefoxOS. See https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#XMLHttpRequest() for details. Closes angular#2318
Related jQuery bug http://bugs.jquery.com/ticket/13394 (their resolution doesn't really apply here since we don't have a similar mechanism yet) |
Anyways, we probably should have something like |
Oh.. Damit.. Didn't see this before I just submitted my own pull request #7906. Sorry for the duplicate. We have actually made quite identical solutions. Only difference I can see is that I called it |
The jQuery xhrFields stuff is a bit different, though --- they don't pass the object to the constructor, but instead this: https://github.com/jquery/jquery/blob/01c360f96390ff16edfe65ef3b34e167087ef645/src/ajax/xhr.js#L51-L55 |
I think we need something like that, as well as a way to have defaults which are applied to all XHR objects, as well as per-request xhrFields, similar to our headers strategy. That would make more sense IMO. |
The problem with that approach is that it doesn't actually work since the |
That sounds like a bug you should file on b2g, because the problem with this is that the XHR constructor isn't normally supposed to take any parameters, but if one extension to it wants to add custom parameters, what if another one does too which behaves differently? The whole thing is a mess. Anyways, this is the solution suggested by the jQuery team, so it was probably valid and tested at some point. |
Yes, you I right. And I agree that it would be a better solution. I'm double-checking my statement and will check if making a jQuery ajax request actually works on Firefox OS. I'll post back with my findings. |
I have verified my findings. It doesn't work with the current implementation by jQuery either. This is also backed up by this bug report: http://bugs.jquery.com/ticket/13862. Don't know if that is something you guys would consider as well. It would sure make mocking the XMLHttpRequest object a lot simpler.. |
@caitp: So it seems this one stalled since passing arguments to a constructor that is not supposed to take one is a bad idea and should really be fixed by Mozilla B2G. But maybe you would be willing to accept a workaround that lets you pass in your own createXhr method instead. In other words the same thing jQuery offers with its If so I could probably make a PR for it. |
I don't see a problem with allowing custom |
hello, change jquery to angular in my application, but do not know how this property is added to the service $http, was something in jquery: my english is bad. |
@ripper2hl there's no way in angular to do this currently... I guess I could submit a patch for it... but frankly the B2G people should just get their act together and not use a different function signature from the interoperable XHR api |
It is sad to know that the standard is not followed, if you send the patch would be a great help, thanks for the information. |
I started on a fix here: https://github.com/sjurba/angular.js/tree/createXhr The implementation is simple enough, but it kinda cries for some refactoring.. But I'm not quite sure how to approach that. What's best for you? Should I just create a pull request for what I got so far and start a discussion there? |
02dc2aa
to
fd2d6c0
Compare
@sjurba Sorry for the late response, but yes, sending a PR is a good idea |
No worries. I've been busy elsewhere.. I'll dig back into it later this evening/afternoon.. — On Sun, Sep 28, 2014 at 1:42 PM, Narretz notifications@github.com wrote:
|
Ok, PR #9319 is sent.. |
e8dc429
to
e83fab9
Compare
4dd5a20
to
998c61c
Compare
This one looks a lot like #7906 and that one was closed in favour of the more generic approach. Currently we've got a PR for a more flexible approach (#9319) but I'm not super-happy with it either... Anyway, closing this one as almost identical #7906 was closed. Let's focus on solving it in a more flexible way. |
Previously, it was not possible to pass settings to the constructor of the XMLHttpRequest. This
adds an optional config property
xhrConfig
to the $http constructor, allowing us to do so. Thisis required for use of the mozAnon and mozSystem options for FirefoxOS.
See https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#XMLHttpRequest() for details.
Closes #2318