From 73b66f889a4ddaea5bcb9feb43743e4a75b0e05a Mon Sep 17 00:00:00 2001 From: "radha%netscape.com" Date: Tue, 27 Nov 2001 23:14:15 +0000 Subject: [PATCH] Fix for bug # 99638. r=darin sr=rpotts. Use nsIMultiPartChannel to access htttpChannel that is part of a multipartChannel. git-svn-id: svn://10.0.0.236/trunk@109051 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsDocShell.cpp | 32 ++++++++++++++++++++++++++-- mozilla/docshell/base/nsDocShell.h | 2 ++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 07a68106636..68da1b4e97b 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -68,7 +68,6 @@ // Interfaces Needed #include "nsIUploadChannel.h" -#include "nsIHttpChannel.h" #include "nsIDataChannel.h" #include "nsIProgressEventSink.h" #include "nsIWebProgress.h" @@ -83,6 +82,7 @@ #include "nsIDOMDocument.h" #include "nsICachingChannel.h" #include "nsICacheEntryDescriptor.h" +#include "nsIMultiPartChannel.h" // The following are for bug #13871: Prevent frameset spoofing #include "nsICodebasePrincipal.h" @@ -4648,6 +4648,11 @@ nsDocShell::OnNewURI(nsIURI * aURI, nsIChannel * aChannel, nsCOMPtr inputStream; if (aChannel) { nsCOMPtr httpChannel(do_QueryInterface(aChannel)); + + // Check if the HTTPChannel is hiding under a multiPartChannel + if (!httpChannel) { + GetHttpChannel(aChannel, getter_AddRefs(httpChannel)); + } if (httpChannel) { httpChannel->GetUploadStream(getter_AddRefs(inputStream)); @@ -5105,7 +5110,11 @@ nsDocShell::AddToSessionHistory(nsIURI * aURI, cacheChannel->GetCacheToken(getter_AddRefs(cacheToken)); } nsCOMPtr httpChannel(do_QueryInterface(aChannel)); - + + // Check if the httpChannel is hiding under a multipartChannel + if (!httpChannel) { + GetHttpChannel(aChannel, getter_AddRefs(httpChannel)); + } if (httpChannel) { httpChannel->GetUploadStream(getter_AddRefs(inputStream)); httpChannel->GetReferrer(getter_AddRefs(referrerURI)); @@ -5367,6 +5376,7 @@ nsDocShell::CloneAndReplace(nsISHEntry * src, PRUint32 aCloneID, } + nsresult nsDocShell::GetRootSessionHistory(nsISHistory ** aReturn) { @@ -5384,6 +5394,24 @@ nsDocShell::GetRootSessionHistory(nsISHistory ** aReturn) return rv; } +nsresult +nsDocShell::GetHttpChannel(nsIChannel * aChannel, nsIHttpChannel ** aReturn) +{ + NS_ENSURE_ARG_POINTER(aReturn); + if (!aChannel) + return NS_ERROR_FAILURE; + + nsCOMPtr multiPartChannel(do_QueryInterface(aChannel)); + if (multiPartChannel) { + nsCOMPtr baseChannel; + multiPartChannel->GetBaseChannel(getter_AddRefs(baseChannel)); + nsCOMPtr httpChannel(do_QueryInterface(baseChannel)); + *aReturn = httpChannel; + NS_IF_ADDREF(*aReturn); + } + return NS_OK; +} + //***************************************************************************** // nsDocShell: Global History //***************************************************************************** diff --git a/mozilla/docshell/base/nsDocShell.h b/mozilla/docshell/base/nsDocShell.h index 9c08bd3ea9e..173230e3978 100644 --- a/mozilla/docshell/base/nsDocShell.h +++ b/mozilla/docshell/base/nsDocShell.h @@ -76,6 +76,7 @@ #include "nsIDocShellHistory.h" #include "nsIURIFixup.h" #include "nsIWebBrowserFind.h" +#include "nsIHttpChannel.h" #define MAKE_LOAD_TYPE(type, flags) ((type) | ((flags) << 16)) @@ -238,6 +239,7 @@ protected: NS_IMETHOD CloneAndReplace(nsISHEntry * srcEntry, PRUint32 aCloneID, nsISHEntry * areplaceEntry, nsISHEntry ** destEntry); nsresult GetRootSessionHistory(nsISHistory ** aReturn); + nsresult GetHttpChannel(nsIChannel * aChannel, nsIHttpChannel ** aReturn); // Global History NS_IMETHOD ShouldAddToGlobalHistory(nsIURI * aURI, PRBool * aShouldAdd);