From a367cb945756826917c8c66b0e5e739c1c2b4450 Mon Sep 17 00:00:00 2001 From: "peterv%propagandism.org" Date: Fri, 5 May 2006 11:48:07 +0000 Subject: [PATCH] Fix for bug 334179 (XSLT document() function doesn't follow HTTP 301 / 302 responses). r=sicking, sr=bz. --- content/base/src/nsSyncLoadService.cpp | 12 ++++++++++++ content/xslt/src/xml/txXMLParser.cpp | 15 +-------------- .../xslt/src/xslt/txMozillaStylesheetCompiler.cpp | 4 ---- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/content/base/src/nsSyncLoadService.cpp b/content/base/src/nsSyncLoadService.cpp index 0ba2754dd055..d0dc3242e610 100644 --- a/content/base/src/nsSyncLoadService.cpp +++ b/content/base/src/nsSyncLoadService.cpp @@ -215,6 +215,12 @@ nsSyncLoader::LoadDocument(nsIChannel* aChannel, nsresult rv = NS_OK; mChannel = aChannel; + nsCOMPtr http = do_QueryInterface(mChannel); + if (http) { + http->SetRequestHeader(NS_LITERAL_CSTRING("Accept"), + NS_LITERAL_CSTRING("text/xml,application/xml,application/xhtml+xml,*/*;q=0.1"), + PR_FALSE); + } if (aLoaderURI) { nsCOMPtr docURI; @@ -278,6 +284,12 @@ nsSyncLoader::LoadDocument(nsIChannel* aChannel, rv = PushAsyncStream(listener); } + http = do_QueryInterface(mChannel); + if (mLoadSuccess && http) { + PRBool succeeded; + mLoadSuccess = NS_SUCCEEDED(http->GetRequestSucceeded(&succeeded)) && + succeeded; + } mChannel = nsnull; // This will release the proxy. Don't use the errorvalue from this since diff --git a/content/xslt/src/xml/txXMLParser.cpp b/content/xslt/src/xml/txXMLParser.cpp index d718cad26cdf..1f37868db71e 100644 --- a/content/xslt/src/xml/txXMLParser.cpp +++ b/content/xslt/src/xml/txXMLParser.cpp @@ -109,11 +109,6 @@ txParseDocumentFromURI(const nsAString& aHref, const txXPathNode& aLoader, nsCOMPtr http = do_QueryInterface(channel); if (http) { http->SetReferrer(loaderUri); - http->SetRequestHeader(NS_LITERAL_CSTRING("Accept"), - NS_LITERAL_CSTRING("text/xml,application/xml,application/xhtml+xml,*/*;q=0.1"), - PR_FALSE); - - } nsCOMPtr loader = @@ -124,15 +119,7 @@ txParseDocumentFromURI(const nsAString& aHref, const txXPathNode& aLoader, // the document. nsIDOMDocument* theDocument = nsnull; rv = loader->LoadDocumentAsXML(channel, loaderUri, &theDocument); - - PRBool succeeded = NS_SUCCEEDED(rv) && theDocument; - if (succeeded && http) { - PRBool httpSucceeded; - rv = http->GetRequestSucceeded(&httpSucceeded); - succeeded = NS_SUCCEEDED(rv) && httpSucceeded; - } - - if (!succeeded) { + if (NS_FAILED(rv)) { aErrMsg.Append(NS_LITERAL_STRING("Document load of ") + aHref + NS_LITERAL_STRING(" failed.")); return NS_FAILED(rv) ? rv : NS_ERROR_FAILURE; diff --git a/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp b/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp index b9b89a82eead..fe555f476d13 100644 --- a/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp +++ b/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp @@ -766,10 +766,6 @@ txSyncCompileObserver::loadURI(const nsAString& aUri, nsCOMPtr httpChannel(do_QueryInterface(channel)); if (httpChannel) { - httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"), - NS_LITERAL_CSTRING("text/xml,application/xml,application/xhtml+xml,*/*;q=0.1"), - PR_FALSE); - httpChannel->SetReferrer(referrerUri); }