简体   繁体   English

如何在AngularJS中访问请求的HTTP标头

[英]How to access HTTP headers of request in AngularJS

I know I can access an HTTP request's GET parameters in AngularJS with 我知道我可以使用AngularJS访问HTTP请求的GET参数

$location.search().parameterOfInterest

But how do I access HTTP headers of the request? 但是,如何访问请求的HTTP标头?

I'm not using $http here. 我在这里不使用$ http。 I'm asking about request to an AngularJS web page. 我在询问对AngularJS网页的请求。

This question and answers makes me believe this is could be not possible: Accessing the web page's HTTP Headers in JavaScript 这个问题和答案使我相信这是不可能的: 在JavaScript中访问网页的HTTP标头

You can use a request interceptor that is called with an HTTP configuration object. 您可以使用通过HTTP配置对象调用的请求拦截器 An HTTP configuration object has a header property that you can freely access / modify inside your interceptor. HTTP配置对象具有标头属性,您可以在拦截器内部自由访问/修改。

The response object of promise also has a header property that you can access. promise响应对象还具有可以访问的标头属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM