gpt4 book ai didi

internet-explorer - IE 接受标题更改,为什么?

转载 作者:可可西里 更新时间:2023-11-01 15:27:13 24 4
gpt4 key购买 nike

我正在尝试在我的服务器端调试一个问题,我相信它与从浏览器发送的接受 header 有关。这是我的问题,为什么 Internet Explorer 会将“接受”标题从一个页面更改为另一个页面?我可以从 javascript 更改请求 header 吗?

这是一个页面的请求:

Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-application, application/x-shockwave-flash, */*

这是来自另一个页面的请求:

Accept: */*

它们都是 GET 请求,我看到内容之间有任何重大差异。所有服务均来自同一应用程序服务器 (Websphere)。

最佳答案

IE 的接受头

根据 this blog post from an IE developer , IE 与其 Accept header “不一致”。它解释了您看到的额外值来自注册表项,应用程序可以将其内容类型添加到该注册表项中,但没有解释为什么并不总是使用此注册表项中的值:

However, in some navigations, you’ll see that IE sends a more complete string, containing a wide variety of MIME-types. For instance:

image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/msword, application/vnd.ms-excel, application/x-shockwave-flash, */*

Hit F5 to refresh that page, and IE will probably go back to sending / again. Clearly, IE is inconsistent in what it chooses to send in the Accept header, but by now you’re probably curious where these MIME types even come from.

IE generates this list by enumerating the values listed in the following registry key:

HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Accepted Documents

知道这一点可能并不能真正解决您的问题。但是请注意 */* 仍然出现在两个 Accept header 中,因此就内容协商而言,这里应该没有问题。但是,添加到 header 的额外类型可能会使请求过大,因此您可能会从哪里开始寻找线索。

用JavaScript修改请求头

您可以使用 XMLHttpRequest.setRequestHeader() 方法修改异步 (XMLHttpRequest) 请求的 header ,详见 this page .

另请参阅此问题:Adding custom HTTP headers using JavaScript

免责声明:我没有尝试将它用于 Accept header 。

但是,如果您要控制的请求不是 AJAX 请求,我不知道您可以用 JavaScript 修改这些请求。

很抱歉,我无法为您的两个问题提供完整的答案,但我希望我提供的信息对您有所帮助。

关于internet-explorer - IE 接受标题更改,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1670329/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com