1

I have an interceptor using $httpProvider as follwos (taken from Angular doc)

$httpProvider.interceptors.push(function ($q) {
        return {
            'response': function (response) {
                // look for the antiforgerytoken and update dataService with the same.

                return response || $q.when(response);
        }
    };
});

using the debugger I see that this method is called on each response and when I look at the 'response' object pased I see only one header, namely the Accept-Header as shown below

response object passed in the code

When I look at the response packet in the chrome I see many more headers

Network packet as seen in chrome

My question is why am I not able to see all the headers in the response?

Specifically I want to read the cookie for AntiforgeryToken and store it, how can I do that?

indichimp
  • 1,152
  • 2
  • 13
  • 22
  • possible duplicate of [Can't Get Custom HTTP Header Response from Ajax getAllResponseHeaders](http://stackoverflow.com/questions/15042439/cant-get-custom-http-header-response-from-ajax-getallresponseheaders) – blueberryfields Mar 31 '14 at 08:01
  • @blueberryfields not duplicate, I am not using CORS and I am not required to do anything special at the server. In my case the server is already sending the header I need, I just don's seem to know the way to get to that information. I want to know how to read all the headers in an interceptor. – indichimp Mar 31 '14 at 08:06

1 Answers1

0

I believe the cookie AntiforgeryToken is a HttpOnly cookie and cannot be accessed from javascript. Can you check

See some details here http://blog.codinghorror.com/protecting-your-cookies-httponly/

Such cookies are mean for server exclusively.

Chandermani
  • 42,589
  • 12
  • 85
  • 88