2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2004-10-25 17:15:25 +04:00
|
|
|
/* vim:set ts=4 sw=4 sts=4 et cin: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-11-01 23:48:12 +03:00
|
|
|
|
|
|
|
#ifndef nsNetUtil_h__
|
|
|
|
#define nsNetUtil_h__
|
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1999-11-18 10:36:41 +03:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
2001-09-06 01:28:38 +04:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2015-05-20 05:48:00 +03:00
|
|
|
#include "nsILoadGroup.h"
|
2005-07-26 00:27:04 +04:00
|
|
|
#include "nsINetUtil.h"
|
2015-05-20 05:48:00 +03:00
|
|
|
#include "nsIRequest.h"
|
|
|
|
#include "nsILoadInfo.h"
|
|
|
|
#include "nsIIOService.h"
|
2010-04-12 19:44:28 +04:00
|
|
|
#include "mozilla/Services.h"
|
2015-05-20 05:48:00 +03:00
|
|
|
#include "nsNetCID.h"
|
2016-01-09 04:20:50 +03:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2012-09-28 14:04:32 +04:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
class nsIURI;
|
|
|
|
class nsIPrincipal;
|
|
|
|
class nsIAsyncStreamCopier;
|
|
|
|
class nsIAuthPrompt;
|
|
|
|
class nsIAuthPrompt2;
|
|
|
|
class nsIChannel;
|
|
|
|
class nsIChannelPolicy;
|
|
|
|
class nsIDownloadObserver;
|
|
|
|
class nsIEventTarget;
|
|
|
|
class nsIFileProtocolHandler;
|
|
|
|
class nsIFileStream;
|
|
|
|
class nsIInputStream;
|
|
|
|
class nsIInputStreamPump;
|
|
|
|
class nsIInterfaceRequestor;
|
|
|
|
class nsINestedURI;
|
|
|
|
class nsINetworkInterface;
|
|
|
|
class nsIOutputStream;
|
|
|
|
class nsIParentChannel;
|
|
|
|
class nsIPersistentProperties;
|
|
|
|
class nsIProxyInfo;
|
|
|
|
class nsIRequestObserver;
|
|
|
|
class nsIStreamListener;
|
|
|
|
class nsIStreamLoader;
|
|
|
|
class nsIStreamLoaderObserver;
|
2015-11-30 17:54:11 +03:00
|
|
|
class nsIIncrementalStreamLoader;
|
|
|
|
class nsIIncrementalStreamLoaderObserver;
|
2015-05-20 05:48:00 +03:00
|
|
|
class nsIUnicharStreamLoader;
|
|
|
|
class nsIUnicharStreamLoaderObserver;
|
|
|
|
|
2015-11-03 04:50:54 +03:00
|
|
|
namespace mozilla { class NeckoOriginAttributes; }
|
2015-09-03 05:46:03 +03:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
template <class> class nsCOMPtr;
|
|
|
|
template <typename> struct already_AddRefed;
|
2010-04-12 19:44:28 +04:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
2013-06-29 07:04:42 +04:00
|
|
|
#include "nsReadableUtils.h"
|
2015-05-20 05:48:00 +03:00
|
|
|
#include "nsString.h"
|
|
|
|
#else
|
|
|
|
#include "nsStringAPI.h"
|
|
|
|
#endif
|
2013-06-29 07:04:42 +04:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
|
|
|
already_AddRefed<nsIIOService> do_GetIOService(nsresult *error = 0);
|
|
|
|
|
|
|
|
already_AddRefed<nsINetUtil> do_GetNetUtil(nsresult *error = 0);
|
2010-04-12 19:44:28 +04:00
|
|
|
|
|
|
|
#else
|
2000-09-09 03:31:26 +04:00
|
|
|
// Helper, to simplify getting the I/O service.
|
2015-05-20 05:48:00 +03:00
|
|
|
const nsGetServiceByContractIDWithError do_GetIOService(nsresult *error = 0);
|
2000-09-09 03:31:26 +04:00
|
|
|
|
2010-04-12 19:44:28 +04:00
|
|
|
// An alias to do_GetIOService
|
2015-05-20 05:48:00 +03:00
|
|
|
const nsGetServiceByContractIDWithError do_GetNetUtil(nsresult *error = 0);
|
|
|
|
|
2010-04-12 19:44:28 +04:00
|
|
|
#endif
|
|
|
|
|
2003-06-19 03:07:09 +04:00
|
|
|
// private little helper function... don't call this directly!
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult net_EnsureIOService(nsIIOService **ios, nsCOMPtr<nsIIOService> &grip);
|
2003-06-19 03:07:09 +04:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_NewURI(nsIURI **result,
|
|
|
|
const nsACString &spec,
|
|
|
|
const char *charset = nullptr,
|
|
|
|
nsIURI *baseURI = nullptr,
|
|
|
|
nsIIOService *ioService = nullptr); // pass in nsIIOService to optimize callers
|
1999-11-01 23:48:12 +03:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_NewURI(nsIURI **result,
|
|
|
|
const nsAString &spec,
|
|
|
|
const char *charset = nullptr,
|
|
|
|
nsIURI *baseURI = nullptr,
|
|
|
|
nsIIOService *ioService = nullptr); // pass in nsIIOService to optimize callers
|
1999-11-01 23:48:12 +03:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_NewURI(nsIURI **result,
|
|
|
|
const char *spec,
|
|
|
|
nsIURI *baseURI = nullptr,
|
|
|
|
nsIIOService *ioService = nullptr); // pass in nsIIOService to optimize callers
|
2001-06-22 02:02:47 +04:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_NewFileURI(nsIURI **result,
|
|
|
|
nsIFile *spec,
|
|
|
|
nsIIOService *ioService = nullptr); // pass in nsIIOService to optimize callers
|
2001-06-22 02:02:47 +04:00
|
|
|
|
2014-07-18 01:52:25 +04:00
|
|
|
/*
|
2014-12-12 20:05:09 +03:00
|
|
|
* How to create a new Channel, using NS_NewChannel,
|
2015-01-12 07:26:40 +03:00
|
|
|
* NS_NewChannelWithTriggeringPrincipal,
|
2014-12-12 20:05:09 +03:00
|
|
|
* NS_NewInputStreamChannel, NS_NewChannelInternal
|
|
|
|
* and it's variations:
|
|
|
|
*
|
2014-12-13 00:45:51 +03:00
|
|
|
* What specific API function to use:
|
|
|
|
* * The NS_NewChannelInternal functions should almost never be directly
|
|
|
|
* called outside of necko code.
|
|
|
|
* * If possible, use NS_NewChannel() providing a loading *nsINode*
|
|
|
|
* * If no loading *nsINode* is avaialable, call NS_NewChannel() providing
|
|
|
|
* a loading *nsIPrincipal*.
|
|
|
|
* * Call NS_NewChannelWithTriggeringPrincipal if the triggeringPrincipal
|
|
|
|
* is different from the loadingPrincipal.
|
|
|
|
* * Call NS_NewChannelInternal() providing aLoadInfo object in cases where
|
|
|
|
* you already have loadInfo object, e.g in case of a channel redirect.
|
2014-12-12 20:05:09 +03:00
|
|
|
*
|
|
|
|
* @param aURI
|
|
|
|
* nsIURI from which to make a channel
|
|
|
|
* @param aLoadingNode
|
|
|
|
* @param aLoadingPrincipal
|
|
|
|
* @param aTriggeringPrincipal
|
|
|
|
* @param aSecurityFlags
|
|
|
|
* @param aContentPolicyType
|
2016-09-20 09:34:40 +03:00
|
|
|
* These will be used as values for the nsILoadInfo object on the
|
|
|
|
* created channel. For details, see nsILoadInfo in nsILoadInfo.idl
|
2014-12-12 20:05:09 +03:00
|
|
|
*
|
2014-12-13 00:45:51 +03:00
|
|
|
* Please note, if you provide both a loadingNode and a loadingPrincipal,
|
|
|
|
* then loadingPrincipal must be equal to loadingNode->NodePrincipal().
|
|
|
|
* But less error prone is to just supply a loadingNode.
|
2015-01-07 04:01:07 +03:00
|
|
|
*
|
|
|
|
* Keep in mind that URIs coming from a webpage should *never* use the
|
|
|
|
* systemPrincipal as the loadingPrincipal.
|
2014-12-12 20:05:09 +03:00
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_NewChannelInternal(nsIChannel **outChannel,
|
|
|
|
nsIURI *aUri,
|
|
|
|
nsINode *aLoadingNode,
|
|
|
|
nsIPrincipal *aLoadingPrincipal,
|
|
|
|
nsIPrincipal *aTriggeringPrincipal,
|
|
|
|
nsSecurityFlags aSecurityFlags,
|
|
|
|
nsContentPolicyType aContentPolicyType,
|
|
|
|
nsILoadGroup *aLoadGroup = nullptr,
|
|
|
|
nsIInterfaceRequestor *aCallbacks = nullptr,
|
|
|
|
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
|
|
|
|
nsIIOService *aIoService = nullptr);
|
2014-07-18 01:52:25 +04:00
|
|
|
|
2014-12-12 20:05:09 +03:00
|
|
|
// See NS_NewChannelInternal for usage and argument description
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_NewChannelInternal(nsIChannel **outChannel,
|
|
|
|
nsIURI *aUri,
|
|
|
|
nsILoadInfo *aLoadInfo,
|
|
|
|
nsILoadGroup *aLoadGroup = nullptr,
|
|
|
|
nsIInterfaceRequestor *aCallbacks = nullptr,
|
|
|
|
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
|
|
|
|
nsIIOService *aIoService = nullptr);
|
2014-07-18 01:52:25 +04:00
|
|
|
|
2014-12-12 20:05:09 +03:00
|
|
|
// See NS_NewChannelInternal for usage and argument description
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult /*NS_NewChannelWithNodeAndTriggeringPrincipal */
|
|
|
|
NS_NewChannelWithTriggeringPrincipal(nsIChannel **outChannel,
|
|
|
|
nsIURI *aUri,
|
|
|
|
nsINode *aLoadingNode,
|
|
|
|
nsIPrincipal *aTriggeringPrincipal,
|
2014-11-14 19:56:39 +03:00
|
|
|
nsSecurityFlags aSecurityFlags,
|
|
|
|
nsContentPolicyType aContentPolicyType,
|
2015-05-20 05:48:00 +03:00
|
|
|
nsILoadGroup *aLoadGroup = nullptr,
|
|
|
|
nsIInterfaceRequestor *aCallbacks = nullptr,
|
2014-11-14 19:56:39 +03:00
|
|
|
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
|
2015-05-20 05:48:00 +03:00
|
|
|
nsIIOService *aIoService = nullptr);
|
|
|
|
|
2014-11-14 19:56:39 +03:00
|
|
|
|
2014-12-12 20:05:09 +03:00
|
|
|
// See NS_NewChannelInternal for usage and argument description
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult /*NS_NewChannelWithPrincipalAndTriggeringPrincipal */
|
|
|
|
NS_NewChannelWithTriggeringPrincipal(nsIChannel **outChannel,
|
|
|
|
nsIURI *aUri,
|
|
|
|
nsIPrincipal *aLoadingPrincipal,
|
|
|
|
nsIPrincipal *aTriggeringPrincipal,
|
2014-11-14 19:56:39 +03:00
|
|
|
nsSecurityFlags aSecurityFlags,
|
|
|
|
nsContentPolicyType aContentPolicyType,
|
2015-05-20 05:48:00 +03:00
|
|
|
nsILoadGroup *aLoadGroup = nullptr,
|
|
|
|
nsIInterfaceRequestor *aCallbacks = nullptr,
|
2014-11-14 19:56:39 +03:00
|
|
|
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
|
2015-05-20 05:48:00 +03:00
|
|
|
nsIIOService *aIoService = nullptr);
|
2014-11-14 19:56:39 +03:00
|
|
|
|
2014-12-12 20:05:09 +03:00
|
|
|
// See NS_NewChannelInternal for usage and argument description
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult /* NS_NewChannelNode */
|
|
|
|
NS_NewChannel(nsIChannel **outChannel,
|
|
|
|
nsIURI *aUri,
|
|
|
|
nsINode *aLoadingNode,
|
2014-07-18 01:52:25 +04:00
|
|
|
nsSecurityFlags aSecurityFlags,
|
|
|
|
nsContentPolicyType aContentPolicyType,
|
2015-05-20 05:48:00 +03:00
|
|
|
nsILoadGroup *aLoadGroup = nullptr,
|
|
|
|
nsIInterfaceRequestor *aCallbacks = nullptr,
|
2014-07-18 01:52:25 +04:00
|
|
|
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
|
2015-05-20 05:48:00 +03:00
|
|
|
nsIIOService *aIoService = nullptr);
|
2014-07-18 01:52:25 +04:00
|
|
|
|
2014-12-12 20:05:09 +03:00
|
|
|
// See NS_NewChannelInternal for usage and argument description
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult /* NS_NewChannelPrincipal */
|
|
|
|
NS_NewChannel(nsIChannel **outChannel,
|
|
|
|
nsIURI *aUri,
|
|
|
|
nsIPrincipal *aLoadingPrincipal,
|
2014-07-18 01:52:25 +04:00
|
|
|
nsSecurityFlags aSecurityFlags,
|
|
|
|
nsContentPolicyType aContentPolicyType,
|
2015-05-20 05:48:00 +03:00
|
|
|
nsILoadGroup *aLoadGroup = nullptr,
|
|
|
|
nsIInterfaceRequestor *aCallbacks = nullptr,
|
2014-07-18 01:52:25 +04:00
|
|
|
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
|
2015-05-20 05:48:00 +03:00
|
|
|
nsIIOService *aIoService = nullptr);
|
1999-11-01 23:48:12 +03:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_MakeAbsoluteURI(nsACString &result,
|
|
|
|
const nsACString &spec,
|
|
|
|
nsIURI *baseURI);
|
1999-11-01 23:48:12 +03:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_MakeAbsoluteURI(char **result,
|
|
|
|
const char *spec,
|
|
|
|
nsIURI *baseURI);
|
2002-03-06 10:48:55 +03:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_MakeAbsoluteURI(nsAString &result,
|
|
|
|
const nsAString &spec,
|
|
|
|
nsIURI *baseURI);
|
1999-11-01 23:48:12 +03:00
|
|
|
|
2008-01-31 11:16:54 +03:00
|
|
|
/**
|
|
|
|
* This function is a helper function to get a scheme's default port.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
int32_t NS_GetDefaultPort(const char *scheme,
|
|
|
|
nsIIOService *ioService = nullptr);
|
2008-01-31 11:16:54 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This function is a helper function to apply the ToAscii conversion
|
|
|
|
* to a string
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
bool NS_StringToACE(const nsACString &idn, nsACString &result);
|
2008-01-31 11:16:54 +03:00
|
|
|
|
2006-08-27 01:42:54 +04:00
|
|
|
/**
|
|
|
|
* This function is a helper function to get a protocol's default port if the
|
|
|
|
* URI does not specify a port explicitly. Returns -1 if this protocol has no
|
|
|
|
* concept of ports or if there was an error getting the port.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
int32_t NS_GetRealPort(nsIURI *aURI);
|
|
|
|
|
|
|
|
nsresult /* NS_NewInputStreamChannelWithLoadInfo */
|
|
|
|
NS_NewInputStreamChannelInternal(nsIChannel **outChannel,
|
|
|
|
nsIURI *aUri,
|
|
|
|
nsIInputStream *aStream,
|
|
|
|
const nsACString &aContentType,
|
|
|
|
const nsACString &aContentCharset,
|
|
|
|
nsILoadInfo *aLoadInfo);
|
|
|
|
|
|
|
|
nsresult NS_NewInputStreamChannelInternal(nsIChannel **outChannel,
|
|
|
|
nsIURI *aUri,
|
|
|
|
nsIInputStream *aStream,
|
|
|
|
const nsACString &aContentType,
|
|
|
|
const nsACString &aContentCharset,
|
|
|
|
nsINode *aLoadingNode,
|
|
|
|
nsIPrincipal *aLoadingPrincipal,
|
|
|
|
nsIPrincipal *aTriggeringPrincipal,
|
|
|
|
nsSecurityFlags aSecurityFlags,
|
2015-08-19 20:43:30 +03:00
|
|
|
nsContentPolicyType aContentPolicyType);
|
2015-05-20 05:48:00 +03:00
|
|
|
|
|
|
|
|
|
|
|
nsresult /* NS_NewInputStreamChannelPrincipal */
|
|
|
|
NS_NewInputStreamChannel(nsIChannel **outChannel,
|
|
|
|
nsIURI *aUri,
|
|
|
|
nsIInputStream *aStream,
|
|
|
|
nsIPrincipal *aLoadingPrincipal,
|
2014-10-16 22:14:05 +04:00
|
|
|
nsSecurityFlags aSecurityFlags,
|
|
|
|
nsContentPolicyType aContentPolicyType,
|
2015-05-20 05:48:00 +03:00
|
|
|
const nsACString &aContentType = EmptyCString(),
|
|
|
|
const nsACString &aContentCharset = EmptyCString());
|
|
|
|
|
|
|
|
nsresult NS_NewInputStreamChannelInternal(nsIChannel **outChannel,
|
|
|
|
nsIURI *aUri,
|
|
|
|
const nsAString &aData,
|
|
|
|
const nsACString &aContentType,
|
|
|
|
nsINode *aLoadingNode,
|
|
|
|
nsIPrincipal *aLoadingPrincipal,
|
|
|
|
nsIPrincipal *aTriggeringPrincipal,
|
|
|
|
nsSecurityFlags aSecurityFlags,
|
|
|
|
nsContentPolicyType aContentPolicyType,
|
2015-08-19 20:43:30 +03:00
|
|
|
bool aIsSrcdocChannel = false);
|
2015-05-20 05:48:00 +03:00
|
|
|
|
2016-03-04 19:54:07 +03:00
|
|
|
nsresult
|
|
|
|
NS_NewInputStreamChannelInternal(nsIChannel **outChannel,
|
|
|
|
nsIURI *aUri,
|
|
|
|
const nsAString &aData,
|
|
|
|
const nsACString &aContentType,
|
|
|
|
nsILoadInfo *aLoadInfo,
|
|
|
|
bool aIsSrcdocChannel = false);
|
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_NewInputStreamChannel(nsIChannel **outChannel,
|
|
|
|
nsIURI *aUri,
|
|
|
|
const nsAString &aData,
|
|
|
|
const nsACString &aContentType,
|
|
|
|
nsIPrincipal *aLoadingPrincipal,
|
|
|
|
nsSecurityFlags aSecurityFlags,
|
|
|
|
nsContentPolicyType aContentPolicyType,
|
2015-08-19 20:43:30 +03:00
|
|
|
bool aIsSrcdocChannel = false);
|
2015-05-20 05:48:00 +03:00
|
|
|
|
|
|
|
nsresult NS_NewInputStreamPump(nsIInputStreamPump **result,
|
|
|
|
nsIInputStream *stream,
|
|
|
|
int64_t streamPos = int64_t(-1),
|
|
|
|
int64_t streamLen = int64_t(-1),
|
|
|
|
uint32_t segsize = 0,
|
|
|
|
uint32_t segcount = 0,
|
|
|
|
bool closeWhenDone = false);
|
2000-04-13 13:20:50 +04:00
|
|
|
|
2003-10-06 05:46:31 +04:00
|
|
|
// NOTE: you will need to specify whether or not your streams are buffered
|
|
|
|
// (i.e., do they implement ReadSegments/WriteSegments). the default
|
|
|
|
// assumption of TRUE for both streams might not be right for you!
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_NewAsyncStreamCopier(nsIAsyncStreamCopier **result,
|
|
|
|
nsIInputStream *source,
|
|
|
|
nsIOutputStream *sink,
|
|
|
|
nsIEventTarget *target,
|
|
|
|
bool sourceBuffered = true,
|
|
|
|
bool sinkBuffered = true,
|
|
|
|
uint32_t chunkSize = 0,
|
|
|
|
bool closeSource = true,
|
|
|
|
bool closeSink = true);
|
|
|
|
|
|
|
|
nsresult NS_NewLoadGroup(nsILoadGroup **result,
|
|
|
|
nsIRequestObserver *obs);
|
1999-11-30 07:50:42 +03:00
|
|
|
|
2014-12-15 16:39:00 +03:00
|
|
|
// Create a new nsILoadGroup that will match the given principal.
|
|
|
|
nsresult
|
2015-05-20 05:48:00 +03:00
|
|
|
NS_NewLoadGroup(nsILoadGroup **aResult, nsIPrincipal* aPrincipal);
|
2014-12-15 16:39:00 +03:00
|
|
|
|
|
|
|
// Determine if the given loadGroup/principal pair will produce a principal
|
|
|
|
// with similar permissions when passed to NS_NewChannel(). This checks for
|
|
|
|
// things like making sure the appId and browser element flags match. Without
|
|
|
|
// an appropriate load group these values can be lost when getting the result
|
|
|
|
// principal back out of the channel. Null principals are also always allowed
|
|
|
|
// as they do not have permissions to actually use the load group.
|
|
|
|
bool
|
2015-05-20 05:48:00 +03:00
|
|
|
NS_LoadGroupMatchesPrincipal(nsILoadGroup *aLoadGroup,
|
|
|
|
nsIPrincipal *aPrincipal);
|
|
|
|
|
|
|
|
nsresult NS_NewDownloader(nsIStreamListener **result,
|
|
|
|
nsIDownloadObserver *observer,
|
|
|
|
nsIFile *downloadLocation = nullptr);
|
|
|
|
|
|
|
|
nsresult NS_NewStreamLoader(nsIStreamLoader **result,
|
|
|
|
nsIStreamLoaderObserver *observer,
|
|
|
|
nsIRequestObserver *requestObserver = nullptr);
|
|
|
|
|
2015-11-30 17:54:11 +03:00
|
|
|
nsresult NS_NewIncrementalStreamLoader(nsIIncrementalStreamLoader **result,
|
|
|
|
nsIIncrementalStreamLoaderObserver *observer);
|
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_NewStreamLoaderInternal(nsIStreamLoader **outStream,
|
|
|
|
nsIURI *aUri,
|
|
|
|
nsIStreamLoaderObserver *aObserver,
|
|
|
|
nsINode *aLoadingNode,
|
|
|
|
nsIPrincipal *aLoadingPrincipal,
|
|
|
|
nsSecurityFlags aSecurityFlags,
|
|
|
|
nsContentPolicyType aContentPolicyType,
|
|
|
|
nsILoadGroup *aLoadGroup = nullptr,
|
|
|
|
nsIInterfaceRequestor *aCallbacks = nullptr,
|
|
|
|
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
|
|
|
|
nsIURI *aReferrer = nullptr);
|
|
|
|
|
|
|
|
nsresult /* NS_NewStreamLoaderNode */
|
|
|
|
NS_NewStreamLoader(nsIStreamLoader **outStream,
|
|
|
|
nsIURI *aUri,
|
|
|
|
nsIStreamLoaderObserver *aObserver,
|
|
|
|
nsINode *aLoadingNode,
|
2014-07-18 01:52:25 +04:00
|
|
|
nsSecurityFlags aSecurityFlags,
|
|
|
|
nsContentPolicyType aContentPolicyType,
|
2015-05-20 05:48:00 +03:00
|
|
|
nsILoadGroup *aLoadGroup = nullptr,
|
|
|
|
nsIInterfaceRequestor *aCallbacks = nullptr,
|
2014-07-18 01:52:25 +04:00
|
|
|
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
|
2015-05-20 05:48:00 +03:00
|
|
|
nsIURI *aReferrer = nullptr);
|
2014-07-18 01:52:25 +04:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult /* NS_NewStreamLoaderPrincipal */
|
|
|
|
NS_NewStreamLoader(nsIStreamLoader **outStream,
|
|
|
|
nsIURI *aUri,
|
|
|
|
nsIStreamLoaderObserver *aObserver,
|
|
|
|
nsIPrincipal *aLoadingPrincipal,
|
2014-07-18 01:52:25 +04:00
|
|
|
nsSecurityFlags aSecurityFlags,
|
|
|
|
nsContentPolicyType aContentPolicyType,
|
2015-05-20 05:48:00 +03:00
|
|
|
nsILoadGroup *aLoadGroup = nullptr,
|
|
|
|
nsIInterfaceRequestor *aCallbacks = nullptr,
|
2014-07-18 01:52:25 +04:00
|
|
|
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
|
2015-05-20 05:48:00 +03:00
|
|
|
nsIURI *aReferrer = nullptr);
|
2002-09-27 08:22:13 +04:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_NewUnicharStreamLoader(nsIUnicharStreamLoader **result,
|
|
|
|
nsIUnicharStreamLoaderObserver *observer);
|
2002-08-28 03:47:25 +04:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_NewSyncStreamListener(nsIStreamListener **result,
|
|
|
|
nsIInputStream **stream);
|
2003-10-08 08:27:13 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implement the nsIChannel::Open(nsIInputStream**) method using the channel's
|
|
|
|
* AsyncOpen method.
|
2003-10-08 08:37:38 +04:00
|
|
|
*
|
|
|
|
* NOTE: Reading from the returned nsIInputStream may spin the current
|
|
|
|
* thread's event queue, which could result in any event being processed.
|
2003-10-08 08:27:13 +04:00
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_ImplementChannelOpen(nsIChannel *channel,
|
|
|
|
nsIInputStream **result);
|
2003-10-08 08:27:13 +04:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_NewRequestObserverProxy(nsIRequestObserver **result,
|
|
|
|
nsIRequestObserver *observer,
|
|
|
|
nsISupports *context);
|
2001-01-24 01:10:34 +03:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_NewSimpleStreamListener(nsIStreamListener **result,
|
|
|
|
nsIOutputStream *sink,
|
|
|
|
nsIRequestObserver *observer = nullptr);
|
2001-01-24 01:10:34 +03:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_CheckPortSafety(int32_t port,
|
|
|
|
const char *scheme,
|
|
|
|
nsIIOService *ioService = nullptr);
|
2001-06-06 04:10:09 +04:00
|
|
|
|
2006-06-24 05:25:17 +04:00
|
|
|
// Determine if this URI is using a safe port.
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_CheckPortSafety(nsIURI *uri);
|
2006-06-24 05:25:17 +04:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_NewProxyInfo(const nsACString &type,
|
|
|
|
const nsACString &host,
|
|
|
|
int32_t port,
|
|
|
|
uint32_t flags,
|
|
|
|
nsIProxyInfo **result);
|
2001-09-13 06:21:05 +04:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_GetFileProtocolHandler(nsIFileProtocolHandler **result,
|
|
|
|
nsIIOService *ioService = nullptr);
|
2002-09-13 23:32:45 +04:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_GetFileFromURLSpec(const nsACString &inURL,
|
|
|
|
nsIFile **result,
|
|
|
|
nsIIOService *ioService = nullptr);
|
2001-12-19 03:55:42 +03:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_GetURLSpecFromFile(nsIFile *file,
|
|
|
|
nsACString &url,
|
|
|
|
nsIIOService *ioService = nullptr);
|
2007-11-23 23:20:41 +03:00
|
|
|
|
2009-10-06 17:43:59 +04:00
|
|
|
/**
|
|
|
|
* Converts the nsIFile to the corresponding URL string.
|
|
|
|
* Should only be called on files which are not directories,
|
|
|
|
* is otherwise identical to NS_GetURLSpecFromFile, but is
|
|
|
|
* usually more efficient.
|
|
|
|
* Warning: this restriction may not be enforced at runtime!
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_GetURLSpecFromActualFile(nsIFile *file,
|
|
|
|
nsACString &url,
|
|
|
|
nsIIOService *ioService = nullptr);
|
2009-10-06 17:43:59 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts the nsIFile to the corresponding URL string.
|
|
|
|
* Should only be called on files which are directories,
|
|
|
|
* is otherwise identical to NS_GetURLSpecFromFile, but is
|
|
|
|
* usually more efficient.
|
|
|
|
* Warning: this restriction may not be enforced at runtime!
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_GetURLSpecFromDir(nsIFile *file,
|
|
|
|
nsACString &url,
|
|
|
|
nsIIOService *ioService = nullptr);
|
2009-10-06 17:43:59 +04:00
|
|
|
|
2007-11-23 23:20:41 +03:00
|
|
|
/**
|
|
|
|
* Obtains the referrer for a given channel. This first tries to obtain the
|
|
|
|
* referrer from the property docshell.internalReferrer, and if that doesn't
|
|
|
|
* work and the channel is an nsIHTTPChannel, we check it's referrer property.
|
|
|
|
*
|
|
|
|
* @returns NS_ERROR_NOT_AVAILABLE if no referrer is available.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_GetReferrerFromChannel(nsIChannel *channel,
|
|
|
|
nsIURI **referrer);
|
|
|
|
|
2015-10-01 21:36:19 +03:00
|
|
|
nsresult NS_ParseRequestContentType(const nsACString &rawContentType,
|
|
|
|
nsCString &contentType,
|
|
|
|
nsCString &contentCharset);
|
|
|
|
|
2015-10-01 19:51:50 +03:00
|
|
|
nsresult NS_ParseResponseContentType(const nsACString &rawContentType,
|
|
|
|
nsCString &contentType,
|
|
|
|
nsCString &contentCharset);
|
2015-05-20 05:48:00 +03:00
|
|
|
|
|
|
|
nsresult NS_ExtractCharsetFromContentType(const nsACString &rawContentType,
|
|
|
|
nsCString &contentCharset,
|
|
|
|
bool *hadCharset,
|
|
|
|
int32_t *charsetStart,
|
|
|
|
int32_t *charsetEnd);
|
|
|
|
|
|
|
|
nsresult NS_NewLocalFileInputStream(nsIInputStream **result,
|
|
|
|
nsIFile *file,
|
|
|
|
int32_t ioFlags = -1,
|
|
|
|
int32_t perm = -1,
|
|
|
|
int32_t behaviorFlags = 0);
|
|
|
|
|
|
|
|
nsresult NS_NewPartialLocalFileInputStream(nsIInputStream **result,
|
|
|
|
nsIFile *file,
|
|
|
|
uint64_t offset,
|
|
|
|
uint64_t length,
|
|
|
|
int32_t ioFlags = -1,
|
|
|
|
int32_t perm = -1,
|
|
|
|
int32_t behaviorFlags = 0);
|
|
|
|
|
|
|
|
nsresult NS_NewLocalFileOutputStream(nsIOutputStream **result,
|
|
|
|
nsIFile *file,
|
|
|
|
int32_t ioFlags = -1,
|
|
|
|
int32_t perm = -1,
|
|
|
|
int32_t behaviorFlags = 0);
|
2003-01-18 05:15:14 +03:00
|
|
|
|
2013-12-02 21:51:25 +04:00
|
|
|
// returns a file output stream which can be QI'ed to nsISafeOutputStream.
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_NewAtomicFileOutputStream(nsIOutputStream **result,
|
|
|
|
nsIFile *file,
|
|
|
|
int32_t ioFlags = -1,
|
|
|
|
int32_t perm = -1,
|
|
|
|
int32_t behaviorFlags = 0);
|
2013-12-02 21:51:25 +04:00
|
|
|
|
2004-07-20 02:00:03 +04:00
|
|
|
// returns a file output stream which can be QI'ed to nsISafeOutputStream.
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_NewSafeLocalFileOutputStream(nsIOutputStream **result,
|
|
|
|
nsIFile *file,
|
|
|
|
int32_t ioFlags = -1,
|
|
|
|
int32_t perm = -1,
|
|
|
|
int32_t behaviorFlags = 0);
|
|
|
|
|
|
|
|
nsresult NS_NewLocalFileStream(nsIFileStream **result,
|
|
|
|
nsIFile *file,
|
|
|
|
int32_t ioFlags = -1,
|
|
|
|
int32_t perm = -1,
|
|
|
|
int32_t behaviorFlags = 0);
|
2004-07-07 00:35:40 +04:00
|
|
|
|
2003-06-19 03:07:09 +04:00
|
|
|
// returns the input end of a pipe. the output end of the pipe
|
|
|
|
// is attached to the original stream. data from the original
|
|
|
|
// stream is read into the pipe on a background thread.
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_BackgroundInputStream(nsIInputStream **result,
|
|
|
|
nsIInputStream *stream,
|
|
|
|
uint32_t segmentSize = 0,
|
|
|
|
uint32_t segmentCount = 0);
|
2003-02-25 16:57:09 +03:00
|
|
|
|
2003-06-19 03:07:09 +04:00
|
|
|
// returns the output end of a pipe. the input end of the pipe
|
|
|
|
// is attached to the original stream. data written to the pipe
|
|
|
|
// is copied to the original stream on a background thread.
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_BackgroundOutputStream(nsIOutputStream **result,
|
|
|
|
nsIOutputStream *stream,
|
|
|
|
uint32_t segmentSize = 0,
|
|
|
|
uint32_t segmentCount = 0);
|
2003-02-25 16:57:09 +03:00
|
|
|
|
2016-04-27 07:16:50 +03:00
|
|
|
MOZ_MUST_USE nsresult
|
2005-11-12 21:17:19 +03:00
|
|
|
NS_NewBufferedInputStream(nsIInputStream **result,
|
|
|
|
nsIInputStream *str,
|
2015-05-20 05:48:00 +03:00
|
|
|
uint32_t bufferSize);
|
2003-01-18 05:15:14 +03:00
|
|
|
|
2004-07-20 02:00:03 +04:00
|
|
|
// note: the resulting stream can be QI'ed to nsISafeOutputStream iff the
|
|
|
|
// provided stream supports it.
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_NewBufferedOutputStream(nsIOutputStream **result,
|
|
|
|
nsIOutputStream *str,
|
|
|
|
uint32_t bufferSize);
|
2003-01-18 05:15:14 +03:00
|
|
|
|
2008-01-04 20:55:02 +03:00
|
|
|
/**
|
2015-12-21 19:51:03 +03:00
|
|
|
* Attempts to buffer a given stream. If this fails, it returns the
|
|
|
|
* passed-in stream.
|
2008-01-04 20:55:02 +03:00
|
|
|
*
|
|
|
|
* @param aOutputStream
|
|
|
|
* The output stream we want to buffer. This cannot be null.
|
|
|
|
* @param aBufferSize
|
|
|
|
* The size of the buffer for the buffered output stream.
|
|
|
|
* @returns an nsIOutputStream that is buffered with the specified buffer size,
|
|
|
|
* or is aOutputStream if creating the new buffered stream failed.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
already_AddRefed<nsIOutputStream>
|
2008-01-04 20:55:02 +03:00
|
|
|
NS_BufferOutputStream(nsIOutputStream *aOutputStream,
|
2015-05-20 05:48:00 +03:00
|
|
|
uint32_t aBufferSize);
|
2015-12-21 19:51:03 +03:00
|
|
|
already_AddRefed<nsIInputStream>
|
|
|
|
NS_BufferInputStream(nsIInputStream *aInputStream,
|
|
|
|
uint32_t aBufferSize);
|
2008-01-04 20:55:02 +03:00
|
|
|
|
2003-06-19 03:07:09 +04:00
|
|
|
// returns an input stream compatible with nsIUploadChannel::SetUploadStream()
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_NewPostDataStream(nsIInputStream **result,
|
|
|
|
bool isFile,
|
|
|
|
const nsACString &data);
|
2003-01-18 05:15:14 +03:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_ReadInputStreamToBuffer(nsIInputStream *aInputStream,
|
|
|
|
void **aDest,
|
|
|
|
uint32_t aCount);
|
2010-05-31 02:30:28 +04:00
|
|
|
|
2012-05-15 01:35:49 +04:00
|
|
|
// external code can't see fallible_t
|
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_ReadInputStreamToString(nsIInputStream *aInputStream,
|
|
|
|
nsACString &aDest,
|
|
|
|
uint32_t aCount);
|
2011-06-08 22:11:41 +04:00
|
|
|
|
2012-05-15 01:35:49 +04:00
|
|
|
#endif
|
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult
|
|
|
|
NS_LoadPersistentPropertiesFromURISpec(nsIPersistentProperties **outResult,
|
2015-11-09 05:54:38 +03:00
|
|
|
const nsACString &aSpec);
|
2003-07-12 01:31:54 +04:00
|
|
|
|
2004-11-15 23:16:52 +03:00
|
|
|
/**
|
|
|
|
* NS_QueryNotificationCallbacks implements the canonical algorithm for
|
|
|
|
* querying interfaces from a channel's notification callbacks. It first
|
|
|
|
* searches the channel's notificationCallbacks attribute, and if the interface
|
|
|
|
* is not found there, then it inspects the notificationCallbacks attribute of
|
|
|
|
* the channel's loadGroup.
|
2012-08-07 08:47:48 +04:00
|
|
|
*
|
|
|
|
* Note: templatized only because nsIWebSocketChannel is currently not an
|
|
|
|
* nsIChannel.
|
2004-11-15 23:16:52 +03:00
|
|
|
*/
|
2012-08-07 08:47:48 +04:00
|
|
|
template <class T> inline void
|
|
|
|
NS_QueryNotificationCallbacks(T *channel,
|
2005-11-12 21:17:19 +03:00
|
|
|
const nsIID &iid,
|
|
|
|
void **result)
|
2004-11-15 23:16:52 +03:00
|
|
|
{
|
2005-11-12 21:17:19 +03:00
|
|
|
NS_PRECONDITION(channel, "null channel");
|
2012-07-30 18:20:58 +04:00
|
|
|
*result = nullptr;
|
2004-11-15 23:16:52 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIInterfaceRequestor> cbs;
|
2005-11-12 21:17:19 +03:00
|
|
|
channel->GetNotificationCallbacks(getter_AddRefs(cbs));
|
2004-11-15 23:16:52 +03:00
|
|
|
if (cbs)
|
2005-11-12 21:17:19 +03:00
|
|
|
cbs->GetInterface(iid, result);
|
|
|
|
if (!*result) {
|
2004-11-15 23:16:52 +03:00
|
|
|
// try load group's notification callbacks...
|
|
|
|
nsCOMPtr<nsILoadGroup> loadGroup;
|
2005-11-12 21:17:19 +03:00
|
|
|
channel->GetLoadGroup(getter_AddRefs(loadGroup));
|
2004-11-15 23:16:52 +03:00
|
|
|
if (loadGroup) {
|
|
|
|
loadGroup->GetNotificationCallbacks(getter_AddRefs(cbs));
|
|
|
|
if (cbs)
|
2005-11-12 21:17:19 +03:00
|
|
|
cbs->GetInterface(iid, result);
|
2004-11-15 23:16:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-07 08:47:48 +04:00
|
|
|
// template helper:
|
|
|
|
// Note: "class C" templatized only because nsIWebSocketChannel is currently not
|
|
|
|
// an nsIChannel.
|
|
|
|
|
|
|
|
template <class C, class T> inline void
|
|
|
|
NS_QueryNotificationCallbacks(C *channel,
|
2005-11-12 21:17:19 +03:00
|
|
|
nsCOMPtr<T> &result)
|
2004-11-15 23:16:52 +03:00
|
|
|
{
|
2005-11-12 21:17:19 +03:00
|
|
|
NS_QueryNotificationCallbacks(channel, NS_GET_TEMPLATE_IID(T),
|
|
|
|
getter_AddRefs(result));
|
2004-11-15 23:16:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Alternate form of NS_QueryNotificationCallbacks designed for use by
|
|
|
|
* nsIChannel implementations.
|
|
|
|
*/
|
|
|
|
inline void
|
2005-11-12 21:17:19 +03:00
|
|
|
NS_QueryNotificationCallbacks(nsIInterfaceRequestor *callbacks,
|
|
|
|
nsILoadGroup *loadGroup,
|
|
|
|
const nsIID &iid,
|
|
|
|
void **result)
|
2004-11-15 23:16:52 +03:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
*result = nullptr;
|
2004-11-15 23:16:52 +03:00
|
|
|
|
2005-11-12 21:17:19 +03:00
|
|
|
if (callbacks)
|
|
|
|
callbacks->GetInterface(iid, result);
|
|
|
|
if (!*result) {
|
2004-11-15 23:16:52 +03:00
|
|
|
// try load group's notification callbacks...
|
2005-11-12 21:17:19 +03:00
|
|
|
if (loadGroup) {
|
2004-11-15 23:16:52 +03:00
|
|
|
nsCOMPtr<nsIInterfaceRequestor> cbs;
|
2005-11-12 21:17:19 +03:00
|
|
|
loadGroup->GetNotificationCallbacks(getter_AddRefs(cbs));
|
2004-11-15 23:16:52 +03:00
|
|
|
if (cbs)
|
2005-11-12 21:17:19 +03:00
|
|
|
cbs->GetInterface(iid, result);
|
2004-11-15 23:16:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-23 02:35:33 +04:00
|
|
|
/**
|
|
|
|
* Returns true if channel is using Private Browsing, or false if not.
|
2012-07-23 22:12:03 +04:00
|
|
|
* Returns false if channel's callbacks don't implement nsILoadContext.
|
2012-07-23 02:35:33 +04:00
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
bool NS_UsePrivateBrowsing(nsIChannel *channel);
|
2012-07-23 22:12:03 +04:00
|
|
|
|
2015-09-03 05:46:03 +03:00
|
|
|
/**
|
2015-11-03 04:50:54 +03:00
|
|
|
* Extract the NeckoOriginAttributes from the channel's triggering principal.
|
2015-09-03 05:46:03 +03:00
|
|
|
*/
|
|
|
|
bool NS_GetOriginAttributes(nsIChannel *aChannel,
|
2015-11-03 04:50:54 +03:00
|
|
|
mozilla::NeckoOriginAttributes &aAttributes);
|
2015-09-03 05:46:03 +03:00
|
|
|
|
2015-12-07 02:33:15 +03:00
|
|
|
/**
|
|
|
|
* Returns true if the channel has visited any cross-origin URLs on any
|
|
|
|
* URLs that it was redirected through.
|
|
|
|
*/
|
|
|
|
bool NS_HasBeenCrossOrigin(nsIChannel* aChannel, bool aReport = false);
|
|
|
|
|
2012-09-18 20:04:04 +04:00
|
|
|
// Constants duplicated from nsIScriptSecurityManager so we avoid having necko
|
|
|
|
// know about script security manager.
|
|
|
|
#define NECKO_NO_APP_ID 0
|
2012-10-02 08:44:29 +04:00
|
|
|
#define NECKO_UNKNOWN_APP_ID UINT32_MAX
|
2013-08-19 23:31:24 +04:00
|
|
|
// special app id reserved for separating the safebrowsing cookie
|
|
|
|
#define NECKO_SAFEBROWSING_APP_ID UINT32_MAX - 1
|
2012-09-18 20:04:04 +04:00
|
|
|
|
2012-10-18 09:00:16 +04:00
|
|
|
/**
|
|
|
|
* Determines whether appcache should be checked for a given URI.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
bool NS_ShouldCheckAppCache(nsIURI *aURI, bool usePrivateBrowsing);
|
2012-10-18 09:00:16 +04:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
bool NS_ShouldCheckAppCache(nsIPrincipal *aPrincipal, bool usePrivateBrowsing);
|
2012-10-18 09:00:16 +04:00
|
|
|
|
2006-08-27 01:42:54 +04:00
|
|
|
/**
|
|
|
|
* Wraps an nsIAuthPrompt so that it can be used as an nsIAuthPrompt2. This
|
|
|
|
* method is provided mainly for use by other methods in this file.
|
|
|
|
*
|
|
|
|
* *aAuthPrompt2 should be set to null before calling this function.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
void NS_WrapAuthPrompt(nsIAuthPrompt *aAuthPrompt,
|
|
|
|
nsIAuthPrompt2 **aAuthPrompt2);
|
2006-08-27 01:42:54 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets an auth prompt from an interface requestor. This takes care of wrapping
|
|
|
|
* an nsIAuthPrompt so that it can be used as an nsIAuthPrompt2.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
void NS_QueryAuthPrompt2(nsIInterfaceRequestor *aCallbacks,
|
|
|
|
nsIAuthPrompt2 **aAuthPrompt);
|
2006-08-27 01:42:54 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets an nsIAuthPrompt2 from a channel. Use this instead of
|
|
|
|
* NS_QueryNotificationCallbacks for better backwards compatibility.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
void NS_QueryAuthPrompt2(nsIChannel *aChannel,
|
|
|
|
nsIAuthPrompt2 **aAuthPrompt);
|
2006-08-27 01:42:54 +04:00
|
|
|
|
2004-11-15 23:16:52 +03:00
|
|
|
/* template helper */
|
|
|
|
template <class T> inline void
|
2005-11-12 21:17:19 +03:00
|
|
|
NS_QueryNotificationCallbacks(nsIInterfaceRequestor *callbacks,
|
|
|
|
nsILoadGroup *loadGroup,
|
|
|
|
nsCOMPtr<T> &result)
|
2004-11-15 23:16:52 +03:00
|
|
|
{
|
2005-11-12 21:17:19 +03:00
|
|
|
NS_QueryNotificationCallbacks(callbacks, loadGroup,
|
2005-11-11 17:36:26 +03:00
|
|
|
NS_GET_TEMPLATE_IID(T),
|
2005-11-12 21:17:19 +03:00
|
|
|
getter_AddRefs(result));
|
2004-11-15 23:16:52 +03:00
|
|
|
}
|
|
|
|
|
2006-04-24 06:54:26 +04:00
|
|
|
/* template helper */
|
|
|
|
template <class T> inline void
|
|
|
|
NS_QueryNotificationCallbacks(const nsCOMPtr<nsIInterfaceRequestor> &aCallbacks,
|
|
|
|
const nsCOMPtr<nsILoadGroup> &aLoadGroup,
|
|
|
|
nsCOMPtr<T> &aResult)
|
|
|
|
{
|
|
|
|
NS_QueryNotificationCallbacks(aCallbacks.get(), aLoadGroup.get(), aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* template helper */
|
|
|
|
template <class T> inline void
|
|
|
|
NS_QueryNotificationCallbacks(const nsCOMPtr<nsIChannel> &aChannel,
|
|
|
|
nsCOMPtr<T> &aResult)
|
|
|
|
{
|
|
|
|
NS_QueryNotificationCallbacks(aChannel.get(), aResult);
|
|
|
|
}
|
|
|
|
|
2004-11-15 23:16:52 +03:00
|
|
|
/**
|
|
|
|
* This function returns a nsIInterfaceRequestor instance that returns the
|
|
|
|
* same result as NS_QueryNotificationCallbacks when queried. It is useful
|
|
|
|
* as the value for nsISocketTransport::securityCallbacks.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult
|
2005-11-12 21:17:19 +03:00
|
|
|
NS_NewNotificationCallbacksAggregation(nsIInterfaceRequestor *callbacks,
|
|
|
|
nsILoadGroup *loadGroup,
|
2012-11-14 20:00:44 +04:00
|
|
|
nsIEventTarget *target,
|
2015-05-20 05:48:00 +03:00
|
|
|
nsIInterfaceRequestor **result);
|
2012-11-14 20:00:44 +04:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult
|
2012-11-14 20:00:44 +04:00
|
|
|
NS_NewNotificationCallbacksAggregation(nsIInterfaceRequestor *callbacks,
|
|
|
|
nsILoadGroup *loadGroup,
|
2015-05-20 05:48:00 +03:00
|
|
|
nsIInterfaceRequestor **result);
|
2004-11-15 23:16:52 +03:00
|
|
|
|
2006-03-03 19:27:35 +03:00
|
|
|
/**
|
|
|
|
* Helper function for testing online/offline state of the browser.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
bool NS_IsOffline();
|
2006-03-03 19:27:35 +03:00
|
|
|
|
2006-05-02 22:54:19 +04:00
|
|
|
/**
|
|
|
|
* Helper functions for implementing nsINestedURI::innermostURI.
|
|
|
|
*
|
|
|
|
* Note that NS_DoImplGetInnermostURI is "private" -- call
|
|
|
|
* NS_ImplGetInnermostURI instead.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_DoImplGetInnermostURI(nsINestedURI *nestedURI, nsIURI **result);
|
2006-05-02 22:54:19 +04:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_ImplGetInnermostURI(nsINestedURI *nestedURI, nsIURI **result);
|
2006-05-02 22:54:19 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function that ensures that |result| is a URI that's safe to
|
|
|
|
* return. If |uri| is immutable, just returns it, otherwise returns
|
|
|
|
* a clone. |uri| must not be null.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_EnsureSafeToReturn(nsIURI *uri, nsIURI **result);
|
2006-05-02 22:54:19 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function that tries to set the argument URI to be immutable
|
2015-05-20 05:48:00 +03:00
|
|
|
*/
|
|
|
|
void NS_TryToSetImmutable(nsIURI *uri);
|
2006-05-02 22:54:19 +04:00
|
|
|
|
2006-05-31 21:57:14 +04:00
|
|
|
/**
|
|
|
|
* Helper function for calling ToImmutableURI. If all else fails, returns
|
|
|
|
* the input URI. The optional second arg indicates whether we had to fall
|
|
|
|
* back to the input URI. Passing in a null URI is ok.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
already_AddRefed<nsIURI> NS_TryToMakeImmutable(nsIURI *uri,
|
|
|
|
nsresult *outRv = nullptr);
|
2006-05-31 21:57:14 +04:00
|
|
|
|
2006-05-02 22:54:19 +04:00
|
|
|
/**
|
|
|
|
* Helper function for testing whether the given URI, or any of its
|
|
|
|
* inner URIs, has all the given protocol flags.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_URIChainHasFlags(nsIURI *uri,
|
|
|
|
uint32_t flags,
|
|
|
|
bool *result);
|
2006-05-02 22:54:19 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function for getting the innermost URI for a given URI. The return
|
|
|
|
* value could be just the object passed in if it's not a nested URI.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
already_AddRefed<nsIURI> NS_GetInnermostURI(nsIURI *aURI);
|
2006-05-02 22:54:19 +04:00
|
|
|
|
2007-10-24 01:56:41 +04:00
|
|
|
/**
|
|
|
|
* Get the "final" URI for a channel. This is either the same as GetURI or
|
|
|
|
* GetOriginalURI, depending on whether this channel has
|
|
|
|
* nsIChanel::LOAD_REPLACE set. For channels without that flag set, the final
|
|
|
|
* URI is the original URI, while for ones with the flag the final URI is the
|
|
|
|
* channel URI.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_GetFinalChannelURI(nsIChannel *channel, nsIURI **uri);
|
2007-10-24 01:56:41 +04:00
|
|
|
|
2008-10-08 17:16:27 +04:00
|
|
|
// NS_SecurityHashURI must return the same hash value for any two URIs that
|
|
|
|
// compare equal according to NS_SecurityCompareURIs. Unfortunately, in the
|
|
|
|
// case of files, it's not clear we can do anything better than returning
|
|
|
|
// the schemeHash, so hashing files degenerates to storing them in a list.
|
2015-05-20 05:48:00 +03:00
|
|
|
uint32_t NS_SecurityHashURI(nsIURI *aURI);
|
2008-08-28 05:15:32 +04:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
bool NS_SecurityCompareURIs(nsIURI *aSourceURI,
|
|
|
|
nsIURI *aTargetURI,
|
|
|
|
bool aStrictFileOriginPolicy);
|
2008-08-28 05:15:32 +04:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
bool NS_URIIsLocalFile(nsIURI *aURI);
|
2013-06-01 01:33:51 +04:00
|
|
|
|
|
|
|
// When strict file origin policy is enabled, SecurityCompareURIs will fail for
|
|
|
|
// file URIs that do not point to the same local file. This call provides an
|
|
|
|
// alternate file-specific origin check that allows target files that are
|
|
|
|
// contained in the same directory as the source.
|
|
|
|
//
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Same-origin_policy_for_file:_URIs
|
2015-05-20 05:48:00 +03:00
|
|
|
bool NS_RelaxStrictFileOriginPolicy(nsIURI *aTargetURI,
|
|
|
|
nsIURI *aSourceURI,
|
|
|
|
bool aAllowDirectoryTarget = false);
|
2009-01-22 01:50:28 +03:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
bool NS_IsInternalSameURIRedirect(nsIChannel *aOldChannel,
|
|
|
|
nsIChannel *aNewChannel,
|
|
|
|
uint32_t aFlags);
|
2015-02-10 16:00:00 +03:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
bool NS_IsHSTSUpgradeRedirect(nsIChannel *aOldChannel,
|
|
|
|
nsIChannel *aNewChannel,
|
|
|
|
uint32_t aFlags);
|
2010-11-24 01:56:06 +03:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_LinkRedirectChannels(uint32_t channelId,
|
|
|
|
nsIParentChannel *parentChannel,
|
|
|
|
nsIChannel **_result);
|
2010-11-24 01:56:06 +03:00
|
|
|
|
2010-11-19 23:58:59 +03:00
|
|
|
/**
|
|
|
|
* Helper function to create a random URL string that's properly formed
|
|
|
|
* but guaranteed to be invalid.
|
2015-05-20 05:48:00 +03:00
|
|
|
*/
|
|
|
|
nsresult NS_MakeRandomInvalidURLString(nsCString &result);
|
2010-11-19 23:58:59 +03:00
|
|
|
|
2016-06-28 20:03:56 +03:00
|
|
|
/**
|
|
|
|
* Helper function which checks whether the channel can be
|
|
|
|
* openend using Open2() or has to fall back to opening
|
|
|
|
* the channel using Open().
|
|
|
|
*/
|
|
|
|
nsresult NS_MaybeOpenChannelUsingOpen2(nsIChannel* aChannel,
|
|
|
|
nsIInputStream **aStream);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function which checks whether the channel can be
|
|
|
|
* openend using AsyncOpen2() or has to fall back to opening
|
|
|
|
* the channel using AsyncOpen().
|
|
|
|
*/
|
|
|
|
nsresult NS_MaybeOpenChannelUsingAsyncOpen2(nsIChannel* aChannel,
|
|
|
|
nsIStreamListener *aListener);
|
|
|
|
|
2010-11-19 23:58:59 +03:00
|
|
|
/**
|
|
|
|
* Helper function to determine whether urlString is Java-compatible --
|
|
|
|
* whether it can be passed to the Java URL(String) constructor without the
|
|
|
|
* latter throwing a MalformedURLException, or without Java otherwise
|
2011-01-11 19:00:36 +03:00
|
|
|
* mishandling it. This function (in effect) implements a scheme whitelist
|
|
|
|
* for Java.
|
2015-05-20 05:48:00 +03:00
|
|
|
*/
|
|
|
|
nsresult NS_CheckIsJavaCompatibleURLString(nsCString& urlString, bool *result);
|
2010-11-19 23:58:59 +03:00
|
|
|
|
2011-09-10 02:41:04 +04:00
|
|
|
/** Given the first (disposition) token from a Content-Disposition header,
|
|
|
|
* tell whether it indicates the content is inline or attachment
|
|
|
|
* @param aDispToken the disposition token from the content-disposition header
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
uint32_t NS_GetContentDispositionFromToken(const nsAString &aDispToken);
|
2011-09-10 02:41:04 +04:00
|
|
|
|
|
|
|
/** Determine the disposition (inline/attachment) of the content based on the
|
|
|
|
* Content-Disposition header
|
|
|
|
* @param aHeader the content-disposition header (full value)
|
|
|
|
* @param aChan the channel the header came from
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
uint32_t NS_GetContentDispositionFromHeader(const nsACString &aHeader,
|
|
|
|
nsIChannel *aChan = nullptr);
|
2011-09-10 02:41:04 +04:00
|
|
|
|
|
|
|
/** Extracts the filename out of a content-disposition header
|
|
|
|
* @param aFilename [out] The filename. Can be empty on error.
|
|
|
|
* @param aDisposition Value of a Content-Disposition header
|
|
|
|
* @param aURI Optional. Will be used to get a fallback charset for the
|
|
|
|
* filename, if it is QI'able to nsIURL
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_GetFilenameFromDisposition(nsAString &aFilename,
|
|
|
|
const nsACString &aDisposition,
|
|
|
|
nsIURI *aURI = nullptr);
|
2011-09-10 02:41:04 +04:00
|
|
|
|
2010-11-23 15:01:30 +03:00
|
|
|
/**
|
|
|
|
* Make sure Personal Security Manager is initialized
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
void net_EnsurePSMInit();
|
2010-11-23 15:01:30 +03:00
|
|
|
|
2011-09-21 01:00:41 +04:00
|
|
|
/**
|
|
|
|
* Test whether a URI is "about:blank". |uri| must not be null
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
bool NS_IsAboutBlank(nsIURI *uri);
|
2011-09-21 01:00:41 +04:00
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
nsresult NS_GenerateHostPort(const nsCString &host, int32_t port,
|
|
|
|
nsACString &hostLine);
|
2011-12-23 06:21:20 +04:00
|
|
|
|
2012-11-21 04:19:53 +04:00
|
|
|
/**
|
|
|
|
* Sniff the content type for a given request or a given buffer.
|
|
|
|
*
|
|
|
|
* aSnifferType can be either NS_CONTENT_SNIFFER_CATEGORY or
|
|
|
|
* NS_DATA_SNIFFER_CATEGORY. The function returns the sniffed content type
|
|
|
|
* in the aSniffedType argument. This argument will not be modified if the
|
|
|
|
* content type could not be sniffed.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
void NS_SniffContent(const char *aSnifferType, nsIRequest *aRequest,
|
|
|
|
const uint8_t *aData, uint32_t aLength,
|
|
|
|
nsACString &aSniffedType);
|
2012-11-21 04:19:53 +04:00
|
|
|
|
2013-09-10 21:40:35 +04:00
|
|
|
/**
|
|
|
|
* Whether the channel was created to load a srcdoc document.
|
2015-05-20 05:48:00 +03:00
|
|
|
* Note that view-source:about:srcdoc is classified as a srcdoc document by
|
2013-09-10 21:40:35 +04:00
|
|
|
* this function, which may not be applicable everywhere.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
bool NS_IsSrcdocChannel(nsIChannel *aChannel);
|
2013-09-10 21:40:35 +04:00
|
|
|
|
2014-07-24 20:38:55 +04:00
|
|
|
/**
|
|
|
|
* Return true if the given string is a reasonable HTTP header value given the
|
|
|
|
* definition in RFC 2616 section 4.2. Currently we don't pay the cost to do
|
|
|
|
* full, sctrict validation here since it would require fulling parsing the
|
|
|
|
* value.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
bool NS_IsReasonableHTTPHeaderValue(const nsACString &aValue);
|
2014-07-24 20:38:55 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the given string is a valid HTTP token per RFC 2616 section
|
|
|
|
* 2.2.
|
|
|
|
*/
|
2015-05-20 05:48:00 +03:00
|
|
|
bool NS_IsValidHTTPToken(const nsACString &aToken);
|
2014-07-24 20:38:55 +04:00
|
|
|
|
2015-11-02 19:27:00 +03:00
|
|
|
/**
|
|
|
|
* Return true if the given request must be upgraded to HTTPS.
|
|
|
|
*/
|
|
|
|
nsresult NS_ShouldSecureUpgrade(nsIURI* aURI,
|
|
|
|
nsILoadInfo* aLoadInfo,
|
|
|
|
nsIPrincipal* aChannelResultPrincipal,
|
|
|
|
bool aPrivateBrowsing,
|
|
|
|
bool aAllowSTS,
|
|
|
|
bool& aShouldUpgrade);
|
|
|
|
|
2016-03-11 02:23:45 +03:00
|
|
|
/**
|
|
|
|
* Returns an https URI for channels that need to go through secure upgrades.
|
|
|
|
*/
|
|
|
|
nsresult NS_GetSecureUpgradedURI(nsIURI* aURI, nsIURI** aUpgradedURI);
|
|
|
|
|
2016-04-13 11:23:26 +03:00
|
|
|
nsresult NS_CompareLoadInfoAndLoadContext(nsIChannel *aChannel);
|
2016-03-11 02:23:45 +03:00
|
|
|
|
2015-01-08 22:48:52 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
|
|
|
const static uint64_t kJS_MAX_SAFE_UINTEGER = +9007199254740991ULL;
|
|
|
|
const static int64_t kJS_MIN_SAFE_INTEGER = -9007199254740991LL;
|
|
|
|
const static int64_t kJS_MAX_SAFE_INTEGER = +9007199254740991LL;
|
|
|
|
|
|
|
|
// Make sure a 64bit value can be captured by JS MAX_SAFE_INTEGER
|
2015-05-20 05:48:00 +03:00
|
|
|
bool InScriptableRange(int64_t val);
|
2015-01-08 22:48:52 +03:00
|
|
|
|
|
|
|
// Make sure a 64bit value can be captured by JS MAX_SAFE_INTEGER
|
2015-05-20 05:48:00 +03:00
|
|
|
bool InScriptableRange(uint64_t val);
|
2015-01-08 22:48:52 +03:00
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace net
|
2015-01-08 22:48:52 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-05-20 05:48:00 +03:00
|
|
|
// Include some function bodies for callers with external linkage
|
|
|
|
#ifndef MOZILLA_INTERNAL_API
|
2016-04-27 07:20:31 +03:00
|
|
|
#include "nsNetUtilInlines.h"
|
2015-05-20 05:48:00 +03:00
|
|
|
#endif
|
|
|
|
|
2003-06-19 03:07:09 +04:00
|
|
|
#endif // !nsNetUtil_h__
|