@@ -92,16 +92,17 @@ function headersGetter(headers) {
9292 * This function is used for both request and response transforming
9393 *
9494 * @param {* } data Data to transform.
95- * @param {function(string=) } headers Http headers getter fn.
95+ * @param {function(string=) } headers HTTP headers getter fn.
96+ * @param {number } status HTTP status code of the response.
9697 * @param {(Function|Array.<Function>) } fns Function or an array of functions.
9798 * @returns {* } Transformed data.
9899 */
99- function transformData ( data , headers , fns ) {
100+ function transformData ( data , headers , status , fns ) {
100101 if ( isFunction ( fns ) )
101- return fns ( data , headers ) ;
102+ return fns ( data , headers , status ) ;
102103
103104 forEach ( fns , function ( fn ) {
104- data = fn ( data , headers ) ;
105+ data = fn ( data , headers , status ) ;
105106 } ) ;
106107
107108 return data ;
@@ -380,7 +381,7 @@ function $HttpProvider() {
380381 *
381382 * Both requests and responses can be transformed using transformation functions: `transformRequest`
382383 * and `transformResponse`. These properties can be a single function that returns
383- * the transformed value (`{function(data, headersGetter)`) or an array of such transformation functions,
384+ * the transformed value (`{function(data, headersGetter, status )`) or an array of such transformation functions,
384385 * which allows you to `push` or `unshift` a new transformation function into the transformation chain.
385386 *
386387 * ### Default Transformations
@@ -624,9 +625,9 @@ function $HttpProvider() {
624625 * See {@link ng.$http#overriding-the-default-transformations-per-request
625626 * Overriding the Default Transformations}
626627 * - **transformResponse** –
627- * `{function(data, headersGetter)|Array.<function(data, headersGetter)>}` –
628+ * `{function(data, headersGetter, status )|Array.<function(data, headersGetter, status )>}` –
628629 * transform function or an array of such functions. The transform function takes the http
629- * response body and headers and returns its transformed (typically deserialized) version.
630+ * response body, headers and status and returns its transformed (typically deserialized) version.
630631 * See {@link ng.$http#overriding-the-default-transformations-per-request
631632 * Overriding the Default Transformations}
632633 * - **cache** – `{boolean|Cache}` – If true, a default $http cache will be used to cache the
@@ -765,7 +766,7 @@ function $HttpProvider() {
765766
766767 var serverRequest = function ( config ) {
767768 var headers = config . headers ;
768- var reqData = transformData ( config . data , headersGetter ( headers ) , config . transformRequest ) ;
769+ var reqData = transformData ( config . data , headersGetter ( headers ) , undefined , config . transformRequest ) ;
769770
770771 // strip content-type if data is undefined
771772 if ( isUndefined ( reqData ) ) {
@@ -826,7 +827,7 @@ function $HttpProvider() {
826827 if ( ! response . data ) {
827828 resp . data = response . data ;
828829 } else {
829- resp . data = transformData ( response . data , response . headers , config . transformResponse ) ;
830+ resp . data = transformData ( response . data , response . headers , response . status , config . transformResponse ) ;
830831 }
831832 return ( isSuccess ( response . status ) )
832833 ? resp
0 commit comments