зеркало из https://github.com/mozilla/pjs.git
181938 allow any protocol to support redirection, using a new
nsIChannelEventSink interface. r=darin sr=bz
This commit is contained in:
Родитель
d58751de36
Коммит
43ff9de092
|
@ -2005,7 +2005,7 @@ bookmarksFavIconLoadListener.prototype = {
|
|||
if (!iid.equals(Components.interfaces.nsISupports) &&
|
||||
!iid.equals(Components.interfaces.nsIInterfaceRequestor) &&
|
||||
!iid.equals(Components.interfaces.nsIRequestObserver) &&
|
||||
!iid.equals(Components.interfaces.nsIHttpEventSink) &&
|
||||
!iid.equals(Components.interfaces.nsIChannelEventSink) &&
|
||||
!iid.equals(Components.interfaces.nsIProgressEventSink) && // see below
|
||||
!iid.equals(Components.interfaces.nsIStreamListener)) {
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
|
@ -2082,8 +2082,8 @@ bookmarksFavIconLoadListener.prototype = {
|
|||
this.mCountRead += aCount;
|
||||
},
|
||||
|
||||
// nsIHttpEventSink
|
||||
onRedirect : function (aHttpChannel, aNewChannel) {
|
||||
// nsIChannelEventSink
|
||||
onChannelRedirect : function (aOldChannel, aNewChannel, aFlags) {
|
||||
this.mChannel = aNewChannel;
|
||||
},
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIDOMLoadListener.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsISyncLoadDOMService.h"
|
||||
|
@ -97,7 +97,7 @@ public:
|
|||
*/
|
||||
|
||||
class nsSyncLoader : public nsIDOMLoadListener,
|
||||
public nsIHttpEventSink,
|
||||
public nsIChannelEventSink,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
|
@ -121,7 +121,7 @@ public:
|
|||
NS_IMETHOD Abort(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Error(nsIDOMEvent* aEvent);
|
||||
|
||||
NS_DECL_NSIHTTPEVENTSINK
|
||||
NS_DECL_NSICHANNELEVENTSINK
|
||||
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
|
@ -309,7 +309,7 @@ nsSyncLoader::~nsSyncLoader()
|
|||
|
||||
NS_IMPL_ISUPPORTS4(nsSyncLoader,
|
||||
nsIDOMLoadListener,
|
||||
nsIHttpEventSink,
|
||||
nsIChannelEventSink,
|
||||
nsIInterfaceRequestor,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
|
@ -513,13 +513,14 @@ nsSyncLoader::Error(nsIDOMEvent* aEvent)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSyncLoader::OnRedirect(nsIHttpChannel *aHttpChannel,
|
||||
nsIChannel *aNewChannel)
|
||||
nsSyncLoader::OnChannelRedirect(nsIChannel *aOldChannel,
|
||||
nsIChannel *aNewChannel,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNewChannel);
|
||||
NS_PRECONDITION(aNewChannel, "Redirecting to null channel?");
|
||||
|
||||
nsCOMPtr<nsIURI> oldURI;
|
||||
nsresult rv = aHttpChannel->GetURI(getter_AddRefs(oldURI)); // The original URI
|
||||
nsresult rv = aOldChannel->GetURI(getter_AddRefs(oldURI)); // The original URI
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIURI> newURI;
|
||||
|
|
|
@ -200,7 +200,7 @@ nsXMLDocument::~nsXMLDocument()
|
|||
// QueryInterface implementation for nsXMLDocument
|
||||
NS_INTERFACE_MAP_BEGIN(nsXMLDocument)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIHttpEventSink)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIChannelEventSink)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMXMLDocument)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(XMLDocument)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDocument)
|
||||
|
@ -259,11 +259,13 @@ nsXMLDocument::GetInterface(const nsIID& aIID, void** aSink)
|
|||
return QueryInterface(aIID, aSink);
|
||||
}
|
||||
|
||||
// nsIHttpEventSink
|
||||
// nsIChannelEventSink
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::OnRedirect(nsIHttpChannel *aHttpChannel, nsIChannel *aNewChannel)
|
||||
nsXMLDocument::OnChannelRedirect(nsIChannel *aOldChannel,
|
||||
nsIChannel *aNewChannel,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNewChannel);
|
||||
NS_PRECONDITION(aNewChannel, "Redirecting to null channel?");
|
||||
|
||||
nsCOMPtr<nsIURI> newLocation;
|
||||
nsresult rv = aNewChannel->GetURI(getter_AddRefs(newLocation)); // The redirected URI
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "nsDocument.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIDOMXMLDocument.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsHTMLStyleSheet.h"
|
||||
|
@ -55,7 +55,7 @@ class nsIURI;
|
|||
|
||||
class nsXMLDocument : public nsDocument,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIHttpEventSink
|
||||
public nsIChannelEventSink
|
||||
{
|
||||
public:
|
||||
nsXMLDocument();
|
||||
|
@ -87,7 +87,7 @@ public:
|
|||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
// nsIHTTPEventSink
|
||||
NS_DECL_NSIHTTPEVENTSINK
|
||||
NS_DECL_NSICHANNELEVENTSINK
|
||||
|
||||
// nsIDOMXMLDocument
|
||||
NS_DECL_NSIDOMXMLDOCUMENT
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIUploadChannel.h"
|
||||
#include "nsISecurityEventSink.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
|
|
|
@ -980,7 +980,7 @@ TransferProgressListener.prototype =
|
|||
// dummy
|
||||
},
|
||||
|
||||
OnRedirect : function(anHTTPChannel, aNewChannel)
|
||||
onChannelRedirect : function(aOldChannel, aNewChannel, aFlags)
|
||||
{
|
||||
// dummy
|
||||
},
|
||||
|
@ -1350,7 +1350,7 @@ TransferProgressListener.prototype =
|
|||
|| aIID.equals(Components.interfaces.nsIPrompt)
|
||||
|| aIID.equals(Components.interfaces.nsIAuthPrompt)
|
||||
|| aIID.equals(Components.interfaces.nsIFTPEventSink)
|
||||
|| aIID.equals(Components.interfaces.nsIHttpEventSink)
|
||||
|| aIID.equals(Components.interfaces.nsIChannelEventSink)
|
||||
|| aIID.equals(Components.interfaces.nsIDocShellTreeItem)
|
||||
|| aIID.equals(Components.interfaces.nsIInterfaceRequestor))
|
||||
return this;
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIExpatSink.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
|
@ -91,7 +91,7 @@ getSpec(nsIChannel* aChannel, nsAString& aSpec)
|
|||
class txStylesheetSink : public nsIXMLContentSink,
|
||||
public nsIExpatSink,
|
||||
public nsIStreamListener,
|
||||
public nsIHttpEventSink,
|
||||
public nsIChannelEventSink,
|
||||
public nsIInterfaceRequestor
|
||||
{
|
||||
public:
|
||||
|
@ -102,7 +102,7 @@ public:
|
|||
NS_DECL_NSIEXPATSINK
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSIHTTPEVENTSINK
|
||||
NS_DECL_NSICHANNELEVENTSINK
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
// nsIContentSink
|
||||
|
@ -143,7 +143,7 @@ NS_IMPL_ISUPPORTS7(txStylesheetSink,
|
|||
nsIExpatSink,
|
||||
nsIStreamListener,
|
||||
nsIRequestObserver,
|
||||
nsIHttpEventSink,
|
||||
nsIChannelEventSink,
|
||||
nsIInterfaceRequestor)
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -369,10 +369,11 @@ txStylesheetSink::OnStopRequest(nsIRequest *aRequest, nsISupports *aContext,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
txStylesheetSink::OnRedirect(nsIHttpChannel *aHttpChannel,
|
||||
nsIChannel *aNewChannel)
|
||||
txStylesheetSink::OnChannelRedirect(nsIChannel *aOldChannel,
|
||||
nsIChannel *aNewChannel,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNewChannel);
|
||||
NS_PRECONDITION(aNewChannel, "Redirect without a channel?");
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan =
|
||||
|
@ -380,7 +381,7 @@ txStylesheetSink::OnRedirect(nsIHttpChannel *aHttpChannel,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIURI> oldURI;
|
||||
rv = aHttpChannel->GetURI(getter_AddRefs(oldURI)); // The original URI
|
||||
rv = aOldChannel->GetURI(getter_AddRefs(oldURI)); // The original URI
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIURI> newURI;
|
||||
|
|
|
@ -59,7 +59,7 @@ NS_IMPL_ISUPPORTS_INHERITED5(nsXFormsInstanceElement,
|
|||
nsIStreamListener,
|
||||
nsIRequestObserver,
|
||||
nsIInterfaceRequestor,
|
||||
nsIHttpEventSink)
|
||||
nsIChannelEventSink)
|
||||
|
||||
nsXFormsInstanceElement::nsXFormsInstanceElement()
|
||||
: mElement(nsnull)
|
||||
|
@ -166,13 +166,14 @@ nsXFormsInstanceElement::GetInterface(const nsIID & aIID, void **aResult)
|
|||
return QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
// nsIHttpEventSink
|
||||
// nsIChannelEventSink
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsInstanceElement::OnRedirect(nsIHttpChannel *aHttpChannel,
|
||||
nsIChannel *aNewChannel)
|
||||
nsXFormsInstanceElement::OnChannelRedirect(nsIChannel *OldChannel,
|
||||
nsIChannel *aNewChannel,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNewChannel);
|
||||
NS_PRECONDITION(aNewChannel, "Redirect without a channel?");
|
||||
nsCOMPtr<nsIURI> newURI;
|
||||
nsresult rv = aNewChannel->GetURI(getter_AddRefs(newURI));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#include "nsIInstanceElementPrivate.h"
|
||||
#include "nsIRequestObserver.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
|
||||
class nsIDOMElement;
|
||||
|
@ -60,7 +60,7 @@ class nsIDOMElement;
|
|||
class nsXFormsInstanceElement : public nsXFormsStubElement,
|
||||
public nsIInstanceElementPrivate,
|
||||
public nsIStreamListener,
|
||||
public nsIHttpEventSink,
|
||||
public nsIChannelEventSink,
|
||||
public nsIInterfaceRequestor
|
||||
{
|
||||
public:
|
||||
|
@ -68,7 +68,7 @@ public:
|
|||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSIINSTANCEELEMENTPRIVATE
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIHTTPEVENTSINK
|
||||
NS_DECL_NSICHANNELEVENTSINK
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
// nsIXTFGenericElement overrides
|
||||
|
|
|
@ -269,7 +269,7 @@ NS_IMPL_ISUPPORTS_INHERITED4(nsXFormsSubmissionElement,
|
|||
nsIRequestObserver,
|
||||
nsIXFormsSubmissionElement,
|
||||
nsIInterfaceRequestor,
|
||||
nsIHttpEventSink)
|
||||
nsIChannelEventSink)
|
||||
|
||||
// nsIXTFElement
|
||||
|
||||
|
@ -343,13 +343,14 @@ nsXFormsSubmissionElement::GetInterface(const nsIID & aIID, void **aResult)
|
|||
return QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
// nsIHttpEventSink
|
||||
// nsIChannelEventSink
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsSubmissionElement::OnRedirect(nsIHttpChannel *aHttpChannel,
|
||||
nsIChannel *aNewChannel)
|
||||
nsXFormsSubmissionElement::OnChannelRedirect(nsIChannel *aOldChannel,
|
||||
nsIChannel *aNewChannel,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNewChannel);
|
||||
NS_PRECONDITION(aNewChannel, "Redirect without a channel?");
|
||||
nsCOMPtr<nsIURI> newURI;
|
||||
nsresult rv = aNewChannel->GetURI(getter_AddRefs(newURI));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -46,12 +46,13 @@
|
|||
#include "nsIModelElementPrivate.h"
|
||||
#include "nsIXFormsSubmitElement.h"
|
||||
#include "nsIXFormsSubmissionElement.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
|
||||
class nsIMultiplexInputStream;
|
||||
class nsIDOMElement;
|
||||
class nsIChannel;
|
||||
class nsIURI;
|
||||
class nsIFile;
|
||||
class nsCString;
|
||||
class nsString;
|
||||
|
@ -66,14 +67,14 @@ class SubmissionAttachmentArray;
|
|||
class nsXFormsSubmissionElement : public nsXFormsStubElement,
|
||||
public nsIRequestObserver,
|
||||
public nsIXFormsSubmissionElement,
|
||||
public nsIHttpEventSink,
|
||||
public nsIChannelEventSink,
|
||||
public nsIInterfaceRequestor
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSIXFORMSSUBMISSIONELEMENT
|
||||
NS_DECL_NSIHTTPEVENTSINK
|
||||
NS_DECL_NSICHANNELEVENTSINK
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
nsXFormsSubmissionElement()
|
||||
|
|
|
@ -283,7 +283,7 @@ NS_INTERFACE_MAP_BEGIN(nsXMLHttpRequest)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIHttpEventSink)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIChannelEventSink)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIProgressEventSink)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
|
@ -1781,13 +1781,14 @@ nsXMLHttpRequest::ChangeState(PRUint32 aState, PRBool aBroadcast,
|
|||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// nsIHttpEventSink methods:
|
||||
// nsIChannelEventSink methods:
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::OnRedirect(nsIHttpChannel *aHttpChannel,
|
||||
nsIChannel *aNewChannel)
|
||||
nsXMLHttpRequest::OnChannelRedirect(nsIChannel *aOldChannel,
|
||||
nsIChannel *aNewChannel,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNewChannel);
|
||||
NS_PRECONDITION(aNewChannel, "Redirect without a channel?");
|
||||
|
||||
if (mScriptContext && !(mState & XML_HTTP_REQUEST_XSITEENABLED)) {
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
#include "nsISupportsArray.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIHttpHeaderVisitor.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
|
@ -68,7 +68,7 @@ class nsXMLHttpRequest : public nsIXMLHttpRequest,
|
|||
public nsIDOMLoadListener,
|
||||
public nsIDOMEventTarget,
|
||||
public nsIStreamListener,
|
||||
public nsIHttpEventSink,
|
||||
public nsIChannelEventSink,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIProgressEventSink,
|
||||
public nsSupportsWeakReference
|
||||
|
@ -104,8 +104,8 @@ public:
|
|||
// nsIRequestObserver
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
|
||||
// nsIHttpEventSink
|
||||
NS_DECL_NSIHTTPEVENTSINK
|
||||
// nsIChannelEventSink
|
||||
NS_DECL_NSICHANNELEVENTSINK
|
||||
|
||||
// nsIProgressEventSink
|
||||
NS_DECL_NSIPROGRESSEVENTSINK
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#
|
||||
# vim:set noet:
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
|
@ -107,6 +107,7 @@ XPIDLSRCS = \
|
|||
nsIAuthModule.idl \
|
||||
nsIContentSniffer.idl \
|
||||
nsIAuthPromptProvider.idl \
|
||||
nsIChannelEventSink.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim:set ts=4 sw=4 sts=4 cin: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Gagan Saksena <gagan@netscape.com> (original author)
|
||||
* Darin Fisher <darin@netscape.com>
|
||||
* Christian Biesinger <cbiesinger@web.de>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIChannel;
|
||||
|
||||
/**
|
||||
* Implement this interface to receive control over various channel events.
|
||||
* Channels will try to get this interface from a channel's
|
||||
* notificationCallbacks or, if not available there, from the loadGroup's
|
||||
* notificationCallbacks.
|
||||
*
|
||||
* These methods are called before onStartRequest, and should be handled
|
||||
* SYNCHRONOUSLY.
|
||||
*/
|
||||
[scriptable, uuid(6757d790-2916-498e-aaca-6b668a956875)]
|
||||
interface nsIChannelEventSink : nsISupports
|
||||
{
|
||||
/**
|
||||
* This is a temporary redirect. New requests for this resource should
|
||||
* continue to use the URI of the old channel.
|
||||
*
|
||||
* The new URI may be identical to the old one.
|
||||
*/
|
||||
const unsigned long REDIRECT_TEMPORARY = 1 << 0;
|
||||
|
||||
/**
|
||||
* This is a permanent redirect. New requests for this resource should use
|
||||
* the URI of the new channel (This might be an HTTP 301 reponse).
|
||||
* If this flag is not set, this is a temporary redirect.
|
||||
*
|
||||
* The new URI may be identical to the old one.
|
||||
*/
|
||||
const unsigned long REDIRECT_PERMANENT = 1 << 1;
|
||||
|
||||
/**
|
||||
* This is an internal redirect, i.e. it was not initiated by the remote
|
||||
* server, but is specific to the channel implementation.
|
||||
*
|
||||
* The new URI may be identical to the old one.
|
||||
*/
|
||||
const unsigned long REDIRECT_INTERNAL = 1 << 2;
|
||||
|
||||
/**
|
||||
* Called when a redirect occurs. This may happen due to an HTTP 3xx status
|
||||
* code.
|
||||
*
|
||||
* @param oldChannel
|
||||
* The channel that's being redirected.
|
||||
* @param newChannel
|
||||
* The new channel. This channel is not opened yet.
|
||||
* @param flags
|
||||
* Flags indicating the type of redirect. A bitmask consisting
|
||||
* of flags from above.
|
||||
* One of REDIRECT_TEMPORARY and REDIRECT_PERMANENT will always be
|
||||
* set.
|
||||
*
|
||||
* @throw <any> Throwing an exception will cancel the load. No network
|
||||
* request for the new channel will be made.
|
||||
*/
|
||||
void onChannelRedirect(in nsIChannel oldChannel,
|
||||
in nsIChannel newChannel,
|
||||
in unsigned long flags);
|
||||
};
|
|
@ -64,7 +64,7 @@ NS_IMPL_ISUPPORTS5(nsURIChecker,
|
|||
nsIURIChecker,
|
||||
nsIRequest,
|
||||
nsIStreamListener,
|
||||
nsIHttpEventSink,
|
||||
nsIChannelEventSink,
|
||||
nsIInterfaceRequestor)
|
||||
|
||||
nsURIChecker::nsURIChecker()
|
||||
|
@ -358,11 +358,13 @@ nsURIChecker::GetInterface(const nsIID & aIID, void **aResult)
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsIHttpEventSink methods:
|
||||
// nsIChannelEventSink methods:
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURIChecker::OnRedirect(nsIHttpChannel *aHttpChannel, nsIChannel *aNewChannel)
|
||||
nsURIChecker::OnChannelRedirect(nsIChannel *aOldChannel,
|
||||
nsIChannel *aNewChannel,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
// We have a new channel
|
||||
mChannel = aNewChannel;
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "nsIURIChecker.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIURI.h"
|
||||
|
@ -52,7 +52,7 @@
|
|||
|
||||
class nsURIChecker : public nsIURIChecker,
|
||||
public nsIStreamListener,
|
||||
public nsIHttpEventSink,
|
||||
public nsIChannelEventSink,
|
||||
public nsIInterfaceRequestor
|
||||
{
|
||||
public:
|
||||
|
@ -64,7 +64,7 @@ public:
|
|||
NS_DECL_NSIREQUEST
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIHTTPEVENTSINK
|
||||
NS_DECL_NSICHANNELEVENTSINK
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
protected:
|
||||
|
|
|
@ -53,6 +53,9 @@ interface nsIURI;
|
|||
*
|
||||
* These methods are called before onStartRequest, and should be handled
|
||||
* SYNCHRONOUSLY.
|
||||
*
|
||||
* @deprecated Newly written code should use nsIChannelEventSink instead of this
|
||||
* interface.
|
||||
*/
|
||||
[scriptable, uuid(9475a6af-6352-4251-90f9-d65b1cd2ea15)]
|
||||
interface nsIHttpEventSink : nsISupports
|
||||
|
|
|
@ -1965,9 +1965,20 @@ nsHttpChannel::ProcessRedirection(PRUint32 redirectType)
|
|||
|
||||
// call out to the event sink to notify it of this redirection.
|
||||
if (mHttpEventSink) {
|
||||
// Note: mHttpEventSink is only kept for compatibility with pre-1.8
|
||||
// versions.
|
||||
rv = mHttpEventSink->OnRedirect(this, newChannel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
if (mChannelEventSink) {
|
||||
PRUint32 flags;
|
||||
if (redirectType == 301) // Moved Permanently
|
||||
flags = nsIChannelEventSink::REDIRECT_PERMANENT;
|
||||
else
|
||||
flags = nsIChannelEventSink::REDIRECT_TEMPORARY;
|
||||
rv = mChannelEventSink->OnChannelRedirect(this, newChannel, flags);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
// XXX we used to talk directly with the script security manager, but that
|
||||
// should really be handled by the event sink implementation.
|
||||
|
||||
|
@ -3093,6 +3104,7 @@ nsHttpChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *context)
|
|||
|
||||
// Initialize callback interfaces
|
||||
GetCallback(mHttpEventSink);
|
||||
GetCallback(mChannelEventSink);
|
||||
GetCallback(mProgressSink);
|
||||
|
||||
// we want to grab a reference to the calling thread's event queue at
|
||||
|
@ -3826,6 +3838,7 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st
|
|||
|
||||
mCallbacks = nsnull;
|
||||
mHttpEventSink = nsnull;
|
||||
mChannelEventSink = nsnull;
|
||||
mProgressSink = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "nsIHttpChannelInternal.h"
|
||||
#include "nsIHttpHeaderVisitor.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIURI.h"
|
||||
|
@ -206,6 +207,7 @@ private:
|
|||
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
||||
nsCOMPtr<nsIProgressEventSink> mProgressSink;
|
||||
nsCOMPtr<nsIHttpEventSink> mHttpEventSink;
|
||||
nsCOMPtr<nsIChannelEventSink> mChannelEventSink;
|
||||
nsCOMPtr<nsIInputStream> mUploadStream;
|
||||
nsCOMPtr<nsIURI> mReferrer;
|
||||
nsCOMPtr<nsISupports> mSecurityInfo;
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
#include "nsIHttpChannel.h"
|
||||
#include "nsIHttpChannelInternal.h"
|
||||
#include "nsIHttpHeaderVisitor.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIDNSService.h"
|
||||
|
@ -199,34 +199,37 @@ URLLoadInfo::~URLLoadInfo()
|
|||
NS_IMPL_THREADSAFE_ISUPPORTS0(URLLoadInfo)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TestHttpEventSink
|
||||
// TestChannelEventSink
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class TestHttpEventSink : public nsIHttpEventSink
|
||||
class TestChannelEventSink : public nsIChannelEventSink
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIHTTPEVENTSINK
|
||||
NS_DECL_NSICHANNELEVENTSINK
|
||||
|
||||
TestHttpEventSink();
|
||||
virtual ~TestHttpEventSink();
|
||||
TestChannelEventSink();
|
||||
virtual ~TestChannelEventSink();
|
||||
};
|
||||
|
||||
TestHttpEventSink::TestHttpEventSink()
|
||||
TestChannelEventSink::TestChannelEventSink()
|
||||
{
|
||||
}
|
||||
|
||||
TestHttpEventSink::~TestHttpEventSink()
|
||||
TestChannelEventSink::~TestChannelEventSink()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS1(TestHttpEventSink, nsIHttpEventSink)
|
||||
NS_IMPL_ISUPPORTS1(TestChannelEventSink, nsIChannelEventSink)
|
||||
|
||||
NS_IMETHODIMP
|
||||
TestHttpEventSink::OnRedirect(nsIHttpChannel *channel, nsIChannel *newChannel)
|
||||
TestChannelEventSink::OnChannelRedirect(nsIChannel *channel,
|
||||
nsIChannel *newChannel,
|
||||
PRUint32 flags)
|
||||
{
|
||||
LOG(("\n+++ TestHTTPEventSink::OnRedirect +++\n"));
|
||||
LOG(("\n+++ TestChannelEventSink::OnChannelRedirect (with flags %x) +++\n",
|
||||
flags));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -560,10 +563,10 @@ public:
|
|||
NS_IMETHOD GetInterface(const nsIID& iid, void* *result) {
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
if (iid.Equals(NS_GET_IID(nsIHttpEventSink))) {
|
||||
TestHttpEventSink *sink;
|
||||
if (iid.Equals(NS_GET_IID(nsIChannelEventSink))) {
|
||||
TestChannelEventSink *sink;
|
||||
|
||||
sink = new TestHttpEventSink();
|
||||
sink = new TestChannelEventSink();
|
||||
if (sink == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(sink);
|
||||
|
|
|
@ -230,7 +230,7 @@ NS_INTERFACE_MAP_BEGIN(nsDocLoader)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIWebProgress)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIProgressEventSink)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIHttpEventSink)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIChannelEventSink)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISecurityEventSink)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsPriority)
|
||||
if (aIID.Equals(kThisImplCID))
|
||||
|
@ -1380,8 +1380,9 @@ PRInt64 nsDocLoader::CalculateMaxProgress()
|
|||
return max;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocLoader::OnRedirect(nsIHttpChannel *aOldChannel,
|
||||
nsIChannel *aNewChannel)
|
||||
NS_IMETHODIMP nsDocLoader::OnChannelRedirect(nsIChannel *aOldChannel,
|
||||
nsIChannel *aNewChannel,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
if (aOldChannel)
|
||||
{
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
#include "nsIProgressEventSink.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsISecurityEventSink.h"
|
||||
#include "nsISupportsPriority.h"
|
||||
#include "nsInt64.h"
|
||||
|
@ -82,7 +82,7 @@ class nsDocLoader : public nsIDocumentLoader,
|
|||
public nsIProgressEventSink,
|
||||
public nsIWebProgress,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIHttpEventSink,
|
||||
public nsIChannelEventSink,
|
||||
public nsISecurityEventSink,
|
||||
public nsISupportsPriority
|
||||
{
|
||||
|
@ -115,7 +115,7 @@ public:
|
|||
NS_DECL_NSIWEBPROGRESS
|
||||
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
NS_DECL_NSIHTTPEVENTSINK
|
||||
NS_DECL_NSICHANNELEVENTSINK
|
||||
NS_DECL_NSISUPPORTSPRIORITY
|
||||
|
||||
// Implementation specific methods...
|
||||
|
|
|
@ -2770,7 +2770,7 @@ SetContainer__10nsWebShellP20nsIWebShellContainer
|
|||
GetIID__14nsIDOMDocument
|
||||
GetIID__9nsIPrompt
|
||||
GetIID__13nsIAuthPrompt
|
||||
GetIID__16nsIHttpEventSink
|
||||
GetIID__16nsIChannelEventSink
|
||||
QueryInterface__16nsWebShellWindowRC4nsIDPPv
|
||||
GetIID__17nsIWebShellWindow
|
||||
GetIID__12nsIXULWindow
|
||||
|
|
Загрузка…
Ссылка в новой задаче