From 1d735b14b208718aae8b24a690f9bfaa054b1fc1 Mon Sep 17 00:00:00 2001 From: Cory Boyd Date: Tue, 10 Jun 2014 20:10:43 -0700 Subject: [PATCH 1/2] docs($httpProvider): add documentation Add documentation for $httpProvider default values Closes #6682 --- src/ng/http.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/ng/http.js b/src/ng/http.js index 738d1cd12cfc..ba0e1e126af6 100644 --- a/src/ng/http.js +++ b/src/ng/http.js @@ -83,6 +83,24 @@ function isSuccess(status) { } +/** + * @ngdoc provider + * @name $httpProvider + * + * @description + * Use `$httpProvider` to change the default behavior of the `$http` service. + * + * @property {Object} defaults Default attributes for {@link ng.$http $http} service. + * + * @property {string} defaults.xsrfHeaderName Name of HTTP header to populate with the XSRF + * token. Defaults value is `'X-XSRF-TOKEN'` + * + * @property {string} defaults.xsrfCookieName Name of cookie containing the XSRF token. + * Defaults value is `'XSRF-TOKEN'` + * + * @property {Object} defaults.headers Set default headers for all $http requests. Refer to + * {@link ng.$http#setting-http-headers $http} for documentation about setting default headers. + * */ function $HttpProvider() { var JSON_START = /^\s*(\[|\{[^\{])/, JSON_END = /[\}\]]\s*$/, From ea227d953721682c3e9f3f3d77fd7b211d9b7b9e Mon Sep 17 00:00:00 2001 From: Cory Boyd Date: Tue, 10 Jun 2014 23:44:14 -0700 Subject: [PATCH 2/2] docs($httpProvider): move default property docs to related object As suggested, move the documentation for the defaults object. --- src/ng/http.js | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/ng/http.js b/src/ng/http.js index ba0e1e126af6..96eeded61046 100644 --- a/src/ng/http.js +++ b/src/ng/http.js @@ -86,20 +86,8 @@ function isSuccess(status) { /** * @ngdoc provider * @name $httpProvider - * * @description - * Use `$httpProvider` to change the default behavior of the `$http` service. - * - * @property {Object} defaults Default attributes for {@link ng.$http $http} service. - * - * @property {string} defaults.xsrfHeaderName Name of HTTP header to populate with the XSRF - * token. Defaults value is `'X-XSRF-TOKEN'` - * - * @property {string} defaults.xsrfCookieName Name of cookie containing the XSRF token. - * Defaults value is `'XSRF-TOKEN'` - * - * @property {Object} defaults.headers Set default headers for all $http requests. Refer to - * {@link ng.$http#setting-http-headers $http} for documentation about setting default headers. + * Use `$httpProvider` to change the default behavior of the {@link ng.$http $http} service. * */ function $HttpProvider() { var JSON_START = /^\s*(\[|\{[^\{])/, @@ -107,8 +95,28 @@ function $HttpProvider() { PROTECTION_PREFIX = /^\)\]\}',?\n/, CONTENT_TYPE_APPLICATION_JSON = {'Content-Type': 'application/json;charset=utf-8'}; + /** + * @ngdoc property + * @name $httpProvider#defaults + * @description + * + * Object containing default values for all {@link ng.$http $http} requests. + * + * - **`defaults.xsrfCookieName`** - {string} - Name of cookie containing the XSRF token. + * Defaults value is `'XSRF-TOKEN'`. + * + * - **`defaults.xsrfHeaderName`** - {string} - Name of HTTP header to populate with the + * XSRF token. Defaults value is `'X-XSRF-TOKEN'`. + * + * - **`defaults.headers`** - {Object} - Default headers for all $http requests. + * Refer to {@link ng.$http#setting-http-headers $http} for documentation on + * setting default headers. + * - **`defaults.headers.common`** + * - **`defaults.headers.post`** + * - **`defaults.headers.put`** + * - **`defaults.headers.patch`** + * */ var defaults = this.defaults = { - // transform incoming response data transformResponse: [function(data) { if (isString(data)) { // strip json vulnerability protection prefix @@ -124,7 +132,6 @@ function $HttpProvider() { return isObject(d) && !isFile(d) && !isBlob(d) ? toJson(d) : d; }], - // default headers headers: { common: { 'Accept': 'application/json, text/plain, */*'