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

feat($http): add option for unsafe xhr requests in FirefoxOS #7903

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/ng/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,8 @@ function $HttpProvider() {
* for more information.
* - **responseType** - `{string}` - see
* [requestType](https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#responseType).
* - **xhrConfig** - `{Object}` - config pass to XMLHttpRequest. See
* [XMLHttpRequest()](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#XMLHttpRequest())
*
* @returns {HttpPromise} Returns a {@link ng.$q promise} object with the
* standard `then` method and two http specific methods: `success` and `error`. The `then`
Expand Down Expand Up @@ -889,7 +891,7 @@ function $HttpProvider() {
}

$httpBackend(config.method, url, reqData, done, reqHeaders, config.timeout,
config.withCredentials, config.responseType);
config.withCredentials, config.responseType, config.xhrConfig);
}

return promise;
Expand Down
9 changes: 6 additions & 3 deletions src/ng/httpBackend.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
'use strict';

function createXhr(method) {
function createXhr(method, config) {
//if IE and the method is not RFC2616 compliant, or if XMLHttpRequest
//is not available, try getting an ActiveXObject. Otherwise, use XMLHttpRequest
//if it is available
if (msie <= 8 && (!method.match(/^(get|post|head|put|delete|options)$/i) ||
!window.XMLHttpRequest)) {
return new window.ActiveXObject("Microsoft.XMLHTTP");
} else if (window.XMLHttpRequest) {
if (isObject(config)) {
return new window.XMLHttpRequest(config);
}
return new window.XMLHttpRequest();
}

Expand Down Expand Up @@ -40,7 +43,7 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
var ABORTED = -1;

// TODO(vojta): fix the signature
return function(method, url, post, callback, headers, timeout, withCredentials, responseType) {
return function(method, url, post, callback, headers, timeout, withCredentials, responseType, xhrConfig) {
var status;
$browser.$$incOutstandingRequestCount();
url = url || $browser.url();
Expand All @@ -59,7 +62,7 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
});
} else {

var xhr = createXhr(method);
var xhr = createXhr(method, xhrConfig);

xhr.open(method, url, true);
forEach(headers, function(value, key) {
Expand Down