• <bdo id='ti8dw'></bdo><ul id='ti8dw'></ul>

    <i id='ti8dw'><tr id='ti8dw'><dt id='ti8dw'><q id='ti8dw'><span id='ti8dw'><b id='ti8dw'><form id='ti8dw'><ins id='ti8dw'></ins><ul id='ti8dw'></ul><sub id='ti8dw'></sub></form><legend id='ti8dw'></legend><bdo id='ti8dw'><pre id='ti8dw'><center id='ti8dw'></center></pre></bdo></b><th id='ti8dw'></th></span></q></dt></tr></i><div id='ti8dw'><tfoot id='ti8dw'></tfoot><dl id='ti8dw'><fieldset id='ti8dw'></fieldset></dl></div>
    <tfoot id='ti8dw'></tfoot>

    <small id='ti8dw'></small><noframes id='ti8dw'>

      <legend id='ti8dw'><style id='ti8dw'><dir id='ti8dw'><q id='ti8dw'></q></dir></style></legend>
    1. XHR HEAD 请求是否有可能不遵循重定向 (301 302)

      时间:2023-10-15

      <i id='uSzGn'><tr id='uSzGn'><dt id='uSzGn'><q id='uSzGn'><span id='uSzGn'><b id='uSzGn'><form id='uSzGn'><ins id='uSzGn'></ins><ul id='uSzGn'></ul><sub id='uSzGn'></sub></form><legend id='uSzGn'></legend><bdo id='uSzGn'><pre id='uSzGn'><center id='uSzGn'></center></pre></bdo></b><th id='uSzGn'></th></span></q></dt></tr></i><div id='uSzGn'><tfoot id='uSzGn'></tfoot><dl id='uSzGn'><fieldset id='uSzGn'></fieldset></dl></div>

        • <bdo id='uSzGn'></bdo><ul id='uSzGn'></ul>

            <small id='uSzGn'></small><noframes id='uSzGn'>

            <tfoot id='uSzGn'></tfoot>
              <tbody id='uSzGn'></tbody>

                <legend id='uSzGn'><style id='uSzGn'><dir id='uSzGn'><q id='uSzGn'></q></dir></style></legend>
              • 本文介绍了XHR HEAD 请求是否有可能不遵循重定向 (301 302)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                是否可以发送 xhr HTTP HEAD 请求以仅获取第一个请求的标头响应,而不像重定向一样自动遵循 301、302?我只对获取 url 的新位置感兴趣.示例:

                Is it possible to send an xhr HTTP HEAD request to only get header response for the first request and not automatically follow 301, 302 like redirects? I'm only interested in getting the new location of the url. Example:

                var xhr = new XMLHttpRequest();
                xhr.onreadystatechange = function(data) {
                    if (xhr.readyState == 4) {
                        if (xhr.status == 301 || xhr.status == 302) {
                            // Get new location url don't GET it
                        }
                    }
                };
                xhr.open('HEAD', url, true);
                xhr.send();
                

                http://www.w3.org/TR/XMLHttpRequest/#infrastructure-for-the-send-method 似乎指定应遵循请求,有没有办法阻止它?

                http://www.w3.org/TR/XMLHttpRequest/#infrastructure-for-the-send-method seems to specify that requests should be followed, is there a way to stop this?

                推荐答案

                没有,这不是你可以阻止的暴露行为.

                There isn't, this isn't exposed behavior you can stop.

                这是因为 您已经链接的规范,指定的行为是 XmlHttpRequest 应该透明地遵循重定向...不幸的是,在幕后,而不是你可以阻止的方式.

                It's because of the spec you linked already, the specified behavior is that XmlHttpRequest should transparently follow redirects...under the covers unfortunately, and not in a way you can prevent.

                这种方式可以尝试让事情变得更容易,如果资源移动等...但是在设计和制定规范时,所有这些重定向服务都不存在.只是没有强烈需要任何其他行为或能力来阻止它,我认为随着网络上的重定向越来越多,我们不会看到添加的能力,但谁知道每个浏览器何时会支持它.

                It's this way to try and make things easier, if resources move, etc...but when it was designed and the spec laid out, all these redirection services weren't out there. There just wasn't a strong need for any other behavior or ability to prevent it, I think with as many redirects hitting the web not we'll see the ability added, but who knows when every browser would support it.

                这篇关于XHR HEAD 请求是否有可能不遵循重定向 (301 302)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:NETWORK_ERROR:XMLHttpRequest 异常 101 下一篇:XMLHttpRequest 无法加载,请求的资源上不存在“A

                相关文章

                最新文章

                    <tfoot id='BcYQn'></tfoot>

                      <bdo id='BcYQn'></bdo><ul id='BcYQn'></ul>

                    <i id='BcYQn'><tr id='BcYQn'><dt id='BcYQn'><q id='BcYQn'><span id='BcYQn'><b id='BcYQn'><form id='BcYQn'><ins id='BcYQn'></ins><ul id='BcYQn'></ul><sub id='BcYQn'></sub></form><legend id='BcYQn'></legend><bdo id='BcYQn'><pre id='BcYQn'><center id='BcYQn'></center></pre></bdo></b><th id='BcYQn'></th></span></q></dt></tr></i><div id='BcYQn'><tfoot id='BcYQn'></tfoot><dl id='BcYQn'><fieldset id='BcYQn'></fieldset></dl></div>
                    <legend id='BcYQn'><style id='BcYQn'><dir id='BcYQn'><q id='BcYQn'></q></dir></style></legend>

                    <small id='BcYQn'></small><noframes id='BcYQn'>