nsIRequest.idl 8.3 KB

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