2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-09-24 09:03:20 +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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_InternalRequest_h
|
|
|
|
#define mozilla_dom_InternalRequest_h
|
|
|
|
|
2014-10-02 21:59:20 +04:00
|
|
|
#include "mozilla/dom/HeadersBinding.h"
|
|
|
|
#include "mozilla/dom/InternalHeaders.h"
|
2014-09-24 09:03:20 +04:00
|
|
|
#include "mozilla/dom/RequestBinding.h"
|
2015-10-22 21:07:32 +03:00
|
|
|
#include "mozilla/LoadTainting.h"
|
2019-08-15 20:26:15 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2014-09-24 09:03:20 +04:00
|
|
|
|
|
|
|
#include "nsIInputStream.h"
|
|
|
|
#include "nsISupportsImpl.h"
|
2014-12-23 18:56:19 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
# include "nsIURLParser.h"
|
|
|
|
# include "nsNetCID.h"
|
|
|
|
# include "nsServiceManagerUtils.h"
|
|
|
|
#endif
|
2014-09-24 09:03:20 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2016-10-26 10:07:25 +03:00
|
|
|
|
|
|
|
namespace ipc {
|
|
|
|
class PrincipalInfo;
|
2019-08-15 20:26:15 +03:00
|
|
|
class AutoIPCStream;
|
2016-10-26 10:07:25 +03:00
|
|
|
} // namespace ipc
|
|
|
|
|
2014-09-24 09:03:20 +04:00
|
|
|
namespace dom {
|
|
|
|
|
2015-03-25 23:38:42 +03:00
|
|
|
/*
|
2018-03-09 17:11:27 +03:00
|
|
|
* The mapping of RequestDestination and nsContentPolicyType is currently as the
|
2015-03-25 23:38:42 +03:00
|
|
|
* following. Note that this mapping is not perfect yet (see the TODO comments
|
2015-06-15 23:12:45 +03:00
|
|
|
* below for examples).
|
2015-03-25 23:38:42 +03:00
|
|
|
*
|
2018-03-09 17:11:27 +03:00
|
|
|
* RequestDestination| nsContentPolicyType
|
2015-03-25 23:38:42 +03:00
|
|
|
* ------------------+--------------------
|
2015-06-15 23:45:27 +03:00
|
|
|
* audio | TYPE_INTERNAL_AUDIO
|
2020-03-17 14:29:33 +03:00
|
|
|
* audioworklet | TYPE_INTERNAL_AUDIOWORKLET
|
2018-03-09 17:11:27 +03:00
|
|
|
* document | TYPE_DOCUMENT, TYPE_INTERNAL_IFRAME, TYPE_SUBDOCUMENT
|
2015-07-18 18:51:00 +03:00
|
|
|
* embed | TYPE_INTERNAL_EMBED
|
2015-03-25 23:38:42 +03:00
|
|
|
* font | TYPE_FONT
|
2018-03-09 17:11:27 +03:00
|
|
|
* image | TYPE_INTERNAL_IMAGE, TYPE_INTERNAL_IMAGE_PRELOAD,
|
|
|
|
* | TYPE_IMAGE, TYPE_INTERNAL_IMAGE_FAVICON, TYPE_IMAGESET
|
2015-06-02 22:42:19 +03:00
|
|
|
* manifest | TYPE_WEB_MANIFEST
|
2018-03-09 17:11:27 +03:00
|
|
|
* object | TYPE_INTERNAL_OBJECT, TYPE_OBJECT
|
2020-03-17 14:29:33 +03:00
|
|
|
* "paintworklet" | TYPE_INTERNAL_PAINTWORKLET
|
2018-03-09 17:11:27 +03:00
|
|
|
* report" | TODO
|
2018-11-27 13:08:58 +03:00
|
|
|
* script | TYPE_INTERNAL_SCRIPT, TYPE_INTERNAL_SCRIPT_PRELOAD,
|
2019-02-12 16:16:32 +03:00
|
|
|
* | TYPE_INTERNAL_MODULE, TYPE_INTERNAL_MODULE_PRELOAD,
|
2018-11-27 13:08:58 +03:00
|
|
|
* | TYPE_SCRIPT,
|
|
|
|
* | TYPE_INTERNAL_SERVICE_WORKER,
|
|
|
|
* | TYPE_INTERNAL_WORKER_IMPORT_SCRIPTS
|
2015-06-17 04:21:08 +03:00
|
|
|
* sharedworker | TYPE_INTERNAL_SHARED_WORKER
|
2018-11-27 13:08:58 +03:00
|
|
|
* serviceworker | The spec lists this as a valid value for the enum,
|
|
|
|
* | however it is impossible to observe a request with this
|
|
|
|
* | destination value.
|
|
|
|
* style | TYPE_INTERNAL_STYLESHEET,
|
|
|
|
* | TYPE_INTERNAL_STYLESHEET_PRELOAD,
|
2018-03-09 17:11:27 +03:00
|
|
|
* | TYPE_STYLESHEET
|
2015-06-15 23:45:27 +03:00
|
|
|
* track | TYPE_INTERNAL_TRACK
|
|
|
|
* video | TYPE_INTERNAL_VIDEO
|
2015-06-17 04:21:08 +03:00
|
|
|
* worker | TYPE_INTERNAL_WORKER
|
2015-03-25 23:38:42 +03:00
|
|
|
* xslt | TYPE_XSLT
|
2018-03-09 17:11:27 +03:00
|
|
|
* _empty | Default for everything else.
|
2015-03-25 23:38:42 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-08-15 20:26:15 +03:00
|
|
|
class IPCInternalRequest;
|
2014-09-24 09:03:20 +04:00
|
|
|
class Request;
|
|
|
|
|
2014-12-23 18:56:19 +03:00
|
|
|
#define kFETCH_CLIENT_REFERRER_STR "about:client"
|
2015-03-21 19:28:04 +03:00
|
|
|
class InternalRequest final {
|
2014-09-24 09:03:20 +04:00
|
|
|
friend class Request;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-09-24 09:03:20 +04:00
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(InternalRequest)
|
2016-11-07 05:16:34 +03:00
|
|
|
InternalRequest(const nsACString& aURL, const nsACString& aFragment);
|
2016-01-14 02:14:38 +03:00
|
|
|
InternalRequest(const nsACString& aURL, const nsACString& aFragment,
|
|
|
|
const nsACString& aMethod,
|
|
|
|
already_AddRefed<InternalHeaders> aHeaders,
|
2016-02-29 02:05:40 +03:00
|
|
|
RequestCache aCacheMode, RequestMode aMode,
|
2016-01-14 02:14:38 +03:00
|
|
|
RequestRedirect aRequestRedirect,
|
|
|
|
RequestCredentials aRequestCredentials,
|
2016-02-27 01:36:45 +03:00
|
|
|
const nsAString& aReferrer, ReferrerPolicy aReferrerPolicy,
|
2016-09-07 05:20:23 +03:00
|
|
|
nsContentPolicyType aContentPolicyType,
|
2016-10-26 10:07:25 +03:00
|
|
|
const nsAString& aIntegrity);
|
2014-09-24 09:03:20 +04:00
|
|
|
|
2019-08-15 20:26:15 +03:00
|
|
|
explicit InternalRequest(const IPCInternalRequest& aIPCRequest);
|
|
|
|
|
|
|
|
template <typename M>
|
|
|
|
void ToIPC(IPCInternalRequest* aIPCRequest, M* aManager,
|
|
|
|
UniquePtr<mozilla::ipc::AutoIPCStream>& aAutoStream);
|
|
|
|
|
2015-02-20 04:24:24 +03:00
|
|
|
already_AddRefed<InternalRequest> Clone();
|
2014-09-24 09:03:20 +04:00
|
|
|
|
|
|
|
void GetMethod(nsCString& aMethod) const { aMethod.Assign(mMethod); }
|
|
|
|
|
|
|
|
void SetMethod(const nsACString& aMethod) { mMethod.Assign(aMethod); }
|
|
|
|
|
2014-10-06 22:01:20 +04:00
|
|
|
bool HasSimpleMethod() const {
|
|
|
|
return mMethod.LowerCaseEqualsASCII("get") ||
|
|
|
|
mMethod.LowerCaseEqualsASCII("post") ||
|
|
|
|
mMethod.LowerCaseEqualsASCII("head");
|
|
|
|
}
|
2016-11-07 05:16:34 +03:00
|
|
|
// GetURL should get the request's current url with fragment. A request has
|
|
|
|
// an associated current url. It is a pointer to the last fetch URL in
|
|
|
|
// request's url list.
|
2016-05-03 04:48:40 +03:00
|
|
|
void GetURL(nsACString& aURL) const {
|
2016-11-07 05:16:34 +03:00
|
|
|
aURL.Assign(GetURLWithoutFragment());
|
|
|
|
if (GetFragment().IsEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
2017-09-08 04:25:25 +03:00
|
|
|
aURL.AppendLiteral("#");
|
2016-11-07 05:16:34 +03:00
|
|
|
aURL.Append(GetFragment());
|
2016-05-03 04:48:40 +03:00
|
|
|
}
|
|
|
|
|
2016-11-07 05:16:34 +03:00
|
|
|
const nsCString& GetURLWithoutFragment() const {
|
|
|
|
MOZ_RELEASE_ASSERT(!mURLList.IsEmpty(),
|
|
|
|
"Internal Request's urlList should not be empty.");
|
|
|
|
|
|
|
|
return mURLList.LastElement();
|
|
|
|
}
|
2018-09-12 15:44:30 +03:00
|
|
|
|
|
|
|
// A safe guard for ensuring that request's URL is only allowed to be set in a
|
|
|
|
// sw internal redirect.
|
|
|
|
void SetURLForInternalRedirect(const uint32_t aFlag, const nsACString& aURL,
|
|
|
|
const nsACString& aFragment) {
|
|
|
|
// Only check in debug build to prevent it from being used unexpectedly.
|
|
|
|
MOZ_ASSERT(aFlag & nsIChannelEventSink::REDIRECT_INTERNAL);
|
|
|
|
|
|
|
|
return SetURL(aURL, aFragment);
|
|
|
|
}
|
|
|
|
|
2016-05-03 04:48:40 +03:00
|
|
|
// AddURL should append the url into url list.
|
2016-11-07 05:16:34 +03:00
|
|
|
// Normally we strip the fragment from the URL in Request::Constructor and
|
|
|
|
// pass the fragment as the second argument into it.
|
|
|
|
// If a fragment is present in the URL it must be stripped and passed in
|
|
|
|
// separately.
|
|
|
|
void AddURL(const nsACString& aURL, const nsACString& aFragment) {
|
2016-05-03 04:48:40 +03:00
|
|
|
MOZ_ASSERT(!aURL.IsEmpty());
|
2016-11-07 05:16:34 +03:00
|
|
|
MOZ_ASSERT(!aURL.Contains('#'));
|
|
|
|
|
2016-05-03 04:48:40 +03:00
|
|
|
mURLList.AppendElement(aURL);
|
2014-09-24 09:03:20 +04:00
|
|
|
|
2016-11-07 05:16:34 +03:00
|
|
|
mFragment.Assign(aFragment);
|
|
|
|
}
|
|
|
|
// Get the URL list without their fragments.
|
|
|
|
void GetURLListWithoutFragment(nsTArray<nsCString>& aURLList) {
|
2016-05-03 04:48:40 +03:00
|
|
|
aURLList.Assign(mURLList);
|
2015-01-08 00:47:18 +03:00
|
|
|
}
|
2014-12-23 18:56:19 +03:00
|
|
|
void GetReferrer(nsAString& aReferrer) const { aReferrer.Assign(mReferrer); }
|
2014-09-24 09:03:20 +04:00
|
|
|
|
2014-12-23 18:56:19 +03:00
|
|
|
void SetReferrer(const nsAString& aReferrer) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
bool validReferrer = false;
|
|
|
|
if (aReferrer.IsEmpty() ||
|
|
|
|
aReferrer.EqualsLiteral(kFETCH_CLIENT_REFERRER_STR)) {
|
|
|
|
validReferrer = true;
|
|
|
|
} else {
|
|
|
|
nsCOMPtr<nsIURLParser> parser = do_GetService(NS_STDURLPARSER_CONTRACTID);
|
|
|
|
if (!parser) {
|
|
|
|
NS_WARNING("Could not get parser to validate URL!");
|
|
|
|
} else {
|
|
|
|
uint32_t schemePos;
|
|
|
|
int32_t schemeLen;
|
|
|
|
uint32_t authorityPos;
|
|
|
|
int32_t authorityLen;
|
|
|
|
uint32_t pathPos;
|
|
|
|
int32_t pathLen;
|
|
|
|
|
|
|
|
NS_ConvertUTF16toUTF8 ref(aReferrer);
|
|
|
|
nsresult rv =
|
|
|
|
parser->ParseURL(ref.get(), ref.Length(), &schemePos, &schemeLen,
|
|
|
|
&authorityPos, &authorityLen, &pathPos, &pathLen);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("Invalid referrer URL!");
|
|
|
|
} else if (schemeLen < 0 || authorityLen < 0) {
|
|
|
|
NS_WARNING("Invalid referrer URL!");
|
|
|
|
} else {
|
|
|
|
validReferrer = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(validReferrer);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
mReferrer.Assign(aReferrer);
|
2014-09-24 09:03:20 +04:00
|
|
|
}
|
|
|
|
|
2016-02-27 01:36:45 +03:00
|
|
|
ReferrerPolicy ReferrerPolicy_() const { return mReferrerPolicy; }
|
|
|
|
|
|
|
|
void SetReferrerPolicy(ReferrerPolicy aReferrerPolicy) {
|
|
|
|
mReferrerPolicy = aReferrerPolicy;
|
|
|
|
}
|
|
|
|
|
2019-08-21 16:24:45 +03:00
|
|
|
ReferrerPolicy GetEnvironmentReferrerPolicy() const {
|
2016-04-01 06:52:28 +03:00
|
|
|
return mEnvironmentReferrerPolicy;
|
|
|
|
}
|
|
|
|
|
2019-08-21 16:24:45 +03:00
|
|
|
void SetEnvironmentReferrerPolicy(ReferrerPolicy aReferrerPolicy) {
|
2016-04-01 06:52:28 +03:00
|
|
|
mEnvironmentReferrerPolicy = aReferrerPolicy;
|
|
|
|
}
|
|
|
|
|
2014-12-24 13:08:41 +03:00
|
|
|
bool SkipServiceWorker() const { return mSkipServiceWorker; }
|
|
|
|
|
|
|
|
void SetSkipServiceWorker() { mSkipServiceWorker = true; }
|
|
|
|
|
2014-09-24 09:03:20 +04:00
|
|
|
bool IsSynchronous() const { return mSynchronous; }
|
|
|
|
|
2014-10-02 21:59:20 +04:00
|
|
|
RequestMode Mode() const { return mMode; }
|
|
|
|
|
2014-09-24 09:03:20 +04:00
|
|
|
void SetMode(RequestMode aMode) { mMode = aMode; }
|
|
|
|
|
2015-01-08 02:50:54 +03:00
|
|
|
RequestCredentials GetCredentialsMode() const { return mCredentialsMode; }
|
|
|
|
|
2014-09-24 09:03:20 +04:00
|
|
|
void SetCredentialsMode(RequestCredentials aCredentialsMode) {
|
|
|
|
mCredentialsMode = aCredentialsMode;
|
|
|
|
}
|
|
|
|
|
2014-10-06 22:01:20 +04:00
|
|
|
LoadTainting GetResponseTainting() const { return mResponseTainting; }
|
|
|
|
|
2015-10-22 21:07:32 +03:00
|
|
|
void MaybeIncreaseResponseTainting(LoadTainting aTainting) {
|
|
|
|
if (aTainting > mResponseTainting) {
|
|
|
|
mResponseTainting = aTainting;
|
|
|
|
}
|
2014-10-06 22:01:20 +04:00
|
|
|
}
|
|
|
|
|
2015-01-08 03:24:40 +03:00
|
|
|
RequestCache GetCacheMode() const { return mCacheMode; }
|
|
|
|
|
2015-03-22 20:12:43 +03:00
|
|
|
void SetCacheMode(RequestCache aCacheMode) { mCacheMode = aCacheMode; }
|
|
|
|
|
2015-09-01 00:26:29 +03:00
|
|
|
RequestRedirect GetRedirectMode() const { return mRedirectMode; }
|
|
|
|
|
|
|
|
void SetRedirectMode(RequestRedirect aRedirectMode) {
|
|
|
|
mRedirectMode = aRedirectMode;
|
|
|
|
}
|
|
|
|
|
2016-09-07 05:20:23 +03:00
|
|
|
const nsString& GetIntegrity() const { return mIntegrity; }
|
|
|
|
void SetIntegrity(const nsAString& aIntegrity) {
|
|
|
|
MOZ_ASSERT(mIntegrity.IsEmpty());
|
|
|
|
mIntegrity.Assign(aIntegrity);
|
|
|
|
}
|
2017-11-21 01:07:26 +03:00
|
|
|
|
|
|
|
bool MozErrors() const { return mMozErrors; }
|
|
|
|
|
|
|
|
void SetMozErrors() { mMozErrors = true; }
|
|
|
|
|
2016-11-07 05:16:34 +03:00
|
|
|
const nsCString& GetFragment() const { return mFragment; }
|
2016-09-07 05:20:23 +03:00
|
|
|
|
2015-01-28 02:43:09 +03:00
|
|
|
nsContentPolicyType ContentPolicyType() const { return mContentPolicyType; }
|
2015-03-25 23:38:42 +03:00
|
|
|
void SetContentPolicyType(nsContentPolicyType aContentPolicyType);
|
|
|
|
|
2016-04-08 00:13:09 +03:00
|
|
|
void OverrideContentPolicyType(nsContentPolicyType aContentPolicyType);
|
|
|
|
|
2018-03-09 17:11:27 +03:00
|
|
|
RequestDestination Destination() const {
|
|
|
|
return MapContentPolicyTypeToRequestDestination(mContentPolicyType);
|
2015-03-02 16:08:00 +03:00
|
|
|
}
|
|
|
|
|
2014-10-06 22:01:20 +04:00
|
|
|
bool UnsafeRequest() const { return mUnsafeRequest; }
|
|
|
|
|
2015-01-08 02:50:54 +03:00
|
|
|
void SetUnsafeRequest() { mUnsafeRequest = true; }
|
|
|
|
|
2014-09-24 09:03:20 +04:00
|
|
|
InternalHeaders* Headers() { return mHeaders; }
|
|
|
|
|
2018-12-01 23:26:09 +03:00
|
|
|
void SetHeaders(InternalHeaders* aHeaders) {
|
|
|
|
MOZ_ASSERT(aHeaders);
|
|
|
|
mHeaders = aHeaders;
|
|
|
|
}
|
|
|
|
|
2017-09-08 17:06:26 +03:00
|
|
|
void SetBody(nsIInputStream* aStream, int64_t aBodyLength) {
|
2014-12-10 11:51:59 +03:00
|
|
|
// A request's body may not be reset once set.
|
2015-08-10 22:06:00 +03:00
|
|
|
MOZ_ASSERT_IF(aStream, !mBodyStream);
|
2014-09-24 09:03:20 +04:00
|
|
|
mBodyStream = aStream;
|
2017-09-08 17:06:26 +03:00
|
|
|
mBodyLength = aBodyLength;
|
2014-09-24 09:03:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Will return the original stream!
|
|
|
|
// Use a tee or copy if you don't want to erase the original.
|
2017-09-08 17:06:26 +03:00
|
|
|
void GetBody(nsIInputStream** aStream, int64_t* aBodyLength = nullptr) {
|
2014-09-24 09:03:20 +04:00
|
|
|
nsCOMPtr<nsIInputStream> s = mBodyStream;
|
|
|
|
s.forget(aStream);
|
2017-09-08 17:06:26 +03:00
|
|
|
|
|
|
|
if (aBodyLength) {
|
|
|
|
*aBodyLength = mBodyLength;
|
|
|
|
}
|
2014-09-24 09:03:20 +04:00
|
|
|
}
|
|
|
|
|
2018-10-06 20:34:24 +03:00
|
|
|
void SetBodyBlobURISpec(nsACString& aBlobURISpec) {
|
|
|
|
mBodyBlobURISpec = aBlobURISpec;
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsACString& BodyBlobURISpec() const { return mBodyBlobURISpec; }
|
|
|
|
|
2018-09-11 22:13:15 +03:00
|
|
|
void SetBodyLocalPath(nsAString& aLocalPath) { mBodyLocalPath = aLocalPath; }
|
|
|
|
|
|
|
|
const nsAString& BodyLocalPath() const { return mBodyLocalPath; }
|
|
|
|
|
2014-09-24 09:03:20 +04:00
|
|
|
// The global is used as the client for the new object.
|
|
|
|
already_AddRefed<InternalRequest> GetRequestConstructorCopy(
|
|
|
|
nsIGlobalObject* aGlobal, ErrorResult& aRv) const;
|
|
|
|
|
2015-07-14 23:11:26 +03:00
|
|
|
bool IsNavigationRequest() const;
|
|
|
|
|
|
|
|
bool IsWorkerRequest() const;
|
|
|
|
|
|
|
|
bool IsClientRequest() const;
|
|
|
|
|
2016-03-03 02:09:30 +03:00
|
|
|
void MaybeSkipCacheIfPerformingRevalidation();
|
|
|
|
|
2016-04-08 00:13:09 +03:00
|
|
|
bool IsContentPolicyTypeOverridden() const {
|
|
|
|
return mContentPolicyTypeOverridden;
|
|
|
|
}
|
|
|
|
|
2015-09-01 17:58:34 +03:00
|
|
|
static RequestMode MapChannelToRequestMode(nsIChannel* aChannel);
|
2015-07-14 23:11:26 +03:00
|
|
|
|
2016-01-25 09:18:29 +03:00
|
|
|
static RequestCredentials MapChannelToRequestCredentials(
|
|
|
|
nsIChannel* aChannel);
|
|
|
|
|
2016-10-26 10:07:25 +03:00
|
|
|
// Takes ownership of the principal info.
|
|
|
|
void SetPrincipalInfo(UniquePtr<mozilla::ipc::PrincipalInfo> aPrincipalInfo);
|
|
|
|
|
|
|
|
const UniquePtr<mozilla::ipc::PrincipalInfo>& GetPrincipalInfo() const {
|
|
|
|
return mPrincipalInfo;
|
|
|
|
}
|
|
|
|
|
2017-12-04 09:39:10 +03:00
|
|
|
const nsCString& GetPreferredAlternativeDataType() const {
|
|
|
|
return mPreferredAlternativeDataType;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetPreferredAlternativeDataType(const nsACString& aDataType) {
|
|
|
|
mPreferredAlternativeDataType = aDataType;
|
|
|
|
}
|
|
|
|
|
2014-09-24 09:03:20 +04:00
|
|
|
private:
|
2015-02-20 04:24:24 +03:00
|
|
|
// Does not copy mBodyStream. Use fallible Clone() for complete copy.
|
|
|
|
explicit InternalRequest(const InternalRequest& aOther);
|
|
|
|
|
2014-09-24 09:03:20 +04:00
|
|
|
~InternalRequest();
|
|
|
|
|
2018-03-09 17:11:27 +03:00
|
|
|
// Map the content policy type to the associated fetch destination, as defined
|
|
|
|
// by the spec at https://fetch.spec.whatwg.org/#concept-request-destination.
|
|
|
|
// Note that while the HTML spec for the "Link" element and its "as" attribute
|
|
|
|
// (https://html.spec.whatwg.org/#attr-link-as) reuse fetch's definition of
|
|
|
|
// destination, and the Link class has an internal Link::AsDestination enum
|
|
|
|
// type, the latter is only a support type to map the string values via
|
|
|
|
// Link::ParseAsValue and Link::AsValueToContentPolicy to our canonical
|
|
|
|
// nsContentPolicyType.
|
|
|
|
static RequestDestination MapContentPolicyTypeToRequestDestination(
|
|
|
|
nsContentPolicyType aContentPolicyType);
|
2015-06-15 23:12:45 +03:00
|
|
|
|
2015-09-01 17:58:34 +03:00
|
|
|
static bool IsNavigationContentPolicy(nsContentPolicyType aContentPolicyType);
|
|
|
|
|
|
|
|
static bool IsWorkerContentPolicy(nsContentPolicyType aContentPolicyType);
|
|
|
|
|
2018-09-12 15:44:30 +03:00
|
|
|
// It should only be called while there is a service-worker-internal-redirect.
|
|
|
|
void SetURL(const nsACString& aURL, const nsACString& aFragment) {
|
|
|
|
MOZ_ASSERT(!aURL.IsEmpty());
|
|
|
|
MOZ_ASSERT(!aURL.Contains('#'));
|
|
|
|
MOZ_ASSERT(mURLList.Length() > 0);
|
|
|
|
|
|
|
|
mURLList.LastElement() = aURL;
|
|
|
|
mFragment.Assign(aFragment);
|
|
|
|
}
|
|
|
|
|
2014-09-24 09:03:20 +04:00
|
|
|
nsCString mMethod;
|
2016-05-03 04:48:40 +03:00
|
|
|
// mURLList: a list of one or more fetch URLs
|
|
|
|
nsTArray<nsCString> mURLList;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<InternalHeaders> mHeaders;
|
2018-10-06 20:34:24 +03:00
|
|
|
nsCString mBodyBlobURISpec;
|
2018-09-11 22:13:15 +03:00
|
|
|
nsString mBodyLocalPath;
|
2014-09-24 09:03:20 +04:00
|
|
|
nsCOMPtr<nsIInputStream> mBodyStream;
|
2017-09-08 17:06:26 +03:00
|
|
|
int64_t mBodyLength;
|
2014-09-24 09:03:20 +04:00
|
|
|
|
2017-12-04 09:39:10 +03:00
|
|
|
nsCString mPreferredAlternativeDataType;
|
|
|
|
|
2015-01-28 02:43:09 +03:00
|
|
|
nsContentPolicyType mContentPolicyType;
|
2014-09-24 09:03:20 +04:00
|
|
|
|
2014-12-23 18:56:19 +03:00
|
|
|
// Empty string: no-referrer
|
|
|
|
// "about:client": client (default)
|
|
|
|
// URL: an URL
|
|
|
|
nsString mReferrer;
|
2016-02-27 01:36:45 +03:00
|
|
|
ReferrerPolicy mReferrerPolicy;
|
2014-09-24 09:03:20 +04:00
|
|
|
|
2016-04-01 06:52:28 +03:00
|
|
|
// This will be used for request created from Window or Worker contexts
|
|
|
|
// In case there's no Referrer Policy in Request, this will be passed to
|
|
|
|
// channel.
|
2019-08-21 16:24:45 +03:00
|
|
|
ReferrerPolicy mEnvironmentReferrerPolicy;
|
2014-09-24 09:03:20 +04:00
|
|
|
RequestMode mMode;
|
|
|
|
RequestCredentials mCredentialsMode;
|
2020-01-16 19:33:28 +03:00
|
|
|
LoadTainting mResponseTainting = LoadTainting::Basic;
|
2015-01-08 03:24:40 +03:00
|
|
|
RequestCache mCacheMode;
|
2015-09-01 00:26:29 +03:00
|
|
|
RequestRedirect mRedirectMode;
|
2016-09-07 05:20:23 +03:00
|
|
|
nsString mIntegrity;
|
2019-10-09 02:47:36 +03:00
|
|
|
bool mMozErrors = false;
|
2016-11-07 05:16:34 +03:00
|
|
|
nsCString mFragment;
|
2020-01-16 19:33:35 +03:00
|
|
|
bool mSkipServiceWorker = false;
|
2020-01-16 19:33:15 +03:00
|
|
|
bool mSynchronous = false;
|
2020-01-16 19:33:19 +03:00
|
|
|
bool mUnsafeRequest = false;
|
2020-01-16 19:33:04 +03:00
|
|
|
bool mUseURLCredentials = false;
|
2016-04-08 00:13:09 +03:00
|
|
|
// This is only set when Request.overrideContentPolicyType() has been set.
|
|
|
|
// It is illegal to pass such a Request object to a fetch() method unless
|
|
|
|
// if the caller has chrome privileges.
|
|
|
|
bool mContentPolicyTypeOverridden = false;
|
2016-10-26 10:07:25 +03:00
|
|
|
|
|
|
|
UniquePtr<mozilla::ipc::PrincipalInfo> mPrincipalInfo;
|
2014-09-24 09:03:20 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_InternalRequest_h
|