nsIHttpChannelInternal.idl (20045B)
1 /* -*- Mode: C++; tab-width: 4; 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 #include "nsILoadInfo.idl" 8 #include "nsIReplacedHttpResponse.idl" 9 #include "nsIRequest.idl" 10 #include "nsITRRSkipReason.idl" 11 12 %{C++ 13 #include "nsStringFwd.h" 14 #include "nsTArrayForwardDeclare.h" 15 template<class T> class nsCOMArray; 16 namespace mozilla { 17 class TimeStamp; 18 namespace net { 19 class nsHttpConnectionInfo; 20 class WebSocketConnectionBase; 21 class EarlyHintConnectArgs; 22 } 23 namespace dom { 24 enum class RequestMode : uint8_t; 25 } 26 } 27 %} 28 [ptr] native nsHttpConnectionInfo(mozilla::net::nsHttpConnectionInfo); 29 [ptr] native StringArray(nsTArray<nsCString>); 30 [ref] native CStringArrayRef(const nsTArray<nsCString>); 31 [ref] native securityMessagesArray(nsCOMArray<nsISecurityConsoleMessage>); 32 [ptr] native WebSocketConnectionBase(mozilla::net::WebSocketConnectionBase); 33 34 native TimeStamp(mozilla::TimeStamp); 35 native RequestMode(mozilla::dom::RequestMode); 36 37 interface nsIAsyncInputStream; 38 interface nsIAsyncOutputStream; 39 interface nsIEarlyHintObserver; 40 interface nsIPrincipal; 41 interface nsIProxyInfo; 42 interface nsISecurityConsoleMessage; 43 interface nsISocketTransport; 44 interface nsIURI; 45 interface WebTransportSessionEventListener; 46 47 /** 48 * The callback interface for nsIHttpChannelInternal::HTTPUpgrade() 49 */ 50 51 [scriptable, uuid(5b515449-ab64-4dba-b3cd-da8fc2f83064)] 52 interface nsIHttpUpgradeListener : nsISupports 53 { 54 [must_use] void onTransportAvailable(in nsISocketTransport aTransport, 55 in nsIAsyncInputStream aSocketIn, 56 in nsIAsyncOutputStream aSocketOut); 57 58 [must_use] void onUpgradeFailed(in nsresult aErrorCode); 59 60 [noscript] void onWebSocketConnectionAvailable(in WebSocketConnectionBase aConnection); 61 }; 62 63 /** 64 * Dumping ground for http. This interface will never be frozen. If you are 65 * using any feature exposed by this interface, be aware that this interface 66 * will change and you will be broken. You have been warned. 67 */ 68 [builtinclass, scriptable, uuid(4e28263d-1e03-46f4-aa5c-9512f91957f9)] 69 interface nsIHttpChannelInternal : nsISupports 70 { 71 /** 72 * An http channel can own a reference to the document URI 73 */ 74 [must_use] attribute nsIURI documentURI; 75 76 /** 77 * Get the major/minor version numbers for the request 78 */ 79 [must_use] 80 void getRequestVersion(out unsigned long major, out unsigned long minor); 81 82 /** 83 * Get the major/minor version numbers for the response 84 */ 85 [must_use] 86 void getResponseVersion(out unsigned long major, out unsigned long minor); 87 88 /** 89 * Retrieves all security messages from the security message queue 90 * and empties the queue after retrieval 91 */ 92 [noscript, must_use] 93 void takeAllSecurityMessages(in securityMessagesArray aMessages); 94 95 /** 96 * Helper method to set a cookie with a consumer-provided 97 * cookie header, _but_ using the channel's other information 98 * (URI's, prompters, date headers etc). 99 * 100 * @param aCookieHeader 101 * The cookie header values to be parsed. 102 */ 103 [must_use] void setCookieHeaders(in Array<ACString> aCookieHeaders); 104 105 /** 106 * Returns true in case this channel is used for auth; 107 * (the response header includes 'www-authenticate'). 108 */ 109 [noscript, must_use] readonly attribute boolean isAuthChannel; 110 111 /** 112 * This flag is set to force relevant cookies to be sent with this load 113 * even if normally they wouldn't be. 114 */ 115 const unsigned long THIRD_PARTY_FORCE_ALLOW = 1 << 0; 116 117 /** 118 * When set, these flags modify the algorithm used to decide whether to 119 * send 3rd party cookies for a given channel. 120 */ 121 [must_use] attribute unsigned long thirdPartyFlags; 122 123 /** 124 * This attribute was added before the "flags" above and is retained here 125 * for compatibility. When set to true, has the same effect as 126 * THIRD_PARTY_FORCE_ALLOW, described above. 127 */ 128 [must_use] attribute boolean forceAllowThirdPartyCookie; 129 130 /** 131 * External handlers may set this to true to notify the channel 132 * that it is open on behalf of a download. 133 */ 134 [must_use] attribute boolean channelIsForDownload; 135 136 /** 137 * The local IP address to which this channel is bound, in the 138 * format produced by PR_NetAddrToString. May be IPv4 or IPv6. 139 * Note: in the presence of NAT, this may not be the same as the 140 * address that the remote host thinks it's talking to. 141 * 142 * May throw NS_ERROR_NOT_AVAILABLE if accessed when the channel's 143 * endpoints are not yet determined, or in any case when 144 * nsIHttpActivityObserver.isActive is false. See bugs 534698 and 526207. 145 */ 146 [must_use] readonly attribute AUTF8String localAddress; 147 148 /** 149 * The local port number to which this channel is bound. 150 * 151 * May throw NS_ERROR_NOT_AVAILABLE if accessed when the channel's 152 * endpoints are not yet determined, or in any case when 153 * nsIHttpActivityObserver.isActive is false. See bugs 534698 and 526207. 154 */ 155 [must_use] readonly attribute int32_t localPort; 156 157 /** 158 * The IP address of the remote host that this channel is 159 * connected to, in the format produced by PR_NetAddrToString. 160 * 161 * May throw NS_ERROR_NOT_AVAILABLE if accessed when the channel's 162 * endpoints are not yet determined, or in any case when 163 * nsIHttpActivityObserver.isActive is false. See bugs 534698 and 526207. 164 */ 165 [must_use] readonly attribute AUTF8String remoteAddress; 166 167 /** 168 * The remote port number that this channel is connected to. 169 * 170 * May throw NS_ERROR_NOT_AVAILABLE if accessed when the channel's 171 * endpoints are not yet determined, or in any case when 172 * nsIHttpActivityObserver.isActive is false. See bugs 534698 and 526207. 173 */ 174 [must_use] readonly attribute int32_t remotePort; 175 176 /** 177 * Transfer chain of redirected cache-keys. 178 */ 179 [noscript, must_use] 180 void setCacheKeysRedirectChain(in StringArray cacheKeys); 181 182 /** 183 * HTTPUpgrade allows for the use of HTTP to bootstrap another protocol 184 * via the RFC 2616 Upgrade request header in conjunction with a 101 level 185 * response. The nsIHttpUpgradeListener will have its 186 * onTransportAvailable() method invoked if a matching 101 is processed. 187 * The arguments to onTransportAvailable provide the new protocol the low 188 * level tranport streams that are no longer used by HTTP. If any errors 189 * occur during the upgrade but the original request has (potentially) 190 * already received onStopRequest, the nsIHttpUpgradeListener will have its 191 * onUpgradeFailed() method invoked instead of onTransportAvailable(). 192 * 193 * The onStartRequest and onStopRequest events are still delivered and the 194 * listener gets full control over the socket if and when onTransportAvailable 195 * is delivered. Note that if onStopRequest is called with an error, no 196 * methods on the nsIHttpUpgradeListener might be invoked at all. 197 * 198 * @param aProtocolName 199 * The value of the HTTP Upgrade request header 200 * @param aListener 201 * The callback object used to handle a successful upgrade 202 */ 203 [must_use] void HTTPUpgrade(in ACString aProtocolName, 204 in nsIHttpUpgradeListener aListener); 205 206 /** 207 * Enable only CONNECT to a proxy. Fails if no HTTPUpgrade listener 208 * has been defined. An ALPN header is set using the upgrade protocol. 209 * 210 * Load flags are set with INHIBIT_CACHING, LOAD_ANONYMOUS, 211 * LOAD_BYPASS_CACHE, and LOAD_BYPASS_SERVICE_WORKER. 212 * 213 * Proxy resolve flags are set with RESOLVE_PREFER_HTTPS_PROXY and 214 * RESOLVE_ALWAYS_TUNNEL. 215 * 216 * @param tlsTunnel 217 * When true, always setup TLS tunnel 218 */ 219 [must_use] void setConnectOnly(in boolean tlsTunnel); 220 221 /** 222 * True iff the channel is CONNECT only. 223 */ 224 [must_use] readonly attribute boolean onlyConnect; 225 226 /** 227 * Enable/Disable Spdy negotiation on per channel basis. 228 * The network.http.http2.enabled preference is still a pre-requisite 229 * for starting spdy. 230 */ 231 [must_use] attribute boolean allowSpdy; 232 233 /** 234 * Enable/Disable HTTP3 negotiation on per channel basis. 235 * The network.http.http3.enable preference is still a pre-requisite 236 * for starting HTTP3. 237 */ 238 [must_use] attribute boolean allowHttp3; 239 240 /** 241 * This attribute en/disables the timeout for the first byte of an HTTP 242 * response. Enabled by default. 243 */ 244 [must_use] attribute boolean responseTimeoutEnabled; 245 246 /** 247 * If the underlying transport supports RWIN manipulation, this is the 248 * intiial window value for the channel. HTTP/2 implements this. 249 * 0 means no override from system default. Set before opening channel. 250 */ 251 [must_use] attribute unsigned long initialRwin; 252 253 /** 254 * Get value of the URI passed to nsIHttpChannel.redirectTo() if any. 255 * May return null when redirectTo() has not been called. 256 */ 257 [must_use] readonly attribute nsIURI apiRedirectToURI; 258 259 /** 260 * Enable/Disable use of Alternate Services with this channel. 261 * The network.http.altsvc.enabled preference is still a pre-requisite. 262 */ 263 [must_use] attribute boolean allowAltSvc; 264 265 /** 266 * If true, do not use newer protocol features that might have interop problems 267 * on the Internet. Intended only for use with critical infra like the updater. 268 * default is false. 269 */ 270 [must_use] attribute boolean beConservative; 271 272 /** 273 * If true, do not resolve any proxy for this request. Intended only for use with 274 * critical infra like the updater. 275 * default is false. 276 */ 277 [must_use] attribute boolean bypassProxy; 278 279 /** 280 * True if channel is used by the internal trusted recursive resolver 281 * This flag places data for the request in a cache segment specific to TRR 282 */ 283 [noscript, must_use] attribute boolean isTRRServiceChannel; 284 285 /** 286 * If the channel's remote IP was resolved using TRR. 287 * Is false for resources loaded from the cache or resources that have an 288 * IP literal host. 289 */ 290 [must_use] readonly attribute boolean isResolvedByTRR; 291 292 293 /** 294 * The effective TRR mode used to resolve this channel. 295 * This is computed by taking the value returned by nsIRequest.getTRRMode() 296 * and the state of the TRRService. If the domain is excluded from TRR 297 * or the TRRService is disabled, the effective mode would be TRR_DISABLED_MODE 298 * even if the initial mode set on the request was TRR_ONLY_MODE. 299 */ 300 [must_use] readonly attribute nsIRequest_TRRMode effectiveTRRMode; 301 302 /** 303 * If the DNS request triggered by this channel didn't use TRR, this value 304 * contains the reason why that was skipped. 305 */ 306 [must_use] readonly attribute nsITRRSkipReason_value trrSkipReason; 307 308 /** 309 * True if channel is loaded by socket process. 310 */ 311 [must_use] readonly attribute boolean isLoadedBySocketProcess; 312 313 /** 314 * Set to true if the channel is an OCSP check. 315 * Channels with this flag set will skip TRR in mode3 (because the circular 316 * dependency with checking OCSP for the TRR server will cause a failure) 317 */ 318 [must_use] attribute boolean isOCSP; 319 320 /** 321 * An opaque flags for non-standard behavior of the TLS system. 322 * It is unlikely this will need to be set outside of tests or telemetry 323 * studies relating to the TLS implementation. 324 */ 325 const unsigned long TLS_FLAG_CONFIGURE_AS_RETRY = (1 << 16); 326 [must_use] attribute unsigned long tlsFlags; 327 328 [must_use] readonly attribute PRTime lastModifiedTime; 329 330 /** 331 * Set by nsCORSListenerProxy if credentials should be included in 332 * cross-origin requests. false indicates "same-origin", users should still 333 * check flag LOAD_ANONYMOUS! 334 */ 335 [must_use] attribute boolean corsIncludeCredentials; 336 337 /** 338 * Set by nsCORSListenerProxy to indicate CORS load type. Defaults to CORS_MODE_NO_CORS. 339 */ 340 [must_use, noscript] attribute RequestMode requestMode; 341 342 const unsigned long REDIRECT_MODE_FOLLOW = 0; 343 const unsigned long REDIRECT_MODE_ERROR = 1; 344 const unsigned long REDIRECT_MODE_MANUAL = 2; 345 /** 346 * Set to indicate Request.redirect mode exposed during ServiceWorker 347 * interception. No policy enforcement is performed by the channel for this 348 * value. 349 */ 350 [must_use] attribute unsigned long redirectMode; 351 352 const unsigned long FETCH_CACHE_MODE_DEFAULT = 0; 353 const unsigned long FETCH_CACHE_MODE_NO_STORE = 1; 354 const unsigned long FETCH_CACHE_MODE_RELOAD = 2; 355 const unsigned long FETCH_CACHE_MODE_NO_CACHE = 3; 356 const unsigned long FETCH_CACHE_MODE_FORCE_CACHE = 4; 357 const unsigned long FETCH_CACHE_MODE_ONLY_IF_CACHED = 5; 358 /** 359 * Set to indicate Request.cache mode, which simulates the fetch API 360 * semantics, and is also used for exposing this value to the Web page 361 * during service worker interception. 362 */ 363 [must_use] attribute unsigned long fetchCacheMode; 364 365 /** 366 * The URI of the top-level window that's associated with this channel. 367 */ 368 [must_use] readonly attribute nsIURI topWindowURI; 369 370 /** 371 * Set top-level window URI to this channel only when the topWindowURI 372 * is null and there is no window associated to this channel. 373 * Note that the current usage of this method is only for xpcshell test. 374 */ 375 [must_use] void setTopWindowURIIfUnknown(in nsIURI topWindowURI); 376 377 /** 378 * Read the proxy URI, which, if non-null, will be used to resolve 379 * proxies for this channel. 380 */ 381 [must_use] readonly attribute nsIURI proxyURI; 382 383 /** 384 * Make cross-origin CORS loads happen with a CORS preflight, and specify 385 * the CORS preflight parameters. 386 */ 387 [noscript, notxpcom, nostdcall] 388 void setCorsPreflightParameters(in CStringArrayRef unsafeHeaders, 389 in boolean shouldStripRequestBodyHeader, 390 in boolean shouldStripAuthHeader); 391 392 [noscript, notxpcom, nostdcall] 393 void setAltDataForChild(in boolean aIsForChild); 394 395 /** 396 * Prevent the use of alt-data cache for this request. Use by the 397 * extension StreamFilter class to force use of the regular cache. 398 */ 399 [noscript, notxpcom, nostdcall] 400 void disableAltDataCache(); 401 402 /** 403 * When set to true, the channel will not pop any authentication prompts up 404 * to the user. When provided or cached credentials lead to an 405 * authentication failure, that failure will be propagated to the channel 406 * listener. Must be called before opening the channel, otherwise throws. 407 */ 408 [infallible] 409 attribute boolean blockAuthPrompt; 410 411 /** 412 * The connection info's hash key. We use it to test connection separation. 413 */ 414 [must_use] readonly attribute ACString connectionInfoHashKey; 415 416 /** 417 * If this channel was created as the result of a redirect, then this 418 * value will reflect the redirect flags passed to the 419 * SetupReplacementChannel() method. 420 */ 421 [noscript, infallible] 422 attribute unsigned long lastRedirectFlags; 423 424 // This is used to determine the duration since navigation started. 425 [noscript] attribute TimeStamp navigationStartTimeStamp; 426 427 /** 428 * Cancel a channel because we have determined that it needs to be blocked 429 * for safe-browsing protection. This is an internal API that is meant to 430 * be called by the channel classifier. Please DO NOT use this API if you 431 * don't know whether you should be using it. 432 */ 433 [noscript] void cancelByURLClassifier(in nsresult aErrorCode); 434 435 /** 436 * The channel will be loaded over IPv6, disabling IPv4. 437 */ 438 void setIPv4Disabled(); 439 440 /** 441 * The channel will be loaded over IPv4, disabling IPv6. 442 */ 443 void setIPv6Disabled(); 444 445 /** 446 * Returns a cached CrossOriginOpenerPolicy that is computed just before we 447 * determine if there is a policy mismatch. 448 * @throws NS_ERROR_NOT_AVAILABLE if it has not been computed yet 449 */ 450 readonly attribute nsILoadInfo_CrossOriginOpenerPolicy crossOriginOpenerPolicy; 451 452 /** 453 * Called during onStartRequest to compute the cross-origin-opener-policy 454 * for a given channel. 455 */ 456 [noscript] 457 nsILoadInfo_CrossOriginOpenerPolicy computeCrossOriginOpenerPolicy( 458 in nsILoadInfo_CrossOriginOpenerPolicy aInitiatorPolicy); 459 460 [noscript] 461 boolean hasCrossOriginOpenerPolicyMismatch(); 462 463 [noscript] 464 nsILoadInfo_CrossOriginEmbedderPolicy getResponseEmbedderPolicy(in boolean aIsOriginTrialCoepCredentiallessEnabled); 465 466 /** 467 * Returns the parsed boolean value of the "Origin-Agent-Cluster" header. 468 * @throws NS_ERROR_NOT_AVAILABLE if the header is not present. 469 */ 470 [noscript] boolean getOriginAgentClusterHeader(); 471 472 [noscript, notxpcom, nostdcall] 473 void DoDiagnosticAssertWhenOnStopNotCalledOnDestroy(); 474 475 /** 476 * This attribute indicates if the channel has support for HTTP3 477 */ 478 [must_use] readonly attribute boolean supportsHTTP3; 479 480 /** 481 * This attribute indicates if the HTTPS RR is used for this channel. 482 */ 483 [must_use] readonly attribute boolean hasHTTPSRR; 484 485 /** 486 * Set Early Hint Observer. 487 */ 488 [must_use] void setEarlyHintObserver(in nsIEarlyHintObserver aObserver); 489 490 /** 491 * id of the EarlyHintPreloader to connect back from PreloadService to 492 * EarlyHintPreloader. 493 */ 494 [must_use] attribute unsigned long long earlyHintPreloaderId; 495 496 [notxpcom, nostdcall] void setConnectionInfo(in nsHttpConnectionInfo aInfo); 497 498 /** 499 * This attribute indicates if the channel was loaded via Proxy. 500 */ 501 [must_use] readonly attribute boolean isProxyUsed; 502 503 /** 504 * Set mWebTransportSessionEventListener. 505 */ 506 [must_use] void setWebTransportSessionEventListener( 507 in WebTransportSessionEventListener aListener); 508 509 /** 510 * This attribute indicates the type of Link header in the received 511 * 103 response. 512 */ 513 [must_use] attribute unsigned long earlyHintLinkType; 514 515 /** 516 * Indicates whether the User-Agent request header has been modified since 517 * the channel was created. This value will be used to decide if we need to 518 * recalculate the User-Agent header for fingerprinting protection. We won't 519 * recalculate the User-Agent header if it has been modified to preserve the 520 * overridden header value. 521 */ 522 [must_use] attribute boolean isUserAgentHeaderModified; 523 524 /** 525 * The nsIReplacedHttpResponse will be used to override the response of the 526 * channel. Should be called before connect (http-on-before-connect). 527 * When setResponseOverride is called, the request will bypass the network 528 * and a mocked response based on the nsIReplacedHttpResponse content will 529 * be used instead. 530 */ 531 [must_use] void setResponseOverride( 532 in nsIReplacedHttpResponse aReplacedHttpResponse); 533 534 /** 535 * Updates the status and statusText for the response. Must be called after 536 * we start receiving the response, eg. http-on-examine-response. 537 */ 538 [must_use] void setResponseStatus( 539 in unsigned long aStatus, in ACString aStatusText); 540 541 readonly attribute nsresult lastTransportStatus; 542 543 544 /** 545 * Same as redirectTo in nsIHttpChannel, but handles internal redirect 546 * so that we add REDIRECT_TRANSPARENT to the flag. 547 */ 548 [must_use] void transparentRedirectTo(in nsIURI aTargetURI); 549 550 551 /** 552 * For testing purposes only. 553 */ 554 readonly attribute unsigned long caps; 555 };