Bug 1885993 - Enable the BackupService initializer on Nightly by default. r=backup...
[gecko.git] / netwerk / base / nsIChannelEventSink.idl
blob56484e933f985324584130df186015551fba109a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim:set ts=4 sw=4 sts=4 cin: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsISupports.idl"
9 interface nsIChannel;
10 interface nsIAsyncVerifyRedirectCallback;
12 /**
13 * Implement this interface to receive control over various channel events.
14 * Channels will try to get this interface from a channel's
15 * notificationCallbacks or, if not available there, from the loadGroup's
16 * notificationCallbacks.
18 * These methods are called before onStartRequest.
20 [scriptable, uuid(0197720d-37ed-4e75-8956-d0d296e4d8a6)]
21 interface nsIChannelEventSink : nsISupports
23 /**
24 * This is a temporary redirect. New requests for this resource should
25 * continue to use the URI of the old channel.
27 * The new URI may be identical to the old one.
29 const unsigned long REDIRECT_TEMPORARY = 1 << 0;
31 /**
32 * This is a permanent redirect. New requests for this resource should use
33 * the URI of the new channel (This might be an HTTP 301 reponse).
34 * If this flag is not set, this is a temporary redirect.
36 * The new URI may be identical to the old one.
38 const unsigned long REDIRECT_PERMANENT = 1 << 1;
40 /**
41 * This is an internal redirect, i.e. it was not initiated by the remote
42 * server, but is specific to the channel implementation.
44 * The new URI may be identical to the old one.
46 const unsigned long REDIRECT_INTERNAL = 1 << 2;
48 /**
49 * This is a special-cased redirect coming from hitting HSTS upgrade
50 * redirect from http to https only. In some cases this type of redirect
51 * may be considered as safe despite not being the-same-origin redirect.
53 const unsigned long REDIRECT_STS_UPGRADE = 1 << 3;
55 /**
56 * This is a internal redirect used to handle http authentication retries.
57 * Upon receiving a 401 or 407 the channel gets redirected to a new channel
58 * (same URL) that performs the request with the appropriate credentials.
59 * Auth retry to the server must be made after redirecting to a new channel
61 const unsigned long REDIRECT_AUTH_RETRY = 1 << 4;
63 /**
64 * Called when a redirect occurs. This may happen due to an HTTP 3xx status
65 * code. The purpose of this method is to notify the sink that a redirect
66 * is about to happen, but also to give the sink the right to veto the
67 * redirect by throwing or passing a failure-code in the callback.
69 * Note that vetoing the redirect simply means that |newChannel| will not
70 * be opened. It is important to understand that |oldChannel| will continue
71 * loading as if it received a HTTP 200, which includes notifying observers
72 * and possibly display or process content attached to the HTTP response.
73 * If the sink wants to prevent this loading it must explicitly deal with
74 * it, e.g. by calling |oldChannel->Cancel()|
76 * There is a certain freedom in implementing this method:
78 * If the return-value indicates success, a callback on |callback| is
79 * required. This callback can be done from within asyncOnChannelRedirect
80 * (effectively making the call synchronous) or at some point later
81 * (making the call asynchronous). Repeat: A callback must be done
82 * if this method returns successfully.
84 * If the return value indicates error (method throws an exception)
85 * the redirect is vetoed and no callback must be done. Repeat: No
86 * callback must be done if this method throws!
88 * NOTE: originalURI isn't yet set on the new channel when
89 * asyncOnChannelRedirect is called.
91 * @see nsIAsyncVerifyRedirectCallback::onRedirectVerifyCallback()
93 * @param oldChannel
94 * The channel that's being redirected.
95 * @param newChannel
96 * The new channel. This channel is not opened yet.
97 * @param flags
98 * Flags indicating the type of redirect. A bitmask consisting
99 * of flags from above.
100 * One of REDIRECT_TEMPORARY and REDIRECT_PERMANENT will always be
101 * set.
102 * @param callback
103 * Object to inform about the async result of this method
105 * @throw <any> Throwing an exception will cause the redirect to be
106 * cancelled
108 void asyncOnChannelRedirect(in nsIChannel oldChannel,
109 in nsIChannel newChannel,
110 in unsigned long flags,
111 in nsIAsyncVerifyRedirectCallback callback);