【问题标题】:Angular JS HTTP Response header not working on SafariAngular JS HTTP 响应标头在 Safari 上不起作用
【发布时间】:2017-10-14 06:54:56
【问题描述】:

我在发布对象时遇到问题,作为响应,我应该从 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

【问题讨论】:

    标签: angularjs safari http-headers httpresponse


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-20
      • 1970-01-01
      • 2020-10-22
      • 2014-12-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多