简体   繁体   English

从HTTP请求获取自定义响应头

[英]Get custom response header from HTTP request

I am fully aware this question has been posted multiple times in the past, but I can't figure it out how to fix my issue. 我完全知道这个问题过去曾多次发布,但我不知道该如何解决。 I do a HEAD request using AJAX and get some data back in the header response, in a custom field. 我使用AJAX进行HEAD请求,并在自定义字段中的标头响应中获取了一些数据。

What I'm trying to do is: 我想做的是:

jqXHR.getResponseHeader("Metadata"); 

Metadata is the custom field in the header. 元数据是标题中的自定义字段。 However, this always comes back as null, even though I see it in Firebug. 但是,即使我在Firebug中看到了它,也总是返回null。 The response is a JSON. 响应是一个JSON。

What can I do to fix this? 我该怎么做才能解决此问题?

addHeader("Access-Control-Expose-Headers", "Custom-Header"); 

如果有人遇到问题,这是Java中的修复程序。

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

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