necko www.*.com trick

This commit is contained in:
valeski%netscape.com 1999-07-21 14:54:45 +00:00
parent 14c1cb2c49
commit 951e14a6a2
2 changed files with 102 additions and 2 deletions

View File

@ -2065,7 +2065,57 @@ NS_METHOD nsDocumentBindInfo::OnStopRequest(nsIURI* aURL, nsresult aStatus, cons
#endif
if (NS_FAILED(aStatus)) {
#ifdef NECKO
// We need to check for a dns failure in aStatus, but dns failure codes
// aren't proliferated yet. This checks for failure for a host lacking
// "www." and/or ".com" and munges the url acordingly, then fires off
// a new request.
//
// XXX This code may or may not have mem leaks depending on the version
// XXX stdurl that is in the tree at a given point in time. This needs to
// XXX be fixed once we have a solid version of std url in.
char *host = nsnull;
nsString2 hostStr;
rv = aURL->GetHost(&host);
if (NS_FAILED(rv)) return rv;
hostStr.SetString(host);
PRInt32 dotLoc = -1;
dotLoc = hostStr.Find('.');
PRBool retry = PR_FALSE;
if (-1 == dotLoc) {
hostStr.Insert("www.", 0, 4);
hostStr.Append(".com");
retry = PR_TRUE;
} else if ( (hostStr.Length() - dotLoc) == 3) {
hostStr.Insert("www.", 0, 4);
retry = PR_TRUE;
}
if (retry) {
char *modHost = hostStr.ToNewCString();
if (!modHost)
return NS_ERROR_OUT_OF_MEMORY;
rv = aURL->SetHost(modHost);
delete [] modHost;
modHost = nsnull;
if (NS_FAILED(rv)) return rv;
char *aSpec = nsnull;
rv = aURL->GetSpec(&aSpec);
if (NS_FAILED(rv)) return rv;
nsString2 newURL(aSpec);
return m_DocLoader->LoadDocument(newURL,
m_Command,
m_Container,
nsnull, // XXX need to pass post data along
m_ExtraInfo,
m_Observer,
nsIChannel::LOAD_NORMAL,
0);
}
char *url;
if (NS_SUCCEEDED(rv))
aURL->GetSpec(&url);
@ -2077,7 +2127,7 @@ NS_METHOD nsDocumentBindInfo::OnStopRequest(nsIURI* aURL, nsresult aStatus, cons
aURL->GetSpec(&url);
else
url = "";
#endif
#endif // NECKO
#ifdef DEBUG_pnunn
cerr << "nsDocumentBindInfo::OnStopRequest: Load of URL '" << url << "' failed. Error code: "

View File

@ -2065,7 +2065,57 @@ NS_METHOD nsDocumentBindInfo::OnStopRequest(nsIURI* aURL, nsresult aStatus, cons
#endif
if (NS_FAILED(aStatus)) {
#ifdef NECKO
// We need to check for a dns failure in aStatus, but dns failure codes
// aren't proliferated yet. This checks for failure for a host lacking
// "www." and/or ".com" and munges the url acordingly, then fires off
// a new request.
//
// XXX This code may or may not have mem leaks depending on the version
// XXX stdurl that is in the tree at a given point in time. This needs to
// XXX be fixed once we have a solid version of std url in.
char *host = nsnull;
nsString2 hostStr;
rv = aURL->GetHost(&host);
if (NS_FAILED(rv)) return rv;
hostStr.SetString(host);
PRInt32 dotLoc = -1;
dotLoc = hostStr.Find('.');
PRBool retry = PR_FALSE;
if (-1 == dotLoc) {
hostStr.Insert("www.", 0, 4);
hostStr.Append(".com");
retry = PR_TRUE;
} else if ( (hostStr.Length() - dotLoc) == 3) {
hostStr.Insert("www.", 0, 4);
retry = PR_TRUE;
}
if (retry) {
char *modHost = hostStr.ToNewCString();
if (!modHost)
return NS_ERROR_OUT_OF_MEMORY;
rv = aURL->SetHost(modHost);
delete [] modHost;
modHost = nsnull;
if (NS_FAILED(rv)) return rv;
char *aSpec = nsnull;
rv = aURL->GetSpec(&aSpec);
if (NS_FAILED(rv)) return rv;
nsString2 newURL(aSpec);
return m_DocLoader->LoadDocument(newURL,
m_Command,
m_Container,
nsnull, // XXX need to pass post data along
m_ExtraInfo,
m_Observer,
nsIChannel::LOAD_NORMAL,
0);
}
char *url;
if (NS_SUCCEEDED(rv))
aURL->GetSpec(&url);
@ -2077,7 +2127,7 @@ NS_METHOD nsDocumentBindInfo::OnStopRequest(nsIURI* aURL, nsresult aStatus, cons
aURL->GetSpec(&url);
else
url = "";
#endif
#endif // NECKO
#ifdef DEBUG_pnunn
cerr << "nsDocumentBindInfo::OnStopRequest: Load of URL '" << url << "' failed. Error code: "