michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 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 nsILoadGroup; michael@0: michael@0: typedef unsigned long nsLoadFlags; michael@0: michael@0: /** michael@0: * nsIRequest michael@0: */ michael@0: [scriptable, uuid(ef6bfbd2-fd46-48d8-96b7-9f8f0fd387fe)] michael@0: interface nsIRequest : nsISupports michael@0: { michael@0: /** michael@0: * The name of the request. Often this is the URI of the request. michael@0: */ michael@0: readonly attribute AUTF8String name; michael@0: michael@0: /** michael@0: * Indicates whether the request is pending. nsIRequest::isPending is michael@0: * true when there is an outstanding asynchronous event that will make michael@0: * the request no longer be pending. Requests do not necessarily start michael@0: * out pending; in some cases, requests have to be explicitly initiated michael@0: * (e.g. nsIChannel implementations are only pending once asyncOpen michael@0: * returns successfully). michael@0: * michael@0: * Requests can become pending multiple times during their lifetime. michael@0: * michael@0: * @return TRUE if the request has yet to reach completion. michael@0: * @return FALSE if the request has reached completion (e.g., after michael@0: * OnStopRequest has fired). michael@0: * @note Suspended requests are still considered pending. michael@0: */ michael@0: boolean isPending(); michael@0: michael@0: /** michael@0: * The error status associated with the request. michael@0: */ michael@0: readonly attribute nsresult status; michael@0: michael@0: /** michael@0: * Cancels the current request. This will close any open input or michael@0: * output streams and terminate any async requests. Users should michael@0: * normally pass NS_BINDING_ABORTED, although other errors may also michael@0: * be passed. The error passed in will become the value of the michael@0: * status attribute. michael@0: * michael@0: * Implementations must not send any notifications (e.g. via michael@0: * nsIRequestObserver) synchronously from this function. Similarly, michael@0: * removal from the load group (if any) must also happen asynchronously. michael@0: * michael@0: * Requests that use nsIStreamListener must not call onDataAvailable michael@0: * anymore after cancel has been called. michael@0: * michael@0: * @param aStatus the reason for canceling this request. michael@0: * michael@0: * NOTE: most nsIRequest implementations expect aStatus to be a michael@0: * failure code; however, some implementations may allow aStatus to michael@0: * be a success code such as NS_OK. In general, aStatus should be michael@0: * a failure code. michael@0: */ michael@0: void cancel(in nsresult aStatus); michael@0: michael@0: /** michael@0: * Suspends the current request. This may have the effect of closing michael@0: * any underlying transport (in order to free up resources), although michael@0: * any open streams remain logically opened and will continue delivering michael@0: * data when the transport is resumed. michael@0: * michael@0: * Calling cancel() on a suspended request must not send any michael@0: * notifications (such as onstopRequest) until the request is resumed. michael@0: * michael@0: * NOTE: some implementations are unable to immediately suspend, and michael@0: * may continue to deliver events already posted to an event queue. In michael@0: * general, callers should be capable of handling events even after michael@0: * suspending a request. michael@0: */ michael@0: void suspend(); michael@0: michael@0: /** michael@0: * Resumes the current request. This may have the effect of re-opening michael@0: * any underlying transport and will resume the delivery of data to michael@0: * any open streams. michael@0: */ michael@0: void resume(); michael@0: michael@0: /** michael@0: * The load group of this request. While pending, the request is a michael@0: * member of the load group. It is the responsibility of the request michael@0: * to implement this policy. michael@0: */ michael@0: attribute nsILoadGroup loadGroup; michael@0: michael@0: /** michael@0: * The load flags of this request. Bits 0-15 are reserved. michael@0: * michael@0: * When added to a load group, this request's load flags are merged with michael@0: * the load flags of the load group. michael@0: */ michael@0: attribute nsLoadFlags loadFlags; michael@0: michael@0: /** michael@0: * Mask defining the bits reserved for nsIRequest LoadFlags michael@0: */ michael@0: const unsigned long LOAD_REQUESTMASK = 0xFFFF; michael@0: michael@0: /************************************************************************** michael@0: * Listed below are the various load flags which may be or'd together. michael@0: */ michael@0: michael@0: /** michael@0: * No special load flags: michael@0: */ michael@0: const unsigned long LOAD_NORMAL = 0; michael@0: michael@0: /** michael@0: * Don't deliver status notifications to the nsIProgressEventSink, or keep michael@0: * this load from completing the nsILoadGroup it may belong to. michael@0: */ michael@0: const unsigned long LOAD_BACKGROUND = 1 << 0; michael@0: michael@0: /************************************************************************** michael@0: * The following flags control the flow of data into the cache. michael@0: */ michael@0: michael@0: /** michael@0: * This flag prevents loading of the request with an HTTP pipeline. michael@0: * Generally this is because the resource is expected to take a michael@0: * while to load and may cause head of line blocking problems. michael@0: */ michael@0: const unsigned long INHIBIT_PIPELINE = 1 << 6; michael@0: michael@0: /** michael@0: * This flag prevents caching of any kind. It does not, however, prevent michael@0: * cached content from being used to satisfy this request. michael@0: */ michael@0: const unsigned long INHIBIT_CACHING = 1 << 7; michael@0: michael@0: /** michael@0: * This flag prevents caching on disk (or other persistent media), which michael@0: * may be needed to preserve privacy. For HTTPS, this flag is set auto- michael@0: * matically. michael@0: */ michael@0: const unsigned long INHIBIT_PERSISTENT_CACHING = 1 << 8; michael@0: michael@0: /************************************************************************** michael@0: * The following flags control what happens when the cache contains data michael@0: * that could perhaps satisfy this request. They are listed in descending michael@0: * order of precidence. michael@0: */ michael@0: michael@0: /** michael@0: * Force an end-to-end download of content data from the origin server. michael@0: * This flag is used for a shift-reload. michael@0: */ michael@0: const unsigned long LOAD_BYPASS_CACHE = 1 << 9; michael@0: michael@0: /** michael@0: * Attempt to force a load from the cache, bypassing ALL validation logic michael@0: * (note: this is stronger than VALIDATE_NEVER, which still validates for michael@0: * certain conditions). michael@0: * michael@0: * If the resource is not present in cache, it will be loaded from the michael@0: * network. Combine this flag with LOAD_ONLY_FROM_CACHE if you wish to michael@0: * perform cache-only loads without validation checks. michael@0: * michael@0: * This flag is used when browsing via history. It is not recommended for michael@0: * normal browsing as it may likely violate reasonable assumptions made by michael@0: * the server and confuse users. michael@0: */ michael@0: const unsigned long LOAD_FROM_CACHE = 1 << 10; michael@0: michael@0: /** michael@0: * The following flags control the frequency of cached content validation michael@0: * when neither LOAD_BYPASS_CACHE or LOAD_FROM_CACHE are set. By default, michael@0: * cached content is automatically validated if necessary before reuse. michael@0: * michael@0: * VALIDATE_ALWAYS forces validation of any cached content independent of michael@0: * its expiration time. michael@0: * michael@0: * VALIDATE_NEVER disables validation of cached content, unless it arrived michael@0: * with the "Cache: no-store" header, or arrived via HTTPS with the michael@0: * "Cache: no-cache" header. michael@0: * michael@0: * VALIDATE_ONCE_PER_SESSION disables validation of expired content, michael@0: * provided it has already been validated (at least once) since the start michael@0: * of this session. michael@0: * michael@0: * NOTE TO IMPLEMENTORS: michael@0: * These flags are intended for normal browsing, and they should therefore michael@0: * not apply to content that must be validated before each use. Consider, michael@0: * for example, a HTTP response with a "Cache-control: no-cache" header. michael@0: * According to RFC2616, this response must be validated before it can michael@0: * be taken from a cache. Breaking this requirement could result in michael@0: * incorrect and potentially undesirable side-effects. michael@0: */ michael@0: const unsigned long VALIDATE_ALWAYS = 1 << 11; michael@0: const unsigned long VALIDATE_NEVER = 1 << 12; michael@0: const unsigned long VALIDATE_ONCE_PER_SESSION = 1 << 13; michael@0: michael@0: /** michael@0: * When set, this flag indicates that no user-specific data should be added michael@0: * to the request when opened. This means that things like authorization michael@0: * tokens or cookie headers should not be added. michael@0: */ michael@0: const unsigned long LOAD_ANONYMOUS = 1 << 14; michael@0: michael@0: /** michael@0: * When set, this flag indicates that caches of network connections, michael@0: * particularly HTTP persistent connections, should not be used. michael@0: */ michael@0: const unsigned long LOAD_FRESH_CONNECTION = 1 << 15; michael@0: };