aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng
diff options
context:
space:
mode:
authorVojta Jina2012-04-03 11:00:52 -0700
committerVojta Jina2012-04-04 16:13:02 -0700
commit86182a9415b9209662b16c25c180b958ba7e6cf9 (patch)
tree18661207396b5da54658676233ff0e15c6d975fc /src/ng
parent15ecc6f3668885ebc5c7130dd34e00059ddf79ae (diff)
downloadangular.js-86182a9415b9209662b16c25c180b958ba7e6cf9.tar.bz2
feat($http): add withCredentials config option
Diffstat (limited to 'src/ng')
-rw-r--r--src/ng/http.js6
-rw-r--r--src/ng/httpBackend.js6
2 files changed, 10 insertions, 2 deletions
diff --git a/src/ng/http.js b/src/ng/http.js
index 9c4dafd4..3942c5c7 100644
--- a/src/ng/http.js
+++ b/src/ng/http.js
@@ -375,6 +375,9 @@ function $HttpProvider() {
* {@link angular.module.ng.$cacheFactory $cacheFactory}, this cache will be used for
* caching.
* - **timeout** – `{number}` – timeout in milliseconds.
+ * - **withCredentials** - `{boolean}` - whether to to set the `withCredentials` flag on the
+ * XHR object. See {@link https://developer.mozilla.org/en/http_access_control#section_5
+ * requests with credentials} for more information.
*
* @returns {HttpPromise} Returns a {@link angular.module.ng.$q promise} object with the
* standard `then` method and two http specific methods: `success` and `error`. The `then`
@@ -674,7 +677,8 @@ function $HttpProvider() {
// if we won't have the response in cache, send the request to the backend
if (!cachedResp) {
- $httpBackend(config.method, url, reqData, done, reqHeaders, config.timeout);
+ $httpBackend(config.method, url, reqData, done, reqHeaders, config.timeout,
+ config.withCredentials);
}
return promise;
diff --git a/src/ng/httpBackend.js b/src/ng/httpBackend.js
index abe1d8f5..b2c14b3f 100644
--- a/src/ng/httpBackend.js
+++ b/src/ng/httpBackend.js
@@ -32,7 +32,7 @@ function $HttpBackendProvider() {
function createHttpBackend($browser, XHR, $browserDefer, callbacks, body, locationProtocol) {
// TODO(vojta): fix the signature
- return function(method, url, post, callback, headers, timeout) {
+ return function(method, url, post, callback, headers, timeout, withCredentials) {
$browser.$$incOutstandingRequestCount();
url = url || $browser.url();
@@ -71,6 +71,10 @@ function createHttpBackend($browser, XHR, $browserDefer, callbacks, body, locati
}
};
+ if (withCredentials) {
+ xhr.withCredentials = true;
+ }
+
xhr.send(post || '');
if (timeout > 0) {