RESTful API の「X-Total-Count」応答ヘッダーを取得したいと考えています。ngResource 'User' のクエリ コールバック関数でヘッダーを取得しようとしているときに、$http が多くの応答ヘッダーを無視しているようです。
これらは私のリクエストの応答ヘッダーです:
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
ここでは、一連のユーザーをクエリしています。
User.query({
page: $scope.pagingOptions.currentPage,
limit: $scope.pagingOptions.pageSize
}, function(users, responseHeaders) {
console.log(responseHeaders());
console.log(responseHeaders('X-Total-Count'));
});
それがコンソールの結果です:
Object { cache-control="max-age=0, private, must-revalidate", content-type="application/json; charset=utf-8"}
null
では、なぜ $http の responseHeaders() 関数は 10 個のヘッダー プロパティのうち 2 個しか変換しないのでしょうか?