Angular JS HTTP Response标头无法在Safari上运行

时间:2017-05-15 13:04:57

标签: angularjs safari http-headers httpresponse

我遇到了一个问题,我发布了一个对象,作为回应,我应该从HTTP响应中获取一些标头。问题是这个代码在Chrome,Firefox,IE等浏览器中运行良好,但在Safari(Windows)的情况下返回null

 $http.post(url, data)
         .then(function(response){
                console.log(response.headers("location"));
                // response.headers("location") is null in Safari
         });

以下是我从服务器获取的响应标头。

Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:http://localhost:5000
Access-Control-Expose-Headers:ETag,Location
Content-Length:0
Date:Mon, 15 May 2017 12:46:14 GMT
Location: //my API
Server:Microsoft-IIS/8.5
X-Powered-By:ASP.NET

1 个答案:

答案 0 :(得分:0)

也许您的safari是一个旧版本,根据旧的建议工作,每个自定义标头必须以X-为前缀 看到这个链接: enter link description here