From 354da864feefa4c244df005eb683bde5e8ef96a4 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Thu, 20 Apr 2006 03:39:50 +0000 Subject: [PATCH] Don't throw when status is gotten after a server timeout or some such. Bug 304980, r=darin, sr=jst git-svn-id: svn://10.0.0.236/trunk@194939 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsXMLHttpRequest.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mozilla/content/base/src/nsXMLHttpRequest.cpp b/mozilla/content/base/src/nsXMLHttpRequest.cpp index 2c2798c6105..4c42ec4acff 100644 --- a/mozilla/content/base/src/nsXMLHttpRequest.cpp +++ b/mozilla/content/base/src/nsXMLHttpRequest.cpp @@ -630,7 +630,21 @@ nsXMLHttpRequest::GetStatus(PRUint32 *aStatus) nsCOMPtr httpChannel = GetCurrentHttpChannel(); if (httpChannel) { - return httpChannel->GetResponseStatus(aStatus); + nsresult rv = httpChannel->GetResponseStatus(aStatus); + if (rv == NS_ERROR_NOT_AVAILABLE) { + // Someone's calling this before we got a response... Check our + // ReadyState. If we're at 3 or 4, then this means the connection + // errored before we got any data; return a somewhat sensible error code + // in that case. + PRInt32 readyState; + GetReadyState(&readyState); + if (readyState >= 3) { + *aStatus = NS_ERROR_NOT_AVAILABLE; + return NS_OK; + } + } + + return rv; } *aStatus = 0;