11869, r = travis. we no longer to the www.*.com trick as it is handled by the keyword protocol handler. we now kick qualifying requests to the keyword protocol handler.

This commit is contained in:
valeski%netscape.com 1999-11-02 04:00:07 +00:00
Родитель 26fbbb140d
Коммит 13ec852729
2 изменённых файлов: 26 добавлений и 98 удалений

Просмотреть файл

@ -2202,7 +2202,19 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
convertFileToURL(urlStr, urlSpec);
rv = NS_NewURI(getter_AddRefs(uri), urlSpec, nsnull);
if (NS_FAILED(rv)) {
// no dice, try more tricks
// keyword failover
// we kick the following cases to the keyword server:
// * starts with a '?'
// * contains a space
// * is a single word (contains no dots or scheme) XXX: this breaks
// intranet host lookups. This latter case needs to be handled by
// dns notifications rather than string interrogation.
if ( (urlStr.FindChar('.') == -1) || (urlStr.First() == '?') || (urlStr.FindChar(' ') > -1) ) {
nsAutoString keywordSpec("keyword:");
keywordSpec.Append(aURLSpec);
rv = NS_NewURI(getter_AddRefs(uri), keywordSpec, nsnull);
}
PRInt32 colon, fSlash = urlSpec.FindChar('/');
PRUnichar port;
@ -3376,54 +3388,6 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader,
dlObserver->OnEndDocumentLoad(mDocLoader, channel, aStatus, aWebShell);
}
if ( (mDocLoader == loader) && (aStatus == NS_ERROR_UNKNOWN_HOST) ) {
// 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);
nsAllocator::Free(host);
PRInt32 dotLoc = -1;
dotLoc = hostStr.FindChar('.');
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);
nsAllocator::Free(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);
// reload the url
const PRUnichar *spec = newURL.GetUnicode();
if (spec) {
rv = LoadURL(spec, "view");
}
} // retry
} // unknown host
} //!mProcessedEndDocumentLoad
else {
rv = NS_OK;

Просмотреть файл

@ -2202,7 +2202,19 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
convertFileToURL(urlStr, urlSpec);
rv = NS_NewURI(getter_AddRefs(uri), urlSpec, nsnull);
if (NS_FAILED(rv)) {
// no dice, try more tricks
// keyword failover
// we kick the following cases to the keyword server:
// * starts with a '?'
// * contains a space
// * is a single word (contains no dots or scheme) XXX: this breaks
// intranet host lookups. This latter case needs to be handled by
// dns notifications rather than string interrogation.
if ( (urlStr.FindChar('.') == -1) || (urlStr.First() == '?') || (urlStr.FindChar(' ') > -1) ) {
nsAutoString keywordSpec("keyword:");
keywordSpec.Append(aURLSpec);
rv = NS_NewURI(getter_AddRefs(uri), keywordSpec, nsnull);
}
PRInt32 colon, fSlash = urlSpec.FindChar('/');
PRUnichar port;
@ -3376,54 +3388,6 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader,
dlObserver->OnEndDocumentLoad(mDocLoader, channel, aStatus, aWebShell);
}
if ( (mDocLoader == loader) && (aStatus == NS_ERROR_UNKNOWN_HOST) ) {
// 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);
nsAllocator::Free(host);
PRInt32 dotLoc = -1;
dotLoc = hostStr.FindChar('.');
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);
nsAllocator::Free(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);
// reload the url
const PRUnichar *spec = newURL.GetUnicode();
if (spec) {
rv = LoadURL(spec, "view");
}
} // retry
} // unknown host
} //!mProcessedEndDocumentLoad
else {
rv = NS_OK;