Fix for bug # 99638. r=darin sr=rpotts. Use nsIMultiPartChannel to access

htttpChannel that is part of a multipartChannel.
This commit is contained in:
radha%netscape.com 2001-11-27 23:14:15 +00:00
parent eb07b15572
commit 155b4d617d
2 changed files with 32 additions and 2 deletions

View File

@ -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<nsIInputStream> inputStream;
if (aChannel) {
nsCOMPtr<nsIHttpChannel> 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<nsIHttpChannel> 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<nsIMultiPartChannel> multiPartChannel(do_QueryInterface(aChannel));
if (multiPartChannel) {
nsCOMPtr<nsIChannel> baseChannel;
multiPartChannel->GetBaseChannel(getter_AddRefs(baseChannel));
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(baseChannel));
*aReturn = httpChannel;
NS_IF_ADDREF(*aReturn);
}
return NS_OK;
}
//*****************************************************************************
// nsDocShell: Global History
//*****************************************************************************

View File

@ -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);