Bug 1845134 - Part 4: Update existing ui-icons to use the latest source from acorn...
[gecko.git] / netwerk / base / nsNetUtil.h
blob423e086c9a32fded02a45e2fe3be781ccf0f8593
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=4 sw=2 sts=2 et cin: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsNetUtil_h__
8 #define nsNetUtil_h__
10 #include <functional>
11 #include "mozilla/Maybe.h"
12 #include "mozilla/ResultExtensions.h"
13 #include "nsAttrValue.h"
14 #include "nsCOMPtr.h"
15 #include "nsIInterfaceRequestor.h"
16 #include "nsIInterfaceRequestorUtils.h"
17 #include "nsILoadGroup.h"
18 #include "nsINestedURI.h"
19 #include "nsINetUtil.h"
20 #include "nsIRequest.h"
21 #include "nsILoadInfo.h"
22 #include "nsIIOService.h"
23 #include "nsIURI.h"
24 #include "mozilla/NotNull.h"
25 #include "mozilla/Services.h"
26 #include "mozilla/Unused.h"
27 #include "nsNetCID.h"
28 #include "nsReadableUtils.h"
29 #include "nsServiceManagerUtils.h"
30 #include "nsString.h"
31 #include "nsTArray.h"
33 class nsIPrincipal;
34 class nsIAsyncStreamCopier;
35 class nsIAuthPrompt;
36 class nsIAuthPrompt2;
37 class nsIChannel;
38 class nsIChannelPolicy;
39 class nsICookieJarSettings;
40 class nsIDownloadObserver;
41 class nsIEventTarget;
42 class nsIFileProtocolHandler;
43 class nsIFileRandomAccessStream;
44 class nsIHttpChannel;
45 class nsIInputStream;
46 class nsIInputStreamPump;
47 class nsIInterfaceRequestor;
48 class nsIOutputStream;
49 class nsIParentChannel;
50 class nsIPersistentProperties;
51 class nsIProxyInfo;
52 class nsIRandomAccessStream;
53 class nsIRequestObserver;
54 class nsISerialEventTarget;
55 class nsIStreamListener;
56 class nsIStreamLoader;
57 class nsIStreamLoaderObserver;
58 class nsIIncrementalStreamLoader;
59 class nsIIncrementalStreamLoaderObserver;
61 namespace mozilla {
62 class Encoding;
63 class OriginAttributes;
64 class OriginTrials;
65 namespace dom {
66 class ClientInfo;
67 class PerformanceStorage;
68 class ServiceWorkerDescriptor;
69 } // namespace dom
71 namespace ipc {
72 class FileDescriptor;
73 } // namespace ipc
75 } // namespace mozilla
77 template <class>
78 class nsCOMPtr;
79 template <typename>
80 struct already_AddRefed;
82 already_AddRefed<nsIIOService> do_GetIOService(nsresult* error = nullptr);
84 already_AddRefed<nsINetUtil> do_GetNetUtil(nsresult* error = nullptr);
86 // private little helper function... don't call this directly!
87 nsresult net_EnsureIOService(nsIIOService** ios, nsCOMPtr<nsIIOService>& grip);
89 nsresult NS_NewURI(nsIURI** aURI, const nsACString& spec,
90 const char* charset = nullptr, nsIURI* baseURI = nullptr);
92 nsresult NS_NewURI(nsIURI** result, const nsACString& spec,
93 mozilla::NotNull<const mozilla::Encoding*> encoding,
94 nsIURI* baseURI = nullptr);
96 nsresult NS_NewURI(nsIURI** result, const nsAString& spec,
97 const char* charset = nullptr, nsIURI* baseURI = nullptr);
99 nsresult NS_NewURI(nsIURI** result, const nsAString& spec,
100 mozilla::NotNull<const mozilla::Encoding*> encoding,
101 nsIURI* baseURI = nullptr);
103 nsresult NS_NewURI(nsIURI** result, const char* spec,
104 nsIURI* baseURI = nullptr);
106 nsresult NS_NewFileURI(
107 nsIURI** result, nsIFile* spec,
108 nsIIOService* ioService =
109 nullptr); // pass in nsIIOService to optimize callers
111 // Functions for adding additional encoding to a URL for compatibility with
112 // Apple's NSURL class URLWithString method.
114 // @param aResult
115 // Out parameter for the encoded URL spec
116 // @param aSpec
117 // The spec for the URL to be encoded
118 nsresult NS_GetSpecWithNSURLEncoding(nsACString& aResult,
119 const nsACString& aSpec);
120 // @param aResult
121 // Out parameter for the encoded URI
122 // @param aSpec
123 // The spec for the URL to be encoded
124 nsresult NS_NewURIWithNSURLEncoding(nsIURI** aResult, const nsACString& aSpec);
126 // These methods will only mutate the URI if the ref of aInput doesn't already
127 // match the ref we are trying to set.
128 // If aInput has no ref, and we are calling NS_GetURIWithoutRef, or
129 // NS_GetURIWithNewRef with an empty string, then aOutput will be the same
130 // as aInput. The same is true if aRef is already equal to the ref of aInput.
131 // This is OK because URIs are immutable and threadsafe.
132 // If the URI doesn't support ref fragments aOutput will be the same as aInput.
133 nsresult NS_GetURIWithNewRef(nsIURI* aInput, const nsACString& aRef,
134 nsIURI** aOutput);
135 nsresult NS_GetURIWithoutRef(nsIURI* aInput, nsIURI** aOutput);
137 nsresult NS_GetSanitizedURIStringFromURI(nsIURI* aUri,
138 nsAString& aSanitizedSpec);
141 * How to create a new Channel, using NS_NewChannel,
142 * NS_NewChannelWithTriggeringPrincipal,
143 * NS_NewInputStreamChannel, NS_NewChannelInternal
144 * and it's variations:
146 * What specific API function to use:
147 * * The NS_NewChannelInternal functions should almost never be directly
148 * called outside of necko code.
149 * * If possible, use NS_NewChannel() providing a loading *nsINode*
150 * * If no loading *nsINode* is available, try calling NS_NewChannel() providing
151 * a loading *ClientInfo*.
152 * * If no loading *nsINode* or *ClientInfo* are available, call NS_NewChannel()
153 * providing a loading *nsIPrincipal*.
154 * * Call NS_NewChannelWithTriggeringPrincipal if the triggeringPrincipal
155 * is different from the loadingPrincipal.
156 * * Call NS_NewChannelInternal() providing aLoadInfo object in cases where
157 * you already have loadInfo object, e.g in case of a channel redirect.
159 * @param aURI
160 * nsIURI from which to make a channel
161 * @param aLoadingNode
162 * @param aLoadingPrincipal
163 * @param aTriggeringPrincipal
164 * @param aSecurityFlags
165 * @param aContentPolicyType
166 * These will be used as values for the nsILoadInfo object on the
167 * created channel. For details, see nsILoadInfo in nsILoadInfo.idl
169 * Please note, if you provide both a loadingNode and a loadingPrincipal,
170 * then loadingPrincipal must be equal to loadingNode->NodePrincipal().
171 * But less error prone is to just supply a loadingNode.
173 * Note, if you provide a loading ClientInfo its principal must match the
174 * loading principal. Currently you must pass both as the loading principal
175 * may have additional mutable values like CSP on it. In the future these
176 * will be removed from nsIPrincipal and the API can be changed to take just
177 * the loading ClientInfo.
179 * Keep in mind that URIs coming from a webpage should *never* use the
180 * systemPrincipal as the loadingPrincipal.
182 nsresult NS_NewChannelInternal(
183 nsIChannel** outChannel, nsIURI* aUri, nsINode* aLoadingNode,
184 nsIPrincipal* aLoadingPrincipal, nsIPrincipal* aTriggeringPrincipal,
185 const mozilla::Maybe<mozilla::dom::ClientInfo>& aLoadingClientInfo,
186 const mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController,
187 nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
188 nsICookieJarSettings* aCookieJarSettings = nullptr,
189 mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr,
190 nsILoadGroup* aLoadGroup = nullptr,
191 nsIInterfaceRequestor* aCallbacks = nullptr,
192 nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
193 nsIIOService* aIoService = nullptr, uint32_t aSandboxFlags = 0,
194 bool aSkipCheckForBrokenURLOrZeroSized = false);
196 // See NS_NewChannelInternal for usage and argument description
197 nsresult NS_NewChannelInternal(
198 nsIChannel** outChannel, nsIURI* aUri, nsILoadInfo* aLoadInfo,
199 mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr,
200 nsILoadGroup* aLoadGroup = nullptr,
201 nsIInterfaceRequestor* aCallbacks = nullptr,
202 nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
203 nsIIOService* aIoService = nullptr);
205 // See NS_NewChannelInternal for usage and argument description
206 nsresult /*NS_NewChannelWithNodeAndTriggeringPrincipal */
207 NS_NewChannelWithTriggeringPrincipal(
208 nsIChannel** outChannel, nsIURI* aUri, nsINode* aLoadingNode,
209 nsIPrincipal* aTriggeringPrincipal, nsSecurityFlags aSecurityFlags,
210 nsContentPolicyType aContentPolicyType,
211 mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr,
212 nsILoadGroup* aLoadGroup = nullptr,
213 nsIInterfaceRequestor* aCallbacks = nullptr,
214 nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
215 nsIIOService* aIoService = nullptr);
217 // See NS_NewChannelInternal for usage and argument description
218 nsresult NS_NewChannelWithTriggeringPrincipal(
219 nsIChannel** outChannel, nsIURI* aUri, nsIPrincipal* aLoadingPrincipal,
220 nsIPrincipal* aTriggeringPrincipal, nsSecurityFlags aSecurityFlags,
221 nsContentPolicyType aContentPolicyType,
222 nsICookieJarSettings* aCookieJarSettings = nullptr,
223 mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr,
224 nsILoadGroup* aLoadGroup = nullptr,
225 nsIInterfaceRequestor* aCallbacks = nullptr,
226 nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
227 nsIIOService* aIoService = nullptr);
229 // See NS_NewChannelInternal for usage and argument description
230 nsresult NS_NewChannelWithTriggeringPrincipal(
231 nsIChannel** outChannel, nsIURI* aUri, nsIPrincipal* aLoadingPrincipal,
232 nsIPrincipal* aTriggeringPrincipal,
233 const mozilla::dom::ClientInfo& aLoadingClientInfo,
234 const mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController,
235 nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
236 nsICookieJarSettings* aCookieJarSettings = nullptr,
237 mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr,
238 nsILoadGroup* aLoadGroup = nullptr,
239 nsIInterfaceRequestor* aCallbacks = nullptr,
240 nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
241 nsIIOService* aIoService = nullptr);
243 // See NS_NewChannelInternal for usage and argument description
244 nsresult NS_NewChannel(
245 nsIChannel** outChannel, nsIURI* aUri, nsINode* aLoadingNode,
246 nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
247 mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr,
248 nsILoadGroup* aLoadGroup = nullptr,
249 nsIInterfaceRequestor* aCallbacks = nullptr,
250 nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
251 nsIIOService* aIoService = nullptr, uint32_t aSandboxFlags = 0,
252 bool aSkipCheckForBrokenURLOrZeroSized = false);
254 // See NS_NewChannelInternal for usage and argument description
255 nsresult NS_NewChannel(
256 nsIChannel** outChannel, nsIURI* aUri, nsIPrincipal* aLoadingPrincipal,
257 nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
258 nsICookieJarSettings* aCookieJarSettings = nullptr,
259 mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr,
260 nsILoadGroup* aLoadGroup = nullptr,
261 nsIInterfaceRequestor* aCallbacks = nullptr,
262 nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
263 nsIIOService* aIoService = nullptr, uint32_t aSandboxFlags = 0,
264 bool aSkipCheckForBrokenURLOrZeroSized = false);
266 // See NS_NewChannelInternal for usage and argument description
267 nsresult NS_NewChannel(
268 nsIChannel** outChannel, nsIURI* aUri, nsIPrincipal* aLoadingPrincipal,
269 const mozilla::dom::ClientInfo& aLoadingClientInfo,
270 const mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController,
271 nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
272 nsICookieJarSettings* aCookieJarSettings = nullptr,
273 mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr,
274 nsILoadGroup* aLoadGroup = nullptr,
275 nsIInterfaceRequestor* aCallbacks = nullptr,
276 nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
277 nsIIOService* aIoService = nullptr, uint32_t aSandboxFlags = 0,
278 bool aSkipCheckForBrokenURLOrZeroSized = false);
280 nsresult NS_GetIsDocumentChannel(nsIChannel* aChannel, bool* aIsDocument);
282 nsresult NS_MakeAbsoluteURI(nsACString& result, const nsACString& spec,
283 nsIURI* baseURI);
285 nsresult NS_MakeAbsoluteURI(char** result, const char* spec, nsIURI* baseURI);
287 nsresult NS_MakeAbsoluteURI(nsAString& result, const nsAString& spec,
288 nsIURI* baseURI);
291 * This function is a helper function to get a scheme's default port.
293 int32_t NS_GetDefaultPort(const char* scheme,
294 nsIIOService* ioService = nullptr);
297 * The UTS #46 ToASCII operation as parametrized by the WHATWG URL Standard.
299 * Use this function to prepare a host name for network protocols.
301 nsresult NS_DomainToASCII(const nsACString& aHost, nsACString& aASCII);
304 * The UTS #46 ToUnicode operation as parametrized by the WHATWG URL Standard,
305 * except potentially misleading labels are treated according to ToASCII
306 * instead.
308 * Use this function to prepare a host name for display to the user.
310 nsresult NS_DomainToDisplay(const nsACString& aHost, nsACString& aDisplay);
313 * The UTS #46 ToUnicode operation as parametrized by the WHATWG URL Standard.
315 * It's most likely incorrect to call this function, and `NS_DomainToDisplay`
316 * should typically be called instead.
318 nsresult NS_DomainToUnicode(const nsACString& aHost, nsACString& aUnicode);
321 * This function is a helper function to get a protocol's default port if the
322 * URI does not specify a port explicitly. Returns -1 if this protocol has no
323 * concept of ports or if there was an error getting the port.
325 int32_t NS_GetRealPort(nsIURI* aURI);
327 nsresult NS_NewInputStreamChannelInternal(
328 nsIChannel** outChannel, nsIURI* aUri,
329 already_AddRefed<nsIInputStream> aStream, const nsACString& aContentType,
330 const nsACString& aContentCharset, nsILoadInfo* aLoadInfo);
332 nsresult NS_NewInputStreamChannelInternal(
333 nsIChannel** outChannel, nsIURI* aUri,
334 already_AddRefed<nsIInputStream> aStream, const nsACString& aContentType,
335 const nsACString& aContentCharset, nsINode* aLoadingNode,
336 nsIPrincipal* aLoadingPrincipal, nsIPrincipal* aTriggeringPrincipal,
337 nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType);
339 nsresult NS_NewInputStreamChannel(nsIChannel** outChannel, nsIURI* aUri,
340 already_AddRefed<nsIInputStream> aStream,
341 nsIPrincipal* aLoadingPrincipal,
342 nsSecurityFlags aSecurityFlags,
343 nsContentPolicyType aContentPolicyType,
344 const nsACString& aContentType = ""_ns,
345 const nsACString& aContentCharset = ""_ns);
347 nsresult NS_NewInputStreamChannelInternal(
348 nsIChannel** outChannel, nsIURI* aUri, const nsAString& aData,
349 const nsACString& aContentType, nsINode* aLoadingNode,
350 nsIPrincipal* aLoadingPrincipal, nsIPrincipal* aTriggeringPrincipal,
351 nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
352 bool aIsSrcdocChannel = false);
354 nsresult NS_NewInputStreamChannelInternal(nsIChannel** outChannel, nsIURI* aUri,
355 const nsAString& aData,
356 const nsACString& aContentType,
357 nsILoadInfo* aLoadInfo,
358 bool aIsSrcdocChannel = false);
360 nsresult NS_NewInputStreamChannel(nsIChannel** outChannel, nsIURI* aUri,
361 const nsAString& aData,
362 const nsACString& aContentType,
363 nsIPrincipal* aLoadingPrincipal,
364 nsSecurityFlags aSecurityFlags,
365 nsContentPolicyType aContentPolicyType,
366 bool aIsSrcdocChannel = false);
368 nsresult NS_NewInputStreamPump(
369 nsIInputStreamPump** aResult, already_AddRefed<nsIInputStream> aStream,
370 uint32_t aSegsize = 0, uint32_t aSegcount = 0, bool aCloseWhenDone = false,
371 nsISerialEventTarget* aMainThreadTarget = nullptr);
373 nsresult NS_NewLoadGroup(nsILoadGroup** result, nsIRequestObserver* obs);
375 // Create a new nsILoadGroup that will match the given principal.
376 nsresult NS_NewLoadGroup(nsILoadGroup** aResult, nsIPrincipal* aPrincipal);
378 // Determine if the given loadGroup/principal pair will produce a principal
379 // with similar permissions when passed to NS_NewChannel(). This checks for
380 // things like making sure the browser element flag matches. Without
381 // an appropriate load group these values can be lost when getting the result
382 // principal back out of the channel. Null principals are also always allowed
383 // as they do not have permissions to actually use the load group.
384 bool NS_LoadGroupMatchesPrincipal(nsILoadGroup* aLoadGroup,
385 nsIPrincipal* aPrincipal);
387 nsresult NS_NewDownloader(nsIStreamListener** result,
388 nsIDownloadObserver* observer,
389 nsIFile* downloadLocation = nullptr);
391 nsresult NS_NewStreamLoader(nsIStreamLoader** result,
392 nsIStreamLoaderObserver* observer,
393 nsIRequestObserver* requestObserver = nullptr);
395 nsresult NS_NewIncrementalStreamLoader(
396 nsIIncrementalStreamLoader** result,
397 nsIIncrementalStreamLoaderObserver* observer);
399 nsresult NS_NewStreamLoaderInternal(
400 nsIStreamLoader** outStream, nsIURI* aUri,
401 nsIStreamLoaderObserver* aObserver, nsINode* aLoadingNode,
402 nsIPrincipal* aLoadingPrincipal, nsSecurityFlags aSecurityFlags,
403 nsContentPolicyType aContentPolicyType, nsILoadGroup* aLoadGroup = nullptr,
404 nsIInterfaceRequestor* aCallbacks = nullptr,
405 nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL);
407 nsresult NS_NewStreamLoader(nsIStreamLoader** outStream, nsIURI* aUri,
408 nsIStreamLoaderObserver* aObserver,
409 nsINode* aLoadingNode,
410 nsSecurityFlags aSecurityFlags,
411 nsContentPolicyType aContentPolicyType,
412 nsILoadGroup* aLoadGroup = nullptr,
413 nsIInterfaceRequestor* aCallbacks = nullptr,
414 nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL);
416 nsresult NS_NewStreamLoader(nsIStreamLoader** outStream, nsIURI* aUri,
417 nsIStreamLoaderObserver* aObserver,
418 nsIPrincipal* aLoadingPrincipal,
419 nsSecurityFlags aSecurityFlags,
420 nsContentPolicyType aContentPolicyType,
421 nsILoadGroup* aLoadGroup = nullptr,
422 nsIInterfaceRequestor* aCallbacks = nullptr,
423 nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL);
425 nsresult NS_NewSyncStreamListener(nsIStreamListener** result,
426 nsIInputStream** stream);
429 * Implement the nsIChannel::Open(nsIInputStream**) method using the channel's
430 * AsyncOpen method.
432 * NOTE: Reading from the returned nsIInputStream may spin the current
433 * thread's event queue, which could result in any event being processed.
435 nsresult NS_ImplementChannelOpen(nsIChannel* channel, nsIInputStream** result);
437 nsresult NS_NewRequestObserverProxy(nsIRequestObserver** result,
438 nsIRequestObserver* observer,
439 nsISupports* context);
441 nsresult NS_NewSimpleStreamListener(nsIStreamListener** result,
442 nsIOutputStream* sink,
443 nsIRequestObserver* observer = nullptr);
445 nsresult NS_CheckPortSafety(int32_t port, const char* scheme,
446 nsIIOService* ioService = nullptr);
448 // Determine if this URI is using a safe port.
449 nsresult NS_CheckPortSafety(nsIURI* uri);
451 nsresult NS_NewProxyInfo(const nsACString& type, const nsACString& host,
452 int32_t port, uint32_t flags, nsIProxyInfo** result);
454 nsresult NS_GetFileProtocolHandler(nsIFileProtocolHandler** result,
455 nsIIOService* ioService = nullptr);
457 nsresult NS_GetFileFromURLSpec(const nsACString& inURL, nsIFile** result,
458 nsIIOService* ioService = nullptr);
460 nsresult NS_GetURLSpecFromFile(nsIFile* file, nsACString& url,
461 nsIIOService* ioService = nullptr);
464 * Converts the nsIFile to the corresponding URL string.
465 * Should only be called on files which are not directories,
466 * is otherwise identical to NS_GetURLSpecFromFile, but is
467 * usually more efficient.
468 * Warning: this restriction may not be enforced at runtime!
470 nsresult NS_GetURLSpecFromActualFile(nsIFile* file, nsACString& url,
471 nsIIOService* ioService = nullptr);
474 * Converts the nsIFile to the corresponding URL string.
475 * Should only be called on files which are directories,
476 * is otherwise identical to NS_GetURLSpecFromFile, but is
477 * usually more efficient.
478 * Warning: this restriction may not be enforced at runtime!
480 nsresult NS_GetURLSpecFromDir(nsIFile* file, nsACString& url,
481 nsIIOService* ioService = nullptr);
484 * Obtains the referrer for a given channel. This first tries to obtain the
485 * referrer from the property docshell.internalReferrer, and if that doesn't
486 * work and the channel is an nsIHTTPChannel, we check it's referrer property.
489 void NS_GetReferrerFromChannel(nsIChannel* channel, nsIURI** referrer);
491 nsresult NS_ParseRequestContentType(const nsACString& rawContentType,
492 nsCString& contentType,
493 nsCString& contentCharset);
495 nsresult NS_ParseResponseContentType(const nsACString& rawContentType,
496 nsCString& contentType,
497 nsCString& contentCharset);
499 nsresult NS_ExtractCharsetFromContentType(const nsACString& rawContentType,
500 nsCString& contentCharset,
501 bool* hadCharset,
502 int32_t* charsetStart,
503 int32_t* charsetEnd);
505 nsresult NS_NewLocalFileInputStream(nsIInputStream** result, nsIFile* file,
506 int32_t ioFlags = -1, int32_t perm = -1,
507 int32_t behaviorFlags = 0);
509 mozilla::Result<nsCOMPtr<nsIInputStream>, nsresult> NS_NewLocalFileInputStream(
510 nsIFile* file, int32_t ioFlags = -1, int32_t perm = -1,
511 int32_t behaviorFlags = 0);
513 nsresult NS_NewLocalFileOutputStream(nsIOutputStream** result, nsIFile* file,
514 int32_t ioFlags = -1, int32_t perm = -1,
515 int32_t behaviorFlags = 0);
517 mozilla::Result<nsCOMPtr<nsIOutputStream>, nsresult>
518 NS_NewLocalFileOutputStream(nsIFile* file, int32_t ioFlags = -1,
519 int32_t perm = -1, int32_t behaviorFlags = 0);
521 nsresult NS_NewLocalFileOutputStream(nsIOutputStream** result,
522 const mozilla::ipc::FileDescriptor& fd);
524 // returns a file output stream which can be QI'ed to nsISafeOutputStream.
525 nsresult NS_NewAtomicFileOutputStream(nsIOutputStream** result, nsIFile* file,
526 int32_t ioFlags = -1, int32_t perm = -1,
527 int32_t behaviorFlags = 0);
529 // returns a file output stream which can be QI'ed to nsISafeOutputStream.
530 nsresult NS_NewSafeLocalFileOutputStream(nsIOutputStream** result,
531 nsIFile* file, int32_t ioFlags = -1,
532 int32_t perm = -1,
533 int32_t behaviorFlags = 0);
535 nsresult NS_NewLocalFileRandomAccessStream(nsIRandomAccessStream** result,
536 nsIFile* file, int32_t ioFlags = -1,
537 int32_t perm = -1,
538 int32_t behaviorFlags = 0);
540 mozilla::Result<nsCOMPtr<nsIRandomAccessStream>, nsresult>
541 NS_NewLocalFileRandomAccessStream(nsIFile* file, int32_t ioFlags = -1,
542 int32_t perm = -1, int32_t behaviorFlags = 0);
544 [[nodiscard]] nsresult NS_NewBufferedInputStream(
545 nsIInputStream** aResult, already_AddRefed<nsIInputStream> aInputStream,
546 uint32_t aBufferSize);
548 mozilla::Result<nsCOMPtr<nsIInputStream>, nsresult> NS_NewBufferedInputStream(
549 already_AddRefed<nsIInputStream> aInputStream, uint32_t aBufferSize);
551 // note: the resulting stream can be QI'ed to nsISafeOutputStream iff the
552 // provided stream supports it.
553 nsresult NS_NewBufferedOutputStream(
554 nsIOutputStream** aResult, already_AddRefed<nsIOutputStream> aOutputStream,
555 uint32_t aBufferSize);
558 * This function reads an inputStream and stores its content into a buffer. In
559 * general, you should avoid using this function because, it blocks the current
560 * thread until the operation is done.
561 * If the inputStream is async, the reading happens on an I/O thread.
563 * @param aInputStream the inputStream.
564 * @param aDest the destination buffer. if *aDest is null, it will be allocated
565 * with the size of the written data. if aDest is not null, aCount
566 * must greater than 0.
567 * @param aCount the amount of data to read. Use -1 if you want that all the
568 * stream is read.
569 * @param aWritten this pointer will be used to store the number of data
570 * written in the buffer. If you don't need, pass nullptr.
572 nsresult NS_ReadInputStreamToBuffer(nsIInputStream* aInputStream, void** aDest,
573 int64_t aCount,
574 uint64_t* aWritten = nullptr);
577 * See the comment for NS_ReadInputStreamToBuffer
579 nsresult NS_ReadInputStreamToString(nsIInputStream* aInputStream,
580 nsACString& aDest, int64_t aCount,
581 uint64_t* aWritten = nullptr);
583 nsresult NS_LoadPersistentPropertiesFromURISpec(
584 nsIPersistentProperties** outResult, const nsACString& aSpec);
587 * NS_QueryNotificationCallbacks implements the canonical algorithm for
588 * querying interfaces from a channel's notification callbacks. It first
589 * searches the channel's notificationCallbacks attribute, and if the interface
590 * is not found there, then it inspects the notificationCallbacks attribute of
591 * the channel's loadGroup.
593 * Note: templatized only because nsIWebSocketChannel is currently not an
594 * nsIChannel.
596 template <class T>
597 inline void NS_QueryNotificationCallbacks(T* channel, const nsIID& iid,
598 void** result) {
599 MOZ_ASSERT(channel, "null channel");
600 *result = nullptr;
602 nsCOMPtr<nsIInterfaceRequestor> cbs;
603 mozilla::Unused << channel->GetNotificationCallbacks(getter_AddRefs(cbs));
604 if (cbs) cbs->GetInterface(iid, result);
605 if (!*result) {
606 // try load group's notification callbacks...
607 nsCOMPtr<nsILoadGroup> loadGroup;
608 mozilla::Unused << channel->GetLoadGroup(getter_AddRefs(loadGroup));
609 if (loadGroup) {
610 loadGroup->GetNotificationCallbacks(getter_AddRefs(cbs));
611 if (cbs) cbs->GetInterface(iid, result);
616 // template helper:
617 // Note: "class C" templatized only because nsIWebSocketChannel is currently not
618 // an nsIChannel.
620 template <class C, class T>
621 inline void NS_QueryNotificationCallbacks(C* channel, nsCOMPtr<T>& result) {
622 NS_QueryNotificationCallbacks(channel, NS_GET_TEMPLATE_IID(T),
623 getter_AddRefs(result));
627 * Alternate form of NS_QueryNotificationCallbacks designed for use by
628 * nsIChannel implementations.
630 inline void NS_QueryNotificationCallbacks(nsIInterfaceRequestor* callbacks,
631 nsILoadGroup* loadGroup,
632 const nsIID& iid, void** result) {
633 *result = nullptr;
635 if (callbacks) callbacks->GetInterface(iid, result);
636 if (!*result) {
637 // try load group's notification callbacks...
638 if (loadGroup) {
639 nsCOMPtr<nsIInterfaceRequestor> cbs;
640 loadGroup->GetNotificationCallbacks(getter_AddRefs(cbs));
641 if (cbs) cbs->GetInterface(iid, result);
647 * Returns true if channel is using Private Browsing, or false if not.
648 * Returns false if channel's callbacks don't implement nsILoadContext.
650 bool NS_UsePrivateBrowsing(nsIChannel* channel);
653 * Returns true if the channel has visited any cross-origin URLs on any
654 * URLs that it was redirected through.
656 bool NS_HasBeenCrossOrigin(nsIChannel* aChannel, bool aReport = false);
659 * Returns true if the channel has a safe method.
661 bool NS_IsSafeMethodNav(nsIChannel* aChannel);
663 // Unique first-party domain for separating the safebrowsing cookie.
664 // Note if this value is changed, code in test_cookiejars_safebrowsing.js and
665 // nsUrlClassifierHashCompleter.js should also be changed.
666 #define NECKO_SAFEBROWSING_FIRST_PARTY_DOMAIN \
667 "safebrowsing.86868755-6b82-4842-b301-72671a0db32e.mozilla"
669 // Unique first-party domain for separating about uri.
670 #define ABOUT_URI_FIRST_PARTY_DOMAIN \
671 "about.ef2a7dd5-93bc-417f-a698-142c3116864f.mozilla"
674 * Wraps an nsIAuthPrompt so that it can be used as an nsIAuthPrompt2. This
675 * method is provided mainly for use by other methods in this file.
677 * *aAuthPrompt2 should be set to null before calling this function.
679 void NS_WrapAuthPrompt(nsIAuthPrompt* aAuthPrompt,
680 nsIAuthPrompt2** aAuthPrompt2);
683 * Gets an auth prompt from an interface requestor. This takes care of wrapping
684 * an nsIAuthPrompt so that it can be used as an nsIAuthPrompt2.
686 void NS_QueryAuthPrompt2(nsIInterfaceRequestor* aCallbacks,
687 nsIAuthPrompt2** aAuthPrompt);
690 * Gets an nsIAuthPrompt2 from a channel. Use this instead of
691 * NS_QueryNotificationCallbacks for better backwards compatibility.
693 void NS_QueryAuthPrompt2(nsIChannel* aChannel, nsIAuthPrompt2** aAuthPrompt);
695 /* template helper */
696 template <class T>
697 inline void NS_QueryNotificationCallbacks(nsIInterfaceRequestor* callbacks,
698 nsILoadGroup* loadGroup,
699 nsCOMPtr<T>& result) {
700 NS_QueryNotificationCallbacks(callbacks, loadGroup, NS_GET_TEMPLATE_IID(T),
701 getter_AddRefs(result));
704 /* template helper */
705 template <class T>
706 inline void NS_QueryNotificationCallbacks(
707 const nsCOMPtr<nsIInterfaceRequestor>& aCallbacks,
708 const nsCOMPtr<nsILoadGroup>& aLoadGroup, nsCOMPtr<T>& aResult) {
709 NS_QueryNotificationCallbacks(aCallbacks.get(), aLoadGroup.get(), aResult);
712 /* template helper */
713 template <class T>
714 inline void NS_QueryNotificationCallbacks(const nsCOMPtr<nsIChannel>& aChannel,
715 nsCOMPtr<T>& aResult) {
716 NS_QueryNotificationCallbacks(aChannel.get(), aResult);
720 * This function returns a nsIInterfaceRequestor instance that returns the
721 * same result as NS_QueryNotificationCallbacks when queried. It is useful
722 * as the value for nsISocketTransport::securityCallbacks.
724 nsresult NS_NewNotificationCallbacksAggregation(
725 nsIInterfaceRequestor* callbacks, nsILoadGroup* loadGroup,
726 nsIEventTarget* target, nsIInterfaceRequestor** result);
728 nsresult NS_NewNotificationCallbacksAggregation(
729 nsIInterfaceRequestor* callbacks, nsILoadGroup* loadGroup,
730 nsIInterfaceRequestor** result);
733 * Helper function for testing online/offline state of the browser.
735 bool NS_IsOffline();
738 * Helper functions for implementing nsINestedURI::innermostURI.
740 * Note that NS_DoImplGetInnermostURI is "private" -- call
741 * NS_ImplGetInnermostURI instead.
743 nsresult NS_DoImplGetInnermostURI(nsINestedURI* nestedURI, nsIURI** result);
745 nsresult NS_ImplGetInnermostURI(nsINestedURI* nestedURI, nsIURI** result);
748 * Helper function for testing whether the given URI, or any of its
749 * inner URIs, has all the given protocol flags.
751 nsresult NS_URIChainHasFlags(nsIURI* uri, uint32_t flags, bool* result);
754 * Helper function for getting the innermost URI for a given URI. The return
755 * value could be just the object passed in if it's not a nested URI.
757 already_AddRefed<nsIURI> NS_GetInnermostURI(nsIURI* aURI);
760 * Helper function for getting the host name of the innermost URI for a given
761 * URI. The return value could be the host name of the URI passed in if it's
762 * not a nested URI.
764 inline nsresult NS_GetInnermostURIHost(nsIURI* aURI, nsACString& aHost) {
765 aHost.Truncate();
767 // This block is optimized in order to avoid the overhead of calling
768 // NS_GetInnermostURI() which incurs a lot of overhead in terms of
769 // AddRef/Release calls.
770 nsCOMPtr<nsINestedURI> nestedURI = do_QueryInterface(aURI);
771 if (nestedURI) {
772 // We have a nested URI!
773 nsCOMPtr<nsIURI> uri;
774 nsresult rv = nestedURI->GetInnermostURI(getter_AddRefs(uri));
775 if (NS_FAILED(rv)) {
776 return rv;
779 rv = uri->GetAsciiHost(aHost);
780 if (NS_FAILED(rv)) {
781 return rv;
783 } else {
784 // We have a non-nested URI!
785 nsresult rv = aURI->GetAsciiHost(aHost);
786 if (NS_FAILED(rv)) {
787 return rv;
791 return NS_OK;
795 * Get the "final" URI for a channel. This is either channel's load info
796 * resultPrincipalURI, if set, or GetOriginalURI. In most cases (but not all)
797 * load info resultPrincipalURI, if set, corresponds to URI of the channel if
798 * it's required to represent the actual principal for the channel.
800 nsresult NS_GetFinalChannelURI(nsIChannel* channel, nsIURI** uri);
802 // NS_SecurityHashURI must return the same hash value for any two URIs that
803 // compare equal according to NS_SecurityCompareURIs. Unfortunately, in the
804 // case of files, it's not clear we can do anything better than returning
805 // the schemeHash, so hashing files degenerates to storing them in a list.
806 uint32_t NS_SecurityHashURI(nsIURI* aURI);
808 bool NS_SecurityCompareURIs(nsIURI* aSourceURI, nsIURI* aTargetURI,
809 bool aStrictFileOriginPolicy);
811 bool NS_URIIsLocalFile(nsIURI* aURI);
813 // When strict file origin policy is enabled, SecurityCompareURIs will fail for
814 // file URIs that do not point to the same local file. This call provides an
815 // alternate file-specific origin check that allows target files that are
816 // contained in the same directory as the source.
818 // https://developer.mozilla.org/en-US/docs/Same-origin_policy_for_file:_URIs
819 bool NS_RelaxStrictFileOriginPolicy(nsIURI* aTargetURI, nsIURI* aSourceURI,
820 bool aAllowDirectoryTarget = false);
822 bool NS_IsInternalSameURIRedirect(nsIChannel* aOldChannel,
823 nsIChannel* aNewChannel, uint32_t aFlags);
825 bool NS_IsHSTSUpgradeRedirect(nsIChannel* aOldChannel, nsIChannel* aNewChannel,
826 uint32_t aFlags);
828 bool NS_ShouldRemoveAuthHeaderOnRedirect(nsIChannel* aOldChannel,
829 nsIChannel* aNewChannel,
830 uint32_t aFlags);
832 nsresult NS_LinkRedirectChannels(uint64_t channelId,
833 nsIParentChannel* parentChannel,
834 nsIChannel** _result);
837 * Returns nsILoadInfo::EMBEDDER_POLICY_REQUIRE_CORP if `aHeader` is
838 * "require-corp" and nsILoadInfo::EMBEDDER_POLICY_NULL otherwise.
840 * See: https://mikewest.github.io/corpp/#parsing
842 nsILoadInfo::CrossOriginEmbedderPolicy
843 NS_GetCrossOriginEmbedderPolicyFromHeader(
844 const nsACString& aHeader, bool aIsOriginTrialCoepCredentiallessEnabled);
846 /** Given the first (disposition) token from a Content-Disposition header,
847 * tell whether it indicates the content is inline or attachment
848 * @param aDispToken the disposition token from the content-disposition header
850 uint32_t NS_GetContentDispositionFromToken(const nsAString& aDispToken);
852 /** Determine the disposition (inline/attachment) of the content based on the
853 * Content-Disposition header
854 * @param aHeader the content-disposition header (full value)
855 * @param aChan the channel the header came from
857 uint32_t NS_GetContentDispositionFromHeader(const nsACString& aHeader,
858 nsIChannel* aChan = nullptr);
860 /** Extracts the filename out of a content-disposition header
861 * @param aFilename [out] The filename. Can be empty on error.
862 * @param aDisposition Value of a Content-Disposition header
865 nsresult NS_GetFilenameFromDisposition(nsAString& aFilename,
866 const nsACString& aDisposition);
869 * Make sure Personal Security Manager is initialized
871 void net_EnsurePSMInit();
874 * Test whether a URI is "about:blank". |uri| must not be null
876 bool NS_IsAboutBlank(nsIURI* uri);
879 * Test whether a URI is "about:srcdoc". |uri| must not be null
881 bool NS_IsAboutSrcdoc(nsIURI* uri);
883 nsresult NS_GenerateHostPort(const nsCString& host, int32_t port,
884 nsACString& hostLine);
887 * Sniff the content type for a given request or a given buffer.
889 * aSnifferType can be either NS_CONTENT_SNIFFER_CATEGORY or
890 * NS_DATA_SNIFFER_CATEGORY. The function returns the sniffed content type
891 * in the aSniffedType argument. This argument will not be modified if the
892 * content type could not be sniffed.
894 void NS_SniffContent(const char* aSnifferType, nsIRequest* aRequest,
895 const uint8_t* aData, uint32_t aLength,
896 nsACString& aSniffedType);
899 * Whether the channel was created to load a srcdoc document.
900 * Note that view-source:about:srcdoc is classified as a srcdoc document by
901 * this function, which may not be applicable everywhere.
903 bool NS_IsSrcdocChannel(nsIChannel* aChannel);
906 * Return true if the given string is a reasonable HTTP header value given the
907 * definition in RFC 2616 section 4.2. Currently we don't pay the cost to do
908 * full, sctrict validation here since it would require fulling parsing the
909 * value.
911 bool NS_IsReasonableHTTPHeaderValue(const nsACString& aValue);
914 * Return true if the given string is a valid HTTP token per RFC 2616 section
915 * 2.2.
917 bool NS_IsValidHTTPToken(const nsACString& aToken);
920 * Strip the leading or trailing HTTP whitespace per fetch spec section 2.2.
922 void NS_TrimHTTPWhitespace(const nsACString& aSource, nsACString& aDest);
924 template <typename Char>
925 constexpr bool NS_IsHTTPTokenPoint(Char aChar) {
926 using UnsignedChar = typename mozilla::detail::MakeUnsignedChar<Char>::Type;
927 auto c = static_cast<UnsignedChar>(aChar);
928 return c == '!' || c == '#' || c == '$' || c == '%' || c == '&' ||
929 c == '\'' || c == '*' || c == '+' || c == '-' || c == '.' ||
930 c == '^' || c == '_' || c == '`' || c == '|' || c == '~' ||
931 mozilla::IsAsciiAlphanumeric(c);
934 template <typename Char>
935 constexpr bool NS_IsHTTPQuotedStringTokenPoint(Char aChar) {
936 using UnsignedChar = typename mozilla::detail::MakeUnsignedChar<Char>::Type;
937 auto c = static_cast<UnsignedChar>(aChar);
938 return c == 0x9 || (c >= ' ' && c <= '~') || mozilla::IsNonAsciiLatin1(c);
941 template <typename Char>
942 constexpr bool NS_IsHTTPWhitespace(Char aChar) {
943 using UnsignedChar = typename mozilla::detail::MakeUnsignedChar<Char>::Type;
944 auto c = static_cast<UnsignedChar>(aChar);
945 return c == 0x9 || c == 0xA || c == 0xD || c == 0x20;
949 * Return true if the given request must be upgraded to HTTPS.
950 * If |aResultCallback| is provided and the storage is not ready to read, the
951 * result will be sent back through the callback and |aWillCallback| will be
952 * true. Otherwiew, the result will be set to |aShouldUpgrade| and
953 * |aWillCallback| is false.
955 nsresult NS_ShouldSecureUpgrade(
956 nsIURI* aURI, nsILoadInfo* aLoadInfo, nsIPrincipal* aChannelResultPrincipal,
957 bool aAllowSTS, const mozilla::OriginAttributes& aOriginAttributes,
958 bool& aShouldUpgrade, std::function<void(bool, nsresult)>&& aResultCallback,
959 bool& aWillCallback);
962 * Returns an https URI for channels that need to go through secure upgrades.
964 nsresult NS_GetSecureUpgradedURI(nsIURI* aURI, nsIURI** aUpgradedURI);
966 nsresult NS_CompareLoadInfoAndLoadContext(nsIChannel* aChannel);
969 * Return true if this channel should be classified by the URL classifier.
971 bool NS_ShouldClassifyChannel(nsIChannel* aChannel);
974 * Helper to set the blocking reason on loadinfo of the channel.
976 nsresult NS_SetRequestBlockingReason(nsIChannel* channel, uint32_t reason);
977 nsresult NS_SetRequestBlockingReason(nsILoadInfo* loadInfo, uint32_t reason);
978 nsresult NS_SetRequestBlockingReasonIfNull(nsILoadInfo* loadInfo,
979 uint32_t reason);
981 namespace mozilla {
982 namespace net {
984 const static uint64_t kJS_MAX_SAFE_UINTEGER = +9007199254740991ULL;
985 const static int64_t kJS_MIN_SAFE_INTEGER = -9007199254740991LL;
986 const static int64_t kJS_MAX_SAFE_INTEGER = +9007199254740991LL;
988 // Make sure a 64bit value can be captured by JS MAX_SAFE_INTEGER
989 bool InScriptableRange(int64_t val);
991 // Make sure a 64bit value can be captured by JS MAX_SAFE_INTEGER
992 bool InScriptableRange(uint64_t val);
995 * Given the value of a single header field (such as
996 * Content-Disposition and Content-Type) and the name of a parameter
997 * (e.g. filename, name, charset), returns the value of the parameter.
998 * See nsIMIMEHeaderParam.idl for more information.
1000 * @param aHeaderVal a header string to get the value of a parameter
1001 * from.
1002 * @param aParamName the name of a MIME header parameter (e.g.
1003 * filename, name, charset). If empty or nullptr,
1004 * returns the first (possibly) _unnamed_ 'parameter'.
1005 * @return the value of <code>aParamName</code> in Unichar(UTF-16).
1007 nsresult GetParameterHTTP(const nsACString& aHeaderVal, const char* aParamName,
1008 nsAString& aResult);
1011 * Helper function that determines if channel is an HTTP POST.
1013 * @param aChannel
1014 * The channel to test
1016 * @return True if channel is an HTTP post.
1018 bool ChannelIsPost(nsIChannel* aChannel);
1021 * Convenience functions for verifying nsIURI schemes. These functions simply
1022 * wrap aURI->SchemeIs(), but specify the protocol as part of the function name.
1025 bool SchemeIsHTTP(nsIURI* aURI);
1026 bool SchemeIsHTTPS(nsIURI* aURI);
1027 bool SchemeIsJavascript(nsIURI* aURI);
1028 bool SchemeIsChrome(nsIURI* aURI);
1029 bool SchemeIsAbout(nsIURI* aURI);
1030 bool SchemeIsBlob(nsIURI* aURI);
1031 bool SchemeIsFile(nsIURI* aURI);
1032 bool SchemeIsData(nsIURI* aURI);
1033 bool SchemeIsViewSource(nsIURI* aURI);
1034 bool SchemeIsResource(nsIURI* aURI);
1035 bool SchemeIsFTP(nsIURI* aURI);
1037 // Helper functions for SetProtocol methods to follow
1038 // step 2.1 in https://url.spec.whatwg.org/#scheme-state
1039 bool SchemeIsSpecial(const nsACString&);
1040 bool IsSchemeChangePermitted(nsIURI*, const nsACString&);
1041 already_AddRefed<nsIURI> TryChangeProtocol(nsIURI*, const nsAString&);
1043 struct LinkHeader {
1044 nsString mHref;
1045 nsString mRel;
1046 nsString mTitle;
1047 nsString mNonce;
1048 nsString mIntegrity;
1049 nsString mSrcset;
1050 nsString mSizes;
1051 nsString mType;
1052 nsString mMedia;
1053 nsString mAnchor;
1054 nsString mCrossOrigin;
1055 nsString mReferrerPolicy;
1056 nsString mAs;
1057 nsString mFetchPriority;
1059 LinkHeader();
1060 void Reset();
1062 nsresult NewResolveHref(nsIURI** aOutURI, nsIURI* aBaseURI) const;
1064 bool operator==(const LinkHeader& rhs) const;
1066 void MaybeUpdateAttribute(const nsAString& aAttribute,
1067 const char16_t* aValue);
1070 // Implements roughly step 2 to 4 of
1071 // <https://httpwg.org/specs/rfc8288.html#parse-set>.
1072 nsTArray<LinkHeader> ParseLinkHeader(const nsAString& aLinkData);
1074 enum ASDestination : uint8_t {
1075 DESTINATION_INVALID,
1076 DESTINATION_AUDIO,
1077 DESTINATION_DOCUMENT,
1078 DESTINATION_EMBED,
1079 DESTINATION_FONT,
1080 DESTINATION_IMAGE,
1081 DESTINATION_MANIFEST,
1082 DESTINATION_OBJECT,
1083 DESTINATION_REPORT,
1084 DESTINATION_SCRIPT,
1085 DESTINATION_SERVICEWORKER,
1086 DESTINATION_SHAREDWORKER,
1087 DESTINATION_STYLE,
1088 DESTINATION_TRACK,
1089 DESTINATION_VIDEO,
1090 DESTINATION_WORKER,
1091 DESTINATION_XSLT,
1092 DESTINATION_FETCH
1095 void ParseAsValue(const nsAString& aValue, nsAttrValue& aResult);
1096 nsContentPolicyType AsValueToContentPolicy(const nsAttrValue& aValue);
1097 bool IsScriptLikeOrInvalid(const nsAString& aAs);
1099 bool CheckPreloadAttrs(const nsAttrValue& aAs, const nsAString& aType,
1100 const nsAString& aMedia,
1101 mozilla::dom::Document* aDocument);
1102 void WarnIgnoredPreload(const mozilla::dom::Document&, nsIURI&);
1105 * Returns true if the |aInput| in is part of the root domain of |aHost|.
1106 * For example, if |aInput| is "www.mozilla.org", and we pass in
1107 * "mozilla.org" as |aHost|, this will return true. It would return false
1108 * the other way around.
1110 * @param aInput The host to be analyzed.
1111 * @param aHost The host to compare to.
1113 nsresult HasRootDomain(const nsACString& aInput, const nsACString& aHost,
1114 bool* aResult);
1116 void CheckForBrokenChromeURL(nsILoadInfo* aLoadInfo, nsIURI* aURI);
1118 bool IsCoepCredentiallessEnabled(bool aIsOriginTrialCoepCredentiallessEnabled);
1120 } // namespace net
1121 } // namespace mozilla
1123 #endif // !nsNetUtil_h__