#162239 POST document could not inherit charset from previous page if the previous charset is from autodetection.

r=ftang, darin, sr=jst
added PrevDocCharset to markupViewer, and pass around previous document charset.
This charset is later used to load POST document.


git-svn-id: svn://10.0.0.236/trunk@128141 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
shanjian%netscape.com
2002-08-26 20:13:31 +00:00
parent 5fe48eddea
commit 5d1c227024
9 changed files with 143 additions and 24 deletions

View File

@@ -964,17 +964,27 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
UseWeakDocTypeDefault(charsetSource, charset);
}
}
if(kCharsetFromAutoDetection > charsetSource) {
PRBool isPostPage = PR_FALSE;
//check if current doc is from POST command
if (httpChannel) {
nsCAutoString methodStr;
if (httpChannel) {
rv = httpChannel->GetRequestMethod(methodStr);
if (NS_FAILED(rv) || !methodStr.Equals(NS_LITERAL_CSTRING("POST"))) {
StartAutodetection(docShell, charset, aCommand);
}
rv = httpChannel->GetRequestMethod(methodStr);
if (NS_SUCCEEDED(rv) && methodStr.Equals(NS_LITERAL_CSTRING("POST")))
isPostPage = PR_TRUE;
}
if (isPostPage && muCV && kCharsetFromHintPrevDoc > charsetSource) {
PRUnichar* requestCharset;
muCV->GetPrevDocCharacterSet(&requestCharset);
if (*requestCharset) {
charsetSource = kCharsetFromHintPrevDoc;
charset = requestCharset;
}
else
StartAutodetection(docShell, charset, aCommand);
}
if(kCharsetFromAutoDetection > charsetSource && !isPostPage) {
StartAutodetection(docShell, charset, aCommand);
}
#endif
@@ -987,7 +997,11 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
SetDocumentCharacterSet(charset);
SetDocumentCharacterSetSource(charsetSource);
// set doc charset to muCV for next document.
if (muCV)
muCV->SetPrevDocCharacterSet(charset.get());
if(cacheDescriptor) {
rv = cacheDescriptor->SetMetaDataElement("charset",
NS_ConvertUCS2toUTF8(charset).get());