$http - Getting all response headers

9,320 views
Skip to first unread message

mathi...@googlemail.com

unread,
Jun 7, 2012, 12:55:52 PM6/7/12
to ang...@googlegroups.com
I apologise if this has already been covered, but I have not been able to find an answer.

The $http service returns a promise object with success and error methods which in turn are passed arguments which include a function called headers()

To get a header, such as the response content-type, I need to call headers( "Content-Type" ). However, I am not concerned with individual headers and would just like to request all headers (like calling getAllResponseHeaders() on an XMLHttpRequest object).

Is this possible with AngularJS? It seems odd that the headers argument passed back through $http is a function to acquire individual headers, rather than a map of headers.

Vojta Jína

unread,
Jun 23, 2012, 4:28:42 AM6/23/12
to ang...@googlegroups.com
Just call headers() without argument, will give you a hash object will all headers parsed and normalized.

V.


--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/7khd9yQ7qqYJ.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.

Malla Ayyappa

unread,
Jul 29, 2015, 3:11:05 AM7/29/15
to AngularJS, vojta...@gmail.com
then we are get only two properties

Object {content-type: "application/json; charset=utf-8", cache-control: "max-age=0, private, must-revalidate"}
Reply all
Reply to author
Forward
0 new messages