Angular $ http does not include all response headers

I would like to get the "X-Total-Count" RESTful API response header. When trying to get the header in my user's ngResource request callback function, it seems like $ http is ignoring a lot of response headers.

These are the response headers of my request:

Access-Control-Allow-Origin: *
Cache-Control: max-age=0, private, must-revalidate
Connection: close
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Date: Fri, 17 Oct 2014 11:13:26 GMT
Link: <http://xxxx.xxx/user?page=2>; rel="next"
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-Total-Count: 32

      

Here I am asking for a set of users:

User.query({
    page: $scope.pagingOptions.currentPage, 
    limit: $scope.pagingOptions.pageSize
}, function(users, responseHeaders) {
    console.log(responseHeaders());
    console.log(responseHeaders('X-Total-Count'));
});

      

Console result:

Object { cache-control="max-age=0, private, must-revalidate", content-type="application/json; charset=utf-8"}
null

      

So why does the $ http responseHeaders () function only turn 2 out of 10 header properties?

+3


source to share


1 answer


Are you sure you are not using Cross Source resource sharing?

see 7.1.1 Handling the Cross-Origin Request Response



This specification prohibits access to any response header field other than simple response header fields (i.e. Cache-Control, Content-Type, ...)

0


source







All Articles