我注意到一个奇怪的警告信息,当使用谷歌chrome检查器(F12)查看下载的资源:

注意显示临时标题

我发现一些可能相关的东西,网络面板:添加临时请求头的警告,但我不能完全理解它。相关问题可以发现Chrome块请求以及XMLHttpRequest无法加载。未加载的资源显示警告:显示临时标头。

与第一个问题类似,我的资源被阻塞了,但后来自动加载了相同的资源。不像第二个问题,我不想解决任何问题;我想知道这条信息是什么意思以及我为什么收到它。


当前回答

在AJAX URL属性中发送参数时,我遇到了这个问题 http://10.165.10.160:82/services?param1=xxxx&param2=xxxx

如果你想执行一个get请求(例如发送参数化url),不要在url属性中添加它们,而是在数据对象中添加:

        <script>
        $.ajax({
        url: "http://10.160.10.160:82/services/STD_ERROR.php",
        data: {
            StatusText: StatusText,
            Status: Status,
            UserCode: UserCode,
            FUNC_CODE: FuncCode,
            ErrorDescription: ErrorDescription
        },
        type: "GET",
        crossDomain: true,
        cache: false
    }).done(data => {
        console.log(data)
    }).fail(function(xhr, status, error) {
        console.log(xhr.ErrorDescription)
    });
</script>

其他回答

如果响应无效并因此被浏览器删除,也会出现此警告消息。

在我的例子中,请求被正确地发送到服务器,服务器端代码随后产生一个错误,我的自定义错误处理在HTTP状态消息字段中返回错误消息。但是客户端没有收到此错误,因为错误消息中的无效字符(此处描述为http://aspnetwebstack.codeplex.com/workitem/1386)导致响应报头损坏。

我看到的另一种可能的情况是——在几毫秒后,完全相同的请求再次发送(很可能是由于客户端存在错误)。 在这种情况下,您还将看到第一个请求的状态是“取消”,并且延迟只有几毫秒。

当使用HSTS保护网站时,可能会出现此消息。然后,当有人链接到URL的HTTP版本时,浏览器根据HSTS的指示,不会发出HTTP请求,而是在内部安全地重定向到HTTPS资源。这是为了避免sslstrip等HTTPS降级攻击。

I've had this come up very recently (today in fact) where I've had an AJAX call go out to the server and Chrome fires off the "Caution: Provisional headers are shown." In the server side PHP scripting, there are MySQL queries that can be pretty much instant or take a few seconds depending on the given scenario. My server response isn't sent back to the browser until the queries are completed. I've found I get this error only when time consuming queries (up to a few seconds total) are being done and prevent the response from being sent back.

我的场景涉及到一个非常罕见的可能性,即必须通过添加/删除数百个天气模型输出列来更改一个表……因此,迭代ALTER TABLE查询循环会导致响应延迟。

当我发送无效的HTTP授权报头时,发生了这个问题。我忘记用base64编码了。