Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
* License, v. 2.0. If a copy of the MPL was not distributed with this
4
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#include "nsISupports.idl"
7
8
interface nsILoadGroup;
9
10
typedef unsigned long nsLoadFlags;
11
12
/**
13
* nsIRequest
14
*/
15
[scriptable, uuid(ef6bfbd2-fd46-48d8-96b7-9f8f0fd387fe)]
16
interface nsIRequest : nsISupports
17
{
18
/**
19
* The name of the request. Often this is the URI of the request.
20
*/
21
readonly attribute AUTF8String name;
22
23
/**
24
* Indicates whether the request is pending. nsIRequest::isPending is
25
* true when there is an outstanding asynchronous event that will make
26
* the request no longer be pending. Requests do not necessarily start
27
* out pending; in some cases, requests have to be explicitly initiated
28
* (e.g. nsIChannel implementations are only pending once asyncOpen
29
* returns successfully).
30
*
31
* Requests can become pending multiple times during their lifetime.
32
*
33
* @return TRUE if the request has yet to reach completion.
34
* @return FALSE if the request has reached completion (e.g., after
35
* OnStopRequest has fired).
36
* @note Suspended requests are still considered pending.
37
*/
38
boolean isPending();
39
40
/**
41
* The error status associated with the request.
42
*/
43
readonly attribute nsresult status;
44
45
/**
46
* Cancels the current request. This will close any open input or
47
* output streams and terminate any async requests. Users should
48
* normally pass NS_BINDING_ABORTED, although other errors may also
49
* be passed. The error passed in will become the value of the
50
* status attribute.
51
*
52
* Implementations must not send any notifications (e.g. via
53
* nsIRequestObserver) synchronously from this function. Similarly,
54
* removal from the load group (if any) must also happen asynchronously.
55
*
56
* Requests that use nsIStreamListener must not call onDataAvailable
57
* anymore after cancel has been called.
58
*
59
* @param aStatus the reason for canceling this request.
60
*
61
* NOTE: most nsIRequest implementations expect aStatus to be a
62
* failure code; however, some implementations may allow aStatus to
63
* be a success code such as NS_OK. In general, aStatus should be
64
* a failure code.
65
*/
66
void cancel(in nsresult aStatus);
67
68
/**
69
* Suspends the current request. This may have the effect of closing
70
* any underlying transport (in order to free up resources), although
71
* any open streams remain logically opened and will continue delivering
72
* data when the transport is resumed.
73
*
74
* Calling cancel() on a suspended request must not send any
75
* notifications (such as onstopRequest) until the request is resumed.
76
*
77
* NOTE: some implementations are unable to immediately suspend, and
78
* may continue to deliver events already posted to an event queue. In
79
* general, callers should be capable of handling events even after
80
* suspending a request.
81
*/
82
void suspend();
83
84
/**
85
* Resumes the current request. This may have the effect of re-opening
86
* any underlying transport and will resume the delivery of data to
87
* any open streams.
88
*/
89
void resume();
90
91
/**
92
* The load group of this request. While pending, the request is a
93
* member of the load group. It is the responsibility of the request
94
* to implement this policy.
95
*/
96
attribute nsILoadGroup loadGroup;
97
98
/**
99
* The load flags of this request. Bits 0-15 are reserved.
100
*
101
* When added to a load group, this request's load flags are merged with
102
* the load flags of the load group.
103
*/
104
attribute nsLoadFlags loadFlags;
105
106
/**
107
* Mask defining the bits reserved for nsIRequest LoadFlags
108
*/
109
const unsigned long LOAD_REQUESTMASK = 0xFFFF;
110
111
/**************************************************************************
112
* Listed below are the various load flags which may be or'd together.
113
*/
114
115
/**
116
* No special load flags:
117
*/
118
const unsigned long LOAD_NORMAL = 0;
119
120
/**
121
* Do not deliver status notifications to the nsIProgressEventSink and
122
* do not block the loadgroup from completing (should this load belong to one).
123
* Note: Progress notifications will still be delivered.
124
*/
125
const unsigned long LOAD_BACKGROUND = 1 << 0;
126
127
/**
128
* This flag marks the request as being made to load the data for an html
129
* <object> tag. This means that the LOAD_DOCUMENT_URI flag may be set after
130
* the channel has been provided with the MIME type.
131
*/
132
const unsigned long LOAD_HTML_OBJECT_DATA = 1 << 1;
133
134
/**
135
* This flag marks the request as belonging to a document that requires access
136
* to the document.cookies API.
137
*/
138
const unsigned long LOAD_DOCUMENT_NEEDS_COOKIE = 1 << 2;
139
140
141
/**
142
* Set this flag to disable TRR for this request.
143
*/
144
const unsigned long LOAD_DISABLE_TRR = 1 << 3;
145
146
/**************************************************************************
147
* The following flags control the flow of data into the cache.
148
*/
149
150
/**
151
* This flag prevents caching of any kind. It does not, however, prevent
152
* cached content from being used to satisfy this request.
153
*/
154
const unsigned long INHIBIT_CACHING = 1 << 7;
155
156
/**
157
* This flag prevents caching on disk (or other persistent media), which
158
* may be needed to preserve privacy.
159
*/
160
const unsigned long INHIBIT_PERSISTENT_CACHING = 1 << 8;
161
162
/**************************************************************************
163
* The following flags control what happens when the cache contains data
164
* that could perhaps satisfy this request. They are listed in descending
165
* order of precidence.
166
*/
167
168
/**
169
* Force an end-to-end download of content data from the origin server.
170
* This flag is used for a shift-reload.
171
*/
172
const unsigned long LOAD_BYPASS_CACHE = 1 << 9;
173
174
/**
175
* Attempt to force a load from the cache, bypassing ALL validation logic
176
* (note: this is stronger than VALIDATE_NEVER, which still validates for
177
* certain conditions).
178
*
179
* If the resource is not present in cache, it will be loaded from the
180
* network. Combine this flag with LOAD_ONLY_FROM_CACHE if you wish to
181
* perform cache-only loads without validation checks.
182
*
183
* This flag is used when browsing via history. It is not recommended for
184
* normal browsing as it may likely violate reasonable assumptions made by
185
* the server and confuse users.
186
*/
187
const unsigned long LOAD_FROM_CACHE = 1 << 10;
188
189
/**
190
* The following flags control the frequency of cached content validation
191
* when neither LOAD_BYPASS_CACHE or LOAD_FROM_CACHE are set. By default,
192
* cached content is automatically validated if necessary before reuse.
193
*
194
* VALIDATE_ALWAYS forces validation of any cached content independent of
195
* its expiration time (unless it is https with Cache-Control: immutable)
196
*
197
* VALIDATE_NEVER disables validation of cached content, unless it arrived
198
* with the "Cache: no-store" header, or arrived via HTTPS with the
199
* "Cache: no-cache" header.
200
*
201
* VALIDATE_ONCE_PER_SESSION disables validation of expired content,
202
* provided it has already been validated (at least once) since the start
203
* of this session.
204
*
205
* NOTE TO IMPLEMENTORS:
206
* These flags are intended for normal browsing, and they should therefore
207
* not apply to content that must be validated before each use. Consider,
208
* for example, a HTTP response with a "Cache-control: no-cache" header.
209
* According to RFC2616, this response must be validated before it can
210
* be taken from a cache. Breaking this requirement could result in
211
* incorrect and potentially undesirable side-effects.
212
*/
213
const unsigned long VALIDATE_ALWAYS = 1 << 11;
214
const unsigned long VALIDATE_NEVER = 1 << 12;
215
const unsigned long VALIDATE_ONCE_PER_SESSION = 1 << 13;
216
217
/**
218
* When set, this flag indicates that no user-specific data should be added
219
* to the request when opened. This means that things like authorization
220
* tokens or cookie headers should not be added.
221
*/
222
const unsigned long LOAD_ANONYMOUS = 1 << 14;
223
224
/**
225
* When set, this flag indicates that caches of network connections,
226
* particularly HTTP persistent connections, should not be used.
227
* Use this together with LOAD_INITIAL_DOCUMENT_URI as otherwise it has no
228
* effect.
229
*/
230
const unsigned long LOAD_FRESH_CONNECTION = 1 << 15;
231
};