显示临时标头和待处理请求

Tar*_*rik 10 javascript php google-chrome vue-resource

我有一个vue资源问题导致临时标题显示在chrome上,另一方面使用Jquery工作没有任何问题

问题只发生在chrome + vue-resource上

错误

复制链接

Chrome 57.0.2987 Windows 7

我没有安装adblock或origin,甚至在chrome上的访客模式下也会发生

一个简单的setInterval调用集

new Vue({

  el: '#main',

  data: {
    summary: null
  },
        methods: {
            updateSummary: function() {
      /*
                $.post( "summary.php", function( data ) {
                    if(typeof response.body.summary != 'undefined'){
                        this.summary = response.body.summary;
                    }
                });
        */
                this.$http.post('summary.php').then(function(response) {
                    if(typeof response.body.summary != 'undefined'){
                        this.summary = response.body.summary;
                    }
                });
            }
      },
        mounted: function () {
            this.updateSummary();

            setInterval(function () {
                this.updateSummary();
            }.bind(this), 2000);
        }
});
Run Code Online (Sandbox Code Playgroud)

https://jsfiddle.net/7vo2s8z3/1/

重现步骤

通常情况下,当我打开页面几个小时

什么是预期的?

提供内容的200代码响应

究竟发生了什么?

我收到了这些标题的请求

请求网址:http://127.0.0.1:8080 / monitor/summary.php推荐人政策:no-referrer-when-downgrade请求标题

临时标题显示为 Accept:application/json,text/plain,/ Content-Type:application/json; charset = utf-8来源:http ://127.0.0.1:8080参考文献:http://127.0.0.1:8080/monitor / User-Agent:Mozilla/5.0(Windows NT 6.1; WOW64)AppleWebKit/537.36(KHTML,与Gecko一样)Chrome/57.0.2987.133 Safari/537.36 X-Requested-With:XMLHttpRequest

看看chrome:// net-internals /#events失败的原因是

85487:URL_REQUEST http://127.0.0.1:8080/monitor/summary.php 开始时间:2017-04-18 09:38:43.826

t = 29028 [st = 0] + REQUEST_ALIVE [dt = 24184] - > priority ="MEDIUM" - > url =" http://127.0.0.1:8080/monitor/summary.php "t = 29029 [st = 1] + DELEGATE_INFO [dt = 24183] - > delegate_blocked_by ="RedirectToFileResourceHandler"t = 53211 [st = 24183] CANCELED - > net_error = -2(ERR_FAILED)t = 53212 [st = 24184] -REQUEST_ALIVE

lax*_*089 3

我相信当实际请求未发送时(通常是在加载缓存资源时)会发生这种情况。

基本上,您向端口 8080 发送了一个 POST 请求,这导致了“警告:显示临时标头”消息,如检查器中所示,然后该请求似乎被全部阻止了。

基于此,一种可能的解决方案是设置 nginx 来代理将请求从常用的 SSL 端口 443 传递到节点 SSL 端口 8080(节点必须位于更高的端口,因为它不能在产品中作为 root 运行)。我猜 Chrome 不喜欢对非常规 SSL 端口的 SSL 请求,尽管我绝对同意他们的错误消息可能更具体。