netwerk/protocol/http/nsIHttpChannel.idl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "nsIChannel.idl"
michael@0 7
michael@0 8 interface nsIHttpHeaderVisitor;
michael@0 9
michael@0 10 /**
michael@0 11 * nsIHttpChannel
michael@0 12 *
michael@0 13 * This interface allows for the modification of HTTP request parameters and
michael@0 14 * the inspection of the resulting HTTP response status and headers when they
michael@0 15 * become available.
michael@0 16 */
michael@0 17 [scriptable, uuid(a01362a0-5c45-11e2-bcfd-0800200c9a66)]
michael@0 18 interface nsIHttpChannel : nsIChannel
michael@0 19 {
michael@0 20 /**************************************************************************
michael@0 21 * REQUEST CONFIGURATION
michael@0 22 *
michael@0 23 * Modifying request parameters after asyncOpen has been called is an error.
michael@0 24 */
michael@0 25
michael@0 26 /**
michael@0 27 * Set/get the HTTP request method (default is "GET"). Setter is case
michael@0 28 * insensitive; getter returns an uppercase string.
michael@0 29 *
michael@0 30 * This attribute may only be set before the channel is opened.
michael@0 31 *
michael@0 32 * NOTE: The data for a "POST" or "PUT" request can be configured via
michael@0 33 * nsIUploadChannel; however, after setting the upload data, it may be
michael@0 34 * necessary to set the request method explicitly. The documentation
michael@0 35 * for nsIUploadChannel has further details.
michael@0 36 *
michael@0 37 * @throws NS_ERROR_IN_PROGRESS if set after the channel has been opened.
michael@0 38 */
michael@0 39 attribute ACString requestMethod;
michael@0 40
michael@0 41 /**
michael@0 42 * Get/set the HTTP referrer URI. This is the address (URI) of the
michael@0 43 * resource from which this channel's URI was obtained (see RFC2616 section
michael@0 44 * 14.36).
michael@0 45 *
michael@0 46 * This attribute may only be set before the channel is opened.
michael@0 47 *
michael@0 48 * NOTE: The channel may silently refuse to set the Referer header if the
michael@0 49 * URI does not pass certain security checks (e.g., a "https://" URL will
michael@0 50 * never be sent as the referrer for a plaintext HTTP request). The
michael@0 51 * implementation is not required to throw an exception when the referrer
michael@0 52 * URI is rejected.
michael@0 53 *
michael@0 54 * @throws NS_ERROR_IN_PROGRESS if set after the channel has been opened.
michael@0 55 */
michael@0 56 attribute nsIURI referrer;
michael@0 57
michael@0 58 /**
michael@0 59 * Read the proxy URI, which, if non-null, will be used to resolve
michael@0 60 * proxies for this channel.
michael@0 61 */
michael@0 62 readonly attribute nsIURI proxyURI;
michael@0 63
michael@0 64 /**
michael@0 65 * Get the value of a particular request header.
michael@0 66 *
michael@0 67 * @param aHeader
michael@0 68 * The case-insensitive name of the request header to query (e.g.,
michael@0 69 * "Cache-Control").
michael@0 70 *
michael@0 71 * @return the value of the request header.
michael@0 72 * @throws NS_ERROR_NOT_AVAILABLE if the header is not set.
michael@0 73 */
michael@0 74 ACString getRequestHeader(in ACString aHeader);
michael@0 75
michael@0 76 /**
michael@0 77 * Set the value of a particular request header.
michael@0 78 *
michael@0 79 * This method allows, for example, the cookies module to add "Cookie"
michael@0 80 * headers to the outgoing HTTP request.
michael@0 81 *
michael@0 82 * This method may only be called before the channel is opened.
michael@0 83 *
michael@0 84 * @param aHeader
michael@0 85 * The case-insensitive name of the request header to set (e.g.,
michael@0 86 * "Cookie").
michael@0 87 * @param aValue
michael@0 88 * The request header value to set (e.g., "X=1").
michael@0 89 * @param aMerge
michael@0 90 * If true, the new header value will be merged with any existing
michael@0 91 * values for the specified header. This flag is ignored if the
michael@0 92 * specified header does not support merging (e.g., the "Content-
michael@0 93 * Type" header can only have one value). The list of headers for
michael@0 94 * which this flag is ignored is an implementation detail. If this
michael@0 95 * flag is false, then the header value will be replaced with the
michael@0 96 * contents of |aValue|.
michael@0 97 *
michael@0 98 * If aValue is empty and aMerge is false, the header will be cleared.
michael@0 99 *
michael@0 100 * @throws NS_ERROR_IN_PROGRESS if called after the channel has been
michael@0 101 * opened.
michael@0 102 */
michael@0 103 void setRequestHeader(in ACString aHeader,
michael@0 104 in ACString aValue,
michael@0 105 in boolean aMerge);
michael@0 106
michael@0 107 /**
michael@0 108 * Call this method to visit all request headers. Calling setRequestHeader
michael@0 109 * while visiting request headers has undefined behavior. Don't do it!
michael@0 110 *
michael@0 111 * @param aVisitor
michael@0 112 * the header visitor instance.
michael@0 113 */
michael@0 114 void visitRequestHeaders(in nsIHttpHeaderVisitor aVisitor);
michael@0 115
michael@0 116 /**
michael@0 117 * This attribute is a hint to the channel to indicate whether or not
michael@0 118 * the underlying HTTP transaction should be allowed to be pipelined
michael@0 119 * with other transactions. This should be set to FALSE, for example,
michael@0 120 * if the application knows that the corresponding document is likely
michael@0 121 * to be very large.
michael@0 122 *
michael@0 123 * This attribute is true by default, though other factors may prevent
michael@0 124 * pipelining.
michael@0 125 *
michael@0 126 * This attribute may only be set before the channel is opened.
michael@0 127 *
michael@0 128 * @throws NS_ERROR_FAILURE if set after the channel has been opened.
michael@0 129 */
michael@0 130 attribute boolean allowPipelining;
michael@0 131
michael@0 132 /**
michael@0 133 * This attribute specifies the number of redirects this channel is allowed
michael@0 134 * to make. If zero, the channel will fail to redirect and will generate
michael@0 135 * a NS_ERROR_REDIRECT_LOOP failure status.
michael@0 136 *
michael@0 137 * NOTE: An HTTP redirect results in a new channel being created. If the
michael@0 138 * new channel supports nsIHttpChannel, then it will be assigned a value
michael@0 139 * to its |redirectionLimit| attribute one less than the value of the
michael@0 140 * redirected channel's |redirectionLimit| attribute. The initial value
michael@0 141 * for this attribute may be a configurable preference (depending on the
michael@0 142 * implementation).
michael@0 143 */
michael@0 144 attribute unsigned long redirectionLimit;
michael@0 145
michael@0 146
michael@0 147 /**************************************************************************
michael@0 148 * RESPONSE INFO
michael@0 149 *
michael@0 150 * Accessing response info before the onStartRequest event is an error.
michael@0 151 */
michael@0 152
michael@0 153 /**
michael@0 154 * Get the HTTP response code (e.g., 200).
michael@0 155 *
michael@0 156 * @throws NS_ERROR_NOT_AVAILABLE if called before the response
michael@0 157 * has been received (before onStartRequest).
michael@0 158 */
michael@0 159 readonly attribute unsigned long responseStatus;
michael@0 160
michael@0 161 /**
michael@0 162 * Get the HTTP response status text (e.g., "OK").
michael@0 163 *
michael@0 164 * NOTE: This returns the raw (possibly 8-bit) text from the server. There
michael@0 165 * are no assumptions made about the charset of the returned text. You
michael@0 166 * have been warned!
michael@0 167 *
michael@0 168 * @throws NS_ERROR_NOT_AVAILABLE if called before the response
michael@0 169 * has been received (before onStartRequest).
michael@0 170 */
michael@0 171 readonly attribute ACString responseStatusText;
michael@0 172
michael@0 173 /**
michael@0 174 * Returns true if the HTTP response code indicates success. The value of
michael@0 175 * nsIRequest::status will be NS_OK even when processing a 404 response
michael@0 176 * because a 404 response may include a message body that (in some cases)
michael@0 177 * should be shown to the user.
michael@0 178 *
michael@0 179 * Use this attribute to distinguish server error pages from normal pages,
michael@0 180 * instead of comparing the response status manually against the set of
michael@0 181 * valid response codes, if that is required by your application.
michael@0 182 *
michael@0 183 * @throws NS_ERROR_NOT_AVAILABLE if called before the response
michael@0 184 * has been received (before onStartRequest).
michael@0 185 */
michael@0 186 readonly attribute boolean requestSucceeded;
michael@0 187
michael@0 188 /**
michael@0 189 * Get the value of a particular response header.
michael@0 190 *
michael@0 191 * @param aHeader
michael@0 192 * The case-insensitive name of the response header to query (e.g.,
michael@0 193 * "Set-Cookie").
michael@0 194 *
michael@0 195 * @return the value of the response header.
michael@0 196 *
michael@0 197 * @throws NS_ERROR_NOT_AVAILABLE if called before the response
michael@0 198 * has been received (before onStartRequest) or if the header is
michael@0 199 * not set in the response.
michael@0 200 */
michael@0 201 ACString getResponseHeader(in ACString header);
michael@0 202
michael@0 203 /**
michael@0 204 * Set the value of a particular response header.
michael@0 205 *
michael@0 206 * This method allows, for example, the HTML content sink to inform the HTTP
michael@0 207 * channel about HTTP-EQUIV headers found in HTML <META> tags.
michael@0 208 *
michael@0 209 * @param aHeader
michael@0 210 * The case-insensitive name of the response header to set (e.g.,
michael@0 211 * "Cache-control").
michael@0 212 * @param aValue
michael@0 213 * The response header value to set (e.g., "no-cache").
michael@0 214 * @param aMerge
michael@0 215 * If true, the new header value will be merged with any existing
michael@0 216 * values for the specified header. This flag is ignored if the
michael@0 217 * specified header does not support merging (e.g., the "Content-
michael@0 218 * Type" header can only have one value). The list of headers for
michael@0 219 * which this flag is ignored is an implementation detail. If this
michael@0 220 * flag is false, then the header value will be replaced with the
michael@0 221 * contents of |aValue|.
michael@0 222 *
michael@0 223 * If aValue is empty and aMerge is false, the header will be cleared.
michael@0 224 *
michael@0 225 * @throws NS_ERROR_NOT_AVAILABLE if called before the response
michael@0 226 * has been received (before onStartRequest).
michael@0 227 * @throws NS_ERROR_ILLEGAL_VALUE if changing the value of this response
michael@0 228 * header is not allowed.
michael@0 229 */
michael@0 230 void setResponseHeader(in ACString header,
michael@0 231 in ACString value,
michael@0 232 in boolean merge);
michael@0 233
michael@0 234 /**
michael@0 235 * Call this method to visit all response headers. Calling
michael@0 236 * setResponseHeader while visiting response headers has undefined
michael@0 237 * behavior. Don't do it!
michael@0 238 *
michael@0 239 * @param aVisitor
michael@0 240 * the header visitor instance.
michael@0 241 *
michael@0 242 * @throws NS_ERROR_NOT_AVAILABLE if called before the response
michael@0 243 * has been received (before onStartRequest).
michael@0 244 */
michael@0 245 void visitResponseHeaders(in nsIHttpHeaderVisitor aVisitor);
michael@0 246
michael@0 247 /**
michael@0 248 * Returns true if the server sent a "Cache-Control: no-store" response
michael@0 249 * header.
michael@0 250 *
michael@0 251 * @throws NS_ERROR_NOT_AVAILABLE if called before the response
michael@0 252 * has been received (before onStartRequest).
michael@0 253 */
michael@0 254 boolean isNoStoreResponse();
michael@0 255
michael@0 256 /**
michael@0 257 * Returns true if the server sent the equivalent of a "Cache-control:
michael@0 258 * no-cache" response header. Equivalent response headers include:
michael@0 259 * "Pragma: no-cache", "Expires: 0", and "Expires" with a date value
michael@0 260 * in the past relative to the value of the "Date" header.
michael@0 261 *
michael@0 262 * @throws NS_ERROR_NOT_AVAILABLE if called before the response
michael@0 263 * has been received (before onStartRequest).
michael@0 264 */
michael@0 265 boolean isNoCacheResponse();
michael@0 266
michael@0 267 /**
michael@0 268 * Instructs the channel to immediately redirect to a new destination.
michael@0 269 * Can only be called on channels not yet opened.
michael@0 270 *
michael@0 271 * This method provides no explicit conflict resolution. The last
michael@0 272 * caller to call it wins.
michael@0 273 *
michael@0 274 * @throws NS_ERROR_ALREADY_OPENED if called after the channel
michael@0 275 * has been opened.
michael@0 276 */
michael@0 277 void redirectTo(in nsIURI aNewURI);
michael@0 278 };

mercurial