Source code

Revision control

Other Tools

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/. */
6
7
#include "nsISupports.idl"
8
9
interface nsIChannel;
10
interface nsIAsyncVerifyRedirectCallback;
11
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.
17
*
18
* These methods are called before onStartRequest.
19
*/
20
[scriptable, uuid(0197720d-37ed-4e75-8956-d0d296e4d8a6)]
21
interface nsIChannelEventSink : nsISupports
22
{
23
/**
24
* This is a temporary redirect. New requests for this resource should
25
* continue to use the URI of the old channel.
26
*
27
* The new URI may be identical to the old one.
28
*/
29
const unsigned long REDIRECT_TEMPORARY = 1 << 0;
30
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.
35
*
36
* The new URI may be identical to the old one.
37
*/
38
const unsigned long REDIRECT_PERMANENT = 1 << 1;
39
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.
43
*
44
* The new URI may be identical to the old one.
45
*/
46
const unsigned long REDIRECT_INTERNAL = 1 << 2;
47
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.
52
*/
53
const unsigned long REDIRECT_STS_UPGRADE = 1 << 3;
54
55
/**
56
* Called when a redirect occurs. This may happen due to an HTTP 3xx status
57
* code. The purpose of this method is to notify the sink that a redirect
58
* is about to happen, but also to give the sink the right to veto the
59
* redirect by throwing or passing a failure-code in the callback.
60
*
61
* Note that vetoing the redirect simply means that |newChannel| will not
62
* be opened. It is important to understand that |oldChannel| will continue
63
* loading as if it received a HTTP 200, which includes notifying observers
64
* and possibly display or process content attached to the HTTP response.
65
* If the sink wants to prevent this loading it must explicitly deal with
66
* it, e.g. by calling |oldChannel->Cancel()|
67
*
68
* There is a certain freedom in implementing this method:
69
*
70
* If the return-value indicates success, a callback on |callback| is
71
* required. This callback can be done from within asyncOnChannelRedirect
72
* (effectively making the call synchronous) or at some point later
73
* (making the call asynchronous). Repeat: A callback must be done
74
* if this method returns successfully.
75
*
76
* If the return value indicates error (method throws an exception)
77
* the redirect is vetoed and no callback must be done. Repeat: No
78
* callback must be done if this method throws!
79
*
80
* @see nsIAsyncVerifyRedirectCallback::onRedirectVerifyCallback()
81
*
82
* @param oldChannel
83
* The channel that's being redirected.
84
* @param newChannel
85
* The new channel. This channel is not opened yet.
86
* @param flags
87
* Flags indicating the type of redirect. A bitmask consisting
88
* of flags from above.
89
* One of REDIRECT_TEMPORARY and REDIRECT_PERMANENT will always be
90
* set.
91
* @param callback
92
* Object to inform about the async result of this method
93
*
94
* @throw <any> Throwing an exception will cause the redirect to be
95
* cancelled
96
*/
97
void asyncOnChannelRedirect(in nsIChannel oldChannel,
98
in nsIChannel newChannel,
99
in unsigned long flags,
100
in nsIAsyncVerifyRedirectCallback callback);
101
};