michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* vim:set ts=4 sw=4 sts=4 cin: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsIChannel; michael@0: interface nsIAsyncVerifyRedirectCallback; michael@0: michael@0: /** michael@0: * Implement this interface to receive control over various channel events. michael@0: * Channels will try to get this interface from a channel's michael@0: * notificationCallbacks or, if not available there, from the loadGroup's michael@0: * notificationCallbacks. michael@0: * michael@0: * These methods are called before onStartRequest. michael@0: */ michael@0: [scriptable, uuid(a430d870-df77-4502-9570-d46a8de33154)] michael@0: interface nsIChannelEventSink : nsISupports michael@0: { michael@0: /** michael@0: * This is a temporary redirect. New requests for this resource should michael@0: * continue to use the URI of the old channel. michael@0: * michael@0: * The new URI may be identical to the old one. michael@0: */ michael@0: const unsigned long REDIRECT_TEMPORARY = 1 << 0; michael@0: michael@0: /** michael@0: * This is a permanent redirect. New requests for this resource should use michael@0: * the URI of the new channel (This might be an HTTP 301 reponse). michael@0: * If this flag is not set, this is a temporary redirect. michael@0: * michael@0: * The new URI may be identical to the old one. michael@0: */ michael@0: const unsigned long REDIRECT_PERMANENT = 1 << 1; michael@0: michael@0: /** michael@0: * This is an internal redirect, i.e. it was not initiated by the remote michael@0: * server, but is specific to the channel implementation. michael@0: * michael@0: * The new URI may be identical to the old one. michael@0: */ michael@0: const unsigned long REDIRECT_INTERNAL = 1 << 2; michael@0: michael@0: /** michael@0: * Called when a redirect occurs. This may happen due to an HTTP 3xx status michael@0: * code. The purpose of this method is to notify the sink that a redirect michael@0: * is about to happen, but also to give the sink the right to veto the michael@0: * redirect by throwing or passing a failure-code in the callback. michael@0: * michael@0: * Note that vetoing the redirect simply means that |newChannel| will not michael@0: * be opened. It is important to understand that |oldChannel| will continue michael@0: * loading as if it received a HTTP 200, which includes notifying observers michael@0: * and possibly display or process content attached to the HTTP response. michael@0: * If the sink wants to prevent this loading it must explicitly deal with michael@0: * it, e.g. by calling |oldChannel->Cancel()| michael@0: * michael@0: * There is a certain freedom in implementing this method: michael@0: * michael@0: * If the return-value indicates success, a callback on |callback| is michael@0: * required. This callback can be done from within asyncOnChannelRedirect michael@0: * (effectively making the call synchronous) or at some point later michael@0: * (making the call asynchronous). Repeat: A callback must be done michael@0: * if this method returns successfully. michael@0: * michael@0: * If the return value indicates error (method throws an exception) michael@0: * the redirect is vetoed and no callback must be done. Repeat: No michael@0: * callback must be done if this method throws! michael@0: * michael@0: * @see nsIAsyncVerifyRedirectCallback::onRedirectVerifyCallback() michael@0: * michael@0: * @param oldChannel michael@0: * The channel that's being redirected. michael@0: * @param newChannel michael@0: * The new channel. This channel is not opened yet. michael@0: * @param flags michael@0: * Flags indicating the type of redirect. A bitmask consisting michael@0: * of flags from above. michael@0: * One of REDIRECT_TEMPORARY and REDIRECT_PERMANENT will always be michael@0: * set. michael@0: * @param callback michael@0: * Object to inform about the async result of this method michael@0: * michael@0: * @throw Throwing an exception will cause the redirect to be michael@0: * cancelled michael@0: */ michael@0: void asyncOnChannelRedirect(in nsIChannel oldChannel, michael@0: in nsIChannel newChannel, michael@0: in unsigned long flags, michael@0: in nsIAsyncVerifyRedirectCallback callback); michael@0: };