为什么Internet Explorer中没有发生故障后发送HTTP POST体的Ajax调用? [英] Why does Internet Explorer not send HTTP post body on Ajax call after failure?

查看:271
本文介绍了为什么Internet Explorer中没有发生故障后发送HTTP POST体的Ajax调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们能够可靠地重新创建以下情形:

We are able to reliably recreate the following scenario:

  1. 创建一个小的HTML页面,使得AJAX请求到服务器(使用HTTP POST)
  2. 从网络上断开并重新连接
  3. 在监视IE浏览器故障
  4. 在生成包

失败的网络连接后,IE浏览器,使下一个Ajax请求,但只发送 HTTP头(不是身体)做HTTP帖子的时候。这会导致各种服务器上的问题,因为它是唯一一个局部请求。谷歌这个问题,必应,你会发现很多人抱怨使用AJAX随机服务器错误或无法解释的AJAX故障。

After a failed network connection, IE makes the next AJAX request but only sends the HTTP header (not the body) when doing the HTTP post. This causes all sorts of problems on the server as it is only a partial request. Google this issue with Bing and you'll find lots of people complaining about "random server errors" using AJAX or unexplained AJAX failures.

我们知道,IE浏览器(与大多数其他浏览器)总是发送一个HTTP POST两个TCP / IP数据包。头和正文分开发送。在发生故障后,直接的情况下, IE浏览器只发送标题

We know that IE (unlike most other browsers) always sends an HTTP POST as TWO TCP/IP packets. The header and body is sent separately. In the case directly after a failure, IE only sends the header.

所以我的问题是 - 为什么它的行为这样?它似乎是错误的基于HTTP规范和其他浏览器不行为这种方式。这纯粹是一个错误吗?当然,这在任何严肃的基于AJAX的Web应用程序创建的破坏。

So my question is - why does it behave this way? It seems wrong based on the HTTP spec and other browsers don't behave this way. Is it simply a bug? Surely this creates havoc in any serious AJAX based Web application.

参考信息:

有类似的问题,通过HTTP保持活动超时是短于1分钟,在这里进行了说明触发:

There is a similar problem, triggered by HTTP keep-alive timeouts that are shorter than 1 minute and is documented here:

<一个href="http://us.generation-nt.com/xmlhtt$p$pquest-post-sometimes-fails-when-server-using-keep-aliv-help-188813541.html">http://us.generation-nt.com/xmlhtt$p$pquest-post-sometimes-fails-when-server-using-keep-aliv-help-188813541.html

<一个href="http://support.microsoft.com/default.aspx?kbid=831167">http://support.microsoft.com/default.aspx?kbid=831167

下面是之前和失败的数据包捕获后:

Here are the before and after failure packet captures:

请注意HTTP报头和有效载荷发送 http://img827.imageshack.us/i/beforee.png/

Notice how the HTTP Header and Payload is sent http://img827.imageshack.us/i/beforee.png/

出现故障后,注意头是如何只派。 IE浏览器的永远的发送有效载荷和服务器最终以超时响应。 http://img203.imageshack.us/i/retryt.png/

After a failure, notice how only the Header is sent. IE never sends the payload and the server eventually responds with a Timeout. http://img203.imageshack.us/i/retryt.png/

推荐答案

似乎没有成为一个明确的回答这个问题,所以我会提供我的经验数据作为替代品,并提供一些方法来解决它。也许有些MS内幕总有一天会提供一些​​线索就这样...

There does not seem to be a clear answer to this question, so I will provide my empirical data as a substitute and provide some ways to work around it. Maybe some MS insider will one day shed some light on this...

  1. 如果HTTP保持活动是禁用在服务器上,这个问题就会消失。换句话说,你的HTTP 1.1服务器将响应每一个Ajax请求与连接:在响应关闭行。这样可以使IE开心,但会导致每一个Ajax请求打开一个新的连接。这可以有显著的性能影响,尤其是在高延迟网络。

  1. If HTTP Keep-Alive is disabled on the server, this issue goes away. In other words, your HTTP 1.1 server will respond to every Ajax request with a Connection: Close line in the response. This keeps IE happy but causes every Ajax request to open a new connection. This can have a significant performance impact, especially on high latency networks.

这个问题很容易触发,如果Ajax请求的快速连续进行。例如,我们发出Ajax请求每100ms,然后在网络状态更改,错误很容易繁殖。虽然大多数应用程序可能不会做出这样的请求,你很可能有几个服务器调用后,对方可能导致这个问题发生的权利。少健谈保持IE开心。

The issue is triggered easily if Ajax requests are made in rapid succession. For example, we make Ajax requests every 100ms and then the network status changes, the error is easy to reproduce. Although most applications probably do not make such requests, you might well have a couple of server calls happening right after each other which could lead to this problem. Less chatty keeps IE happy.

它发生,即使没有NTLM身份验证。

It happens even without NTLM authentication.

它发生在你的HTTP保持活动超时在服务器上比默认短(默认为60秒在Windows上)。详细信息在提问环节提供的。

It happens when your HTTP keep-alive timeout on the server is shorter than the default (which defaults to 60 seconds on Windows). Details provided in link in question.

这不会发生与Chrome或Firefox浏览器。 FF发送一个数据包等等,似乎完全避免这个问题。

It does not happen with Chrome or Firefox. FF sends one packet so seems to avoid this issue altogether.

它发生在IE 6,7,8,无法复制与IE 9测试版。

It happens in IE 6, 7, 8. Could not reproduce with IE 9 beta.

这篇关于为什么Internet Explorer中没有发生故障后发送HTTP POST体的Ajax调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆