mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
fixes bug 63878 "Implement alert for 'document contains no data' (was Going
to lexmark.com does nothing, but www.lexmark works [Connection reset by peer]" r=adamlock, sr=rpotts, a=asa
This commit is contained in:
parent
9fd366b021
commit
5affc94a93
@ -27,3 +27,5 @@ redirectLoop=Redirection limit for this URL exceeded. Unable to load the reques
|
||||
repost=The page you are trying to view contains POSTDATA that has expired from cache. If you resend the data, any action the form carried out (such as a search or online purchase) will be repeated. To resend the data, click OK. Otherwise, click Cancel.
|
||||
repostConfirm=The page you are trying to view contains POSTDATA. If you resend the data, any action the form carried out (such as a search or online purchase) will be repeated. To resend the data, click OK. Otherwise, click Cancel.
|
||||
unknownSocketType=This document cannot be displayed unless you install the Personal Security Manager (PSM). Download and install PSM and try again, or contact your system administrator.
|
||||
netReset=The document contains no data.
|
||||
unknownError=An unknown error occured while attempting to load the requested page.
|
||||
|
@ -774,7 +774,8 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress,
|
||||
//
|
||||
if (aStatus == NS_ERROR_UNKNOWN_HOST ||
|
||||
aStatus == NS_ERROR_CONNECTION_REFUSED ||
|
||||
aStatus == NS_ERROR_NET_TIMEOUT)
|
||||
aStatus == NS_ERROR_NET_TIMEOUT ||
|
||||
aStatus == NS_ERROR_NET_RESET)
|
||||
{
|
||||
mURIFixup->CreateFixupURI(oldSpecW.get(),
|
||||
nsIURIFixup::FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP, getter_AddRefs(newURI));
|
||||
@ -783,7 +784,8 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress,
|
||||
//
|
||||
// Now try change the address, e.g. turn http://foo into http://www.foo.com
|
||||
//
|
||||
if (aStatus == NS_ERROR_UNKNOWN_HOST)
|
||||
if (aStatus == NS_ERROR_UNKNOWN_HOST ||
|
||||
aStatus == NS_ERROR_NET_RESET)
|
||||
{
|
||||
// Test if keyword lookup produced a new URI or not
|
||||
PRBool doCreateAlternate = PR_TRUE;
|
||||
@ -1008,10 +1010,30 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress,
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// Doc failed to load because the server generated too many redirects
|
||||
//
|
||||
else if (aStatus == NS_ERROR_REDIRECT_LOOP) {
|
||||
else {
|
||||
//
|
||||
// handle errors that have simple messages w/ no arguments.
|
||||
//
|
||||
const char *errorStr = nsnull;
|
||||
switch (aStatus) {
|
||||
case NS_ERROR_REDIRECT_LOOP:
|
||||
// Doc failed to load because the server generated too many redirects
|
||||
errorStr = "redirectLoop";
|
||||
break;
|
||||
case NS_ERROR_UNKNOWN_SOCKET_TYPE:
|
||||
// Doc failed to load because PSM is not installed
|
||||
errorStr = "unknownSocketType";
|
||||
break;
|
||||
case NS_ERROR_NET_RESET:
|
||||
// Doc failed to load because the server kept reseting the connection
|
||||
// before we could read any data from it
|
||||
errorStr = "netReset";
|
||||
break;
|
||||
default:
|
||||
NS_NOTREACHED("would be nice to add an alert here");
|
||||
errorStr = "unknownError";
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIPrompt> prompter;
|
||||
nsCOMPtr<nsIStringBundle> stringBundle;
|
||||
|
||||
@ -1022,24 +1044,7 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress,
|
||||
}
|
||||
|
||||
nsXPIDLString messageStr;
|
||||
rv = stringBundle->GetStringFromName(NS_LITERAL_STRING("redirectLoop").get(),
|
||||
getter_Copies(messageStr));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
prompter->Alert(nsnull, messageStr);
|
||||
}
|
||||
else if (aStatus == NS_ERROR_UNKNOWN_SOCKET_TYPE) {
|
||||
nsCOMPtr<nsIPrompt> prompter;
|
||||
nsCOMPtr<nsIStringBundle> stringBundle;
|
||||
|
||||
rv = GetPromptAndStringBundle(getter_AddRefs(prompter),
|
||||
getter_AddRefs(stringBundle));
|
||||
if (!stringBundle) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsXPIDLString messageStr;
|
||||
rv = stringBundle->GetStringFromName(NS_LITERAL_STRING("unknownSocketType").get(),
|
||||
rv = stringBundle->GetStringFromName(NS_ConvertASCIItoUCS2(errorStr).get(),
|
||||
getter_Copies(messageStr));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -70,6 +70,24 @@ static PRLogModuleInfo *gSocketTransportLog = nsnull;
|
||||
static NS_DEFINE_CID(kSocketProviderService, NS_SOCKETPROVIDERSERVICE_CID);
|
||||
static NS_DEFINE_CID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID);
|
||||
|
||||
static nsresult
|
||||
ErrorAccordingToNSPR()
|
||||
{
|
||||
nsresult rv = NS_ErrorAccordingToNSPR();
|
||||
if (rv == NS_ERROR_FAILURE) {
|
||||
LOG(("PR_GetError() returned %d\n", PR_GetError()));
|
||||
// maybe this really maps to a more specific necko error
|
||||
switch (PR_GetError()) {
|
||||
case PR_CONNECT_ABORTED_ERROR:
|
||||
case PR_CONNECT_RESET_ERROR:
|
||||
LOG(("mapping to NS_ERROR_NET_RESET\n"));
|
||||
rv = NS_ERROR_NET_RESET;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// nsSocketTransport
|
||||
@ -2218,7 +2236,7 @@ nsSocketBIS::Read(char *aBuf, PRUint32 aCount, PRUint32 *aBytesRead)
|
||||
tryRead:
|
||||
total = PR_Read(sock, aBuf, aCount);
|
||||
if (total < 0) {
|
||||
rv = NS_ErrorAccordingToNSPR();
|
||||
rv = ErrorAccordingToNSPR();
|
||||
if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
|
||||
//
|
||||
// Block until the socket is readable and then try again.
|
||||
@ -2231,7 +2249,7 @@ tryRead:
|
||||
LOG(("nsSocketBIS::Read [this=%x] Poll succeeded; looping back to PR_Read\n", this));
|
||||
goto tryRead;
|
||||
}
|
||||
LOG(("nsSocketBIS::Read [this=%x] PR_Read failed [error=%x]\n", this, PR_GetError()));
|
||||
LOG(("nsSocketBIS::Read [this=%x] PR_Read failed [error=%d]\n", this, PR_GetError()));
|
||||
goto end;
|
||||
}
|
||||
*aBytesRead = (PRUint32) total;
|
||||
@ -2302,7 +2320,7 @@ tryWrite:
|
||||
LOG(("nsSocketBOS PR_Write [this=%x] wrote %d of %d\n", this, total, aCount));
|
||||
|
||||
if (written < 0) {
|
||||
rv = NS_ErrorAccordingToNSPR();
|
||||
rv = ErrorAccordingToNSPR();
|
||||
if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
|
||||
//
|
||||
// Block until the socket is writable and then try again.
|
||||
@ -2315,7 +2333,7 @@ tryWrite:
|
||||
LOG(("nsSocketBOS::Write [this=%x] Poll succeeded; looping back to PR_Write\n", this));
|
||||
goto tryWrite;
|
||||
}
|
||||
LOG(("nsSocketBOS::Write [this=%x] PR_Write failed [error=%x]\n", this, PR_GetError()));
|
||||
LOG(("nsSocketBOS::Write [this=%x] PR_Write failed [error=%d]\n", this, PR_GetError()));
|
||||
goto end;
|
||||
}
|
||||
|
||||
@ -2406,9 +2424,9 @@ nsSocketIS::Read(char *aBuf, PRUint32 aCount, PRUint32 *aBytesRead)
|
||||
rv = NS_BASE_STREAM_WOULD_BLOCK;
|
||||
}
|
||||
else {
|
||||
LOG(("nsSocketIS: PR_Read() failed [error=%x, os_error=%x]\n",
|
||||
LOG(("nsSocketIS: PR_Read() failed [error=%d, os_error=%d]\n",
|
||||
mError, PR_GetOSError()));
|
||||
rv = NS_ERROR_FAILURE;
|
||||
rv = ErrorAccordingToNSPR();
|
||||
}
|
||||
*aBytesRead = 0;
|
||||
}
|
||||
@ -2512,9 +2530,9 @@ nsSocketOS::Write(const char *aBuf, PRUint32 aCount, PRUint32 *aBytesWritten)
|
||||
LOG(("nsSocketTransport: PR_Write() failed with PR_WOULD_BLOCK_ERROR\n"));
|
||||
rv = NS_BASE_STREAM_WOULD_BLOCK;
|
||||
} else {
|
||||
LOG(("nsSocketTransport: PR_Write() failed [error=%x, os_error=%x]\n",
|
||||
LOG(("nsSocketTransport: PR_Write() failed [error=%d, os_error=%d]\n",
|
||||
mError, PR_GetOSError()));
|
||||
rv = NS_ERROR_FAILURE;
|
||||
rv = ErrorAccordingToNSPR();
|
||||
}
|
||||
*aBytesWritten = 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user