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/. */
6 #include
"nsISupports.idl"
7 #include
"nsILoadInfo.idl"
8 #include
"nsIRequest.idl"
9 #include
"nsITRRSkipReason.idl"
12 #include
"nsStringFwd.h"
13 #include
"nsTArrayForwardDeclare.h"
14 template
<class T
> class nsCOMArray
;
18 class nsHttpConnectionInfo
;
19 class WebSocketConnectionBase
;
20 class EarlyHintConnectArgs
;
23 enum class RequestMode
: uint8_t
;
27 [ptr] native nsHttpConnectionInfo
(mozilla
::net
::nsHttpConnectionInfo
);
28 [ptr] native StringArray
(nsTArray
<nsCString
>);
29 [ref] native CStringArrayRef
(const nsTArray
<nsCString
>);
30 [ref] native securityMessagesArray
(nsCOMArray
<nsISecurityConsoleMessage
>);
31 [ptr] native WebSocketConnectionBase
(mozilla
::net
::WebSocketConnectionBase
);
33 native TimeStamp
(mozilla
::TimeStamp
);
34 native RequestMode
(mozilla
::dom
::RequestMode
);
36 interface nsIAsyncInputStream
;
37 interface nsIAsyncOutputStream
;
38 interface nsIEarlyHintObserver
;
39 interface nsIPrincipal
;
40 interface nsIProxyInfo
;
41 interface nsISecurityConsoleMessage
;
42 interface nsISocketTransport
;
44 interface WebTransportSessionEventListener
;
47 * The callback interface for nsIHttpChannelInternal::HTTPUpgrade()
50 [scriptable
, uuid(5b515449
-ab64
-4dba
-b3cd
-da8fc2f83064
)]
51 interface nsIHttpUpgradeListener
: nsISupports
53 [must_use
] void onTransportAvailable
(in nsISocketTransport aTransport
,
54 in nsIAsyncInputStream aSocketIn
,
55 in nsIAsyncOutputStream aSocketOut
);
57 [must_use
] void onUpgradeFailed
(in nsresult aErrorCode
);
59 void onWebSocketConnectionAvailable
(in WebSocketConnectionBase aConnection
);
63 * Dumping ground for http. This interface will never be frozen. If you are
64 * using any feature exposed by this interface, be aware that this interface
65 * will change and you will be broken. You have been warned.
67 [builtinclass
, scriptable
, uuid(4e28263d
-1e03
-46f4
-aa5c
-9512f91957f9
)]
68 interface nsIHttpChannelInternal
: nsISupports
71 * An http channel can own a reference to the document URI
73 [must_use
] attribute nsIURI documentURI
;
76 * Get the major/minor version numbers for the request
79 void getRequestVersion
(out unsigned long major
, out unsigned long minor
);
82 * Get the major/minor version numbers for the response
85 void getResponseVersion
(out unsigned long major
, out unsigned long minor
);
88 * Retrieves all security messages from the security message queue
89 * and empties the queue after retrieval
92 void takeAllSecurityMessages
(in securityMessagesArray aMessages
);
95 * Helper method to set a cookie with a consumer-provided
96 * cookie header, _but_ using the channel's other information
97 * (URI's, prompters, date headers etc).
99 * @param aCookieHeader
100 * The cookie header to be parsed.
102 [must_use
] void setCookie
(in ACString aCookieHeader
);
105 * Returns true in case this channel is used for auth;
106 * (the response header includes 'www-authenticate').
108 [noscript
, must_use
] readonly attribute bool isAuthChannel
;
111 * This flag is set to force relevant cookies to be sent with this load
112 * even if normally they wouldn't be.
114 const unsigned long THIRD_PARTY_FORCE_ALLOW
= 1 << 0;
117 * When set, these flags modify the algorithm used to decide whether to
118 * send 3rd party cookies for a given channel.
120 [must_use
] attribute
unsigned long thirdPartyFlags
;
123 * This attribute was added before the "flags" above and is retained here
124 * for compatibility. When set to true, has the same effect as
125 * THIRD_PARTY_FORCE_ALLOW, described above.
127 [must_use
] attribute
boolean forceAllowThirdPartyCookie
;
130 * External handlers may set this to true to notify the channel
131 * that it is open on behalf of a download.
133 [must_use
] attribute
boolean channelIsForDownload
;
136 * The local IP address to which this channel is bound, in the
137 * format produced by PR_NetAddrToString. May be IPv4 or IPv6.
138 * Note: in the presence of NAT, this may not be the same as the
139 * address that the remote host thinks it's talking to.
141 * May throw NS_ERROR_NOT_AVAILABLE if accessed when the channel's
142 * endpoints are not yet determined, or in any case when
143 * nsIHttpActivityObserver.isActive is false. See bugs 534698 and 526207.
145 [must_use
] readonly attribute AUTF8String localAddress
;
148 * The local port number to which this channel is bound.
150 * May throw NS_ERROR_NOT_AVAILABLE if accessed when the channel's
151 * endpoints are not yet determined, or in any case when
152 * nsIHttpActivityObserver.isActive is false. See bugs 534698 and 526207.
154 [must_use
] readonly attribute int32_t localPort
;
157 * The IP address of the remote host that this channel is
158 * connected to, in the format produced by PR_NetAddrToString.
160 * May throw NS_ERROR_NOT_AVAILABLE if accessed when the channel's
161 * endpoints are not yet determined, or in any case when
162 * nsIHttpActivityObserver.isActive is false. See bugs 534698 and 526207.
164 [must_use
] readonly attribute AUTF8String remoteAddress
;
167 * The remote port number that this channel is connected to.
169 * May throw NS_ERROR_NOT_AVAILABLE if accessed when the channel's
170 * endpoints are not yet determined, or in any case when
171 * nsIHttpActivityObserver.isActive is false. See bugs 534698 and 526207.
173 [must_use
] readonly attribute int32_t remotePort
;
176 * Transfer chain of redirected cache-keys.
179 void setCacheKeysRedirectChain
(in StringArray cacheKeys
);
182 * HTTPUpgrade allows for the use of HTTP to bootstrap another protocol
183 * via the RFC 2616 Upgrade request header in conjunction with a 101 level
184 * response. The nsIHttpUpgradeListener will have its
185 * onTransportAvailable() method invoked if a matching 101 is processed.
186 * The arguments to onTransportAvailable provide the new protocol the low
187 * level tranport streams that are no longer used by HTTP. If any errors
188 * occur during the upgrade but the original request has (potentially)
189 * already received onStopRequest, the nsIHttpUpgradeListener will have its
190 * onUpgradeFailed() method invoked instead of onTransportAvailable().
192 * The onStartRequest and onStopRequest events are still delivered and the
193 * listener gets full control over the socket if and when onTransportAvailable
194 * is delivered. Note that if onStopRequest is called with an error, no
195 * methods on the nsIHttpUpgradeListener might be invoked at all.
197 * @param aProtocolName
198 * The value of the HTTP Upgrade request header
200 * The callback object used to handle a successful upgrade
202 [must_use
] void HTTPUpgrade
(in ACString aProtocolName
,
203 in nsIHttpUpgradeListener aListener
);
206 * Enable only CONNECT to a proxy. Fails if no HTTPUpgrade listener
207 * has been defined. An ALPN header is set using the upgrade protocol.
209 * Load flags are set with INHIBIT_CACHING, LOAD_ANONYMOUS,
210 * LOAD_BYPASS_CACHE, and LOAD_BYPASS_SERVICE_WORKER.
212 * Proxy resolve flags are set with RESOLVE_PREFER_HTTPS_PROXY and
213 * RESOLVE_ALWAYS_TUNNEL.
215 [must_use
] void setConnectOnly
();
218 * True iff the channel is CONNECT only.
220 [must_use
] readonly attribute
boolean onlyConnect
;
223 * Enable/Disable Spdy negotiation on per channel basis.
224 * The network.http.http2.enabled preference is still a pre-requisite
227 [must_use
] attribute
boolean allowSpdy
;
230 * Enable/Disable HTTP3 negotiation on per channel basis.
231 * The network.http.http3.enable preference is still a pre-requisite
232 * for starting HTTP3.
234 [must_use
] attribute
boolean allowHttp3
;
237 * This attribute en/disables the timeout for the first byte of an HTTP
238 * response. Enabled by default.
240 [must_use
] attribute
boolean responseTimeoutEnabled
;
243 * If the underlying transport supports RWIN manipulation, this is the
244 * intiial window value for the channel. HTTP/2 implements this.
245 * 0 means no override from system default. Set before opening channel.
247 [must_use
] attribute
unsigned long initialRwin
;
250 * Get value of the URI passed to nsIHttpChannel.redirectTo() if any.
251 * May return null when redirectTo() has not been called.
253 [must_use
] readonly attribute nsIURI apiRedirectToURI
;
256 * Enable/Disable use of Alternate Services with this channel.
257 * The network.http.altsvc.enabled preference is still a pre-requisite.
259 [must_use
] attribute
boolean allowAltSvc
;
262 * If true, do not use newer protocol features that might have interop problems
263 * on the Internet. Intended only for use with critical infra like the updater.
266 [must_use
] attribute
boolean beConservative
;
269 * If true, do not resolve any proxy for this request. Intended only for use with
270 * critical infra like the updater.
273 [must_use
] attribute
boolean bypassProxy
;
276 * True if channel is used by the internal trusted recursive resolver
277 * This flag places data for the request in a cache segment specific to TRR
279 [noscript
, must_use
] attribute
boolean isTRRServiceChannel
;
282 * If the channel's remote IP was resolved using TRR.
283 * Is false for resources loaded from the cache or resources that have an
286 [must_use
] readonly attribute
boolean isResolvedByTRR
;
290 * The effective TRR mode used to resolve this channel.
291 * This is computed by taking the value returned by nsIRequest.getTRRMode()
292 * and the state of the TRRService. If the domain is excluded from TRR
293 * or the TRRService is disabled, the effective mode would be TRR_DISABLED_MODE
294 * even if the initial mode set on the request was TRR_ONLY_MODE.
296 [must_use
] readonly attribute nsIRequest_TRRMode effectiveTRRMode
;
299 * If the DNS request triggered by this channel didn't use TRR, this value
300 * contains the reason why that was skipped.
302 [must_use
] readonly attribute nsITRRSkipReason_value trrSkipReason
;
305 * True if channel is loaded by socket process.
307 [must_use
] readonly attribute
boolean isLoadedBySocketProcess
;
310 * Set to true if the channel is an OCSP check.
311 * Channels with this flag set will skip TRR in mode3 (because the circular
312 * dependency with checking OCSP for the TRR server will cause a failure)
314 [must_use
] attribute
boolean isOCSP
;
317 * An opaque flags for non-standard behavior of the TLS system.
318 * It is unlikely this will need to be set outside of telemetry studies
319 * relating to the TLS implementation.
321 [must_use
] attribute
unsigned long tlsFlags
;
323 [must_use
] readonly attribute PRTime lastModifiedTime
;
326 * Set by nsCORSListenerProxy if credentials should be included in
327 * cross-origin requests. false indicates "same-origin", users should still
328 * check flag LOAD_ANONYMOUS!
330 [must_use
] attribute
boolean corsIncludeCredentials
;
333 * Set by nsCORSListenerProxy to indicate CORS load type. Defaults to CORS_MODE_NO_CORS.
335 [must_use
, noscript
] attribute RequestMode requestMode
;
337 const unsigned long REDIRECT_MODE_FOLLOW
= 0;
338 const unsigned long REDIRECT_MODE_ERROR
= 1;
339 const unsigned long REDIRECT_MODE_MANUAL
= 2;
341 * Set to indicate Request.redirect mode exposed during ServiceWorker
342 * interception. No policy enforcement is performed by the channel for this
345 [must_use
] attribute
unsigned long redirectMode
;
347 const unsigned long FETCH_CACHE_MODE_DEFAULT
= 0;
348 const unsigned long FETCH_CACHE_MODE_NO_STORE
= 1;
349 const unsigned long FETCH_CACHE_MODE_RELOAD
= 2;
350 const unsigned long FETCH_CACHE_MODE_NO_CACHE
= 3;
351 const unsigned long FETCH_CACHE_MODE_FORCE_CACHE
= 4;
352 const unsigned long FETCH_CACHE_MODE_ONLY_IF_CACHED
= 5;
354 * Set to indicate Request.cache mode, which simulates the fetch API
355 * semantics, and is also used for exposing this value to the Web page
356 * during service worker interception.
358 [must_use
] attribute
unsigned long fetchCacheMode
;
361 * The URI of the top-level window that's associated with this channel.
363 [must_use
] readonly attribute nsIURI topWindowURI
;
366 * Set top-level window URI to this channel only when the topWindowURI
367 * is null and there is no window associated to this channel.
368 * Note that the current usage of this method is only for xpcshell test.
370 [must_use
] void setTopWindowURIIfUnknown
(in nsIURI topWindowURI
);
373 * Read the proxy URI, which, if non-null, will be used to resolve
374 * proxies for this channel.
376 [must_use
] readonly attribute nsIURI proxyURI
;
379 * Make cross-origin CORS loads happen with a CORS preflight, and specify
380 * the CORS preflight parameters.
382 [noscript
, notxpcom
, nostdcall
]
383 void setCorsPreflightParameters
(in CStringArrayRef unsafeHeaders
,
384 in boolean shouldStripRequestBodyHeader
);
386 [noscript
, notxpcom
, nostdcall
]
387 void setAltDataForChild
(in boolean aIsForChild
);
390 * Prevent the use of alt-data cache for this request. Use by the
391 * extension StreamFilter class to force use of the regular cache.
393 [noscript
, notxpcom
, nostdcall
]
394 void disableAltDataCache
();
397 * When set to true, the channel will not pop any authentication prompts up
398 * to the user. When provided or cached credentials lead to an
399 * authentication failure, that failure will be propagated to the channel
400 * listener. Must be called before opening the channel, otherwise throws.
403 attribute
boolean blockAuthPrompt
;
406 * Set to indicate Request.integrity.
408 [must_use
] attribute AString integrityMetadata
;
411 * The connection info's hash key. We use it to test connection separation.
413 [must_use
] readonly attribute ACString connectionInfoHashKey
;
416 * If this channel was created as the result of a redirect, then this
417 * value will reflect the redirect flags passed to the
418 * SetupReplacementChannel() method.
420 [noscript
, infallible
]
421 attribute
unsigned long lastRedirectFlags
;
423 // This is use to determine the duration since navigation started.
424 [noscript
] attribute TimeStamp navigationStartTimeStamp
;
427 * Cancel a channel because we have determined that it needs to be blocked
428 * for safe-browsing protection. This is an internal API that is meant to
429 * be called by the channel classifier. Please DO NOT use this API if you
430 * don't know whether you should be using it.
432 [noscript
] void cancelByURLClassifier
(in nsresult aErrorCode
);
435 * The channel will be loaded over IPv6, disabling IPv4.
437 void setIPv4Disabled
();
440 * The channel will be loaded over IPv4, disabling IPv6.
442 void setIPv6Disabled
();
445 * Returns a cached CrossOriginOpenerPolicy that is computed just before we
446 * determine if there is a policy mismatch.
447 * @throws NS_ERROR_NOT_AVAILABLE if it has not been computed yet
449 readonly attribute nsILoadInfo_CrossOriginOpenerPolicy crossOriginOpenerPolicy
;
452 * Called during onStartRequest to compute the cross-origin-opener-policy
453 * for a given channel.
456 nsILoadInfo_CrossOriginOpenerPolicy computeCrossOriginOpenerPolicy
(
457 in nsILoadInfo_CrossOriginOpenerPolicy aInitiatorPolicy
);
460 bool hasCrossOriginOpenerPolicyMismatch
();
463 nsILoadInfo_CrossOriginEmbedderPolicy getResponseEmbedderPolicy
(in boolean aIsOriginTrialCoepCredentiallessEnabled
);
465 [noscript
, notxpcom
, nostdcall
]
466 void DoDiagnosticAssertWhenOnStopNotCalledOnDestroy
();
469 * If this is called, this channel's transaction will not be dispatched
470 * until the HTTPSSVC record is available.
472 [must_use
] void setWaitForHTTPSSVCRecord
();
475 * This attribute indicates if the channel has support for HTTP3
477 [must_use
] readonly attribute
boolean supportsHTTP3
;
480 * This attribute indicates if the HTTPS RR is used for this channel.
482 [must_use
] readonly attribute
boolean hasHTTPSRR
;
485 * Set Early Hint Observer.
487 [must_use
] void setEarlyHintObserver
(in nsIEarlyHintObserver aObserver
);
490 * id of the EarlyHintPreloader to connect back from PreloadService to
491 * EarlyHintPreloader.
493 [must_use
] attribute
unsigned long long earlyHintPreloaderId
;
495 [notxpcom
, nostdcall
] void setConnectionInfo
(in nsHttpConnectionInfo aInfo
);
498 * This attribute indicates if the channel was loaded via Proxy.
500 [must_use
] readonly attribute
boolean isProxyUsed
;
503 * Set mWebTransportSessionEventListener.
505 [must_use
] void setWebTransportSessionEventListener
(
506 in WebTransportSessionEventListener aListener
);
509 * This attribute indicates the type of Link header in the received
512 [must_use
] attribute
unsigned long earlyHintLinkType
;