Cant see headers of http post [Angular4]

亡梦爱人 提交于 2019-12-01 14:39:22

In order to expose this header to your Angular XHR, the server will need to set the Access-Control-Expose-Headers response header to allow specifically access to the Content-Disposition header. The docs have more information on the subject:

By default, only the 6 simple response headers are exposed:

  • Cache-Control
  • Content-Language
  • Content-Type
  • Expires
  • Last-Modified
  • Pragma

If you want clients to be able to access other headers, you have to list them using the Access-Control-Expose-Headers header.

This means that your server needs to set the following header:

Access-Control-Expose-Headers: Content-Disposition

In Angular, using HttpClient, the response headers are lazily parsed - To get a specific header's value, you'll need to to get the header using something like this:

res.headers.get('Content-Disposition');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!