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-07-25 04:53:03 +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_Request_h
|
|
|
|
#define mozilla_dom_Request_h
|
|
|
|
|
|
|
|
#include "nsISupportsImpl.h"
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
|
2014-09-27 03:41:15 +04:00
|
|
|
#include "mozilla/dom/Fetch.h"
|
2014-09-24 09:03:20 +04:00
|
|
|
#include "mozilla/dom/InternalRequest.h"
|
|
|
|
// Required here due to certain WebIDL enums/classes being declared in both
|
|
|
|
// files.
|
2014-07-25 04:53:03 +04:00
|
|
|
#include "mozilla/dom/RequestBinding.h"
|
2020-05-11 15:10:53 +03:00
|
|
|
#include "mozilla/dom/SafeRefPtr.h"
|
2014-07-25 04:53:03 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class Headers;
|
2014-10-02 21:59:20 +04:00
|
|
|
class InternalHeaders;
|
2014-11-20 14:58:00 +03:00
|
|
|
class RequestOrUSVString;
|
2014-07-25 04:53:03 +04:00
|
|
|
|
2019-07-01 23:01:17 +03:00
|
|
|
class Request final : public FetchBody<Request>, public nsWrapperCache {
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(Request,
|
|
|
|
FetchBody<Request>)
|
2014-07-25 04:53:03 +04:00
|
|
|
|
|
|
|
public:
|
2020-05-11 15:10:53 +03:00
|
|
|
Request(nsIGlobalObject* aOwner, SafeRefPtr<InternalRequest> aRequest,
|
2017-08-29 12:31:06 +03:00
|
|
|
AbortSignal* aSignal);
|
2014-07-25 04:53:03 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override {
|
2018-06-26 00:20:54 +03:00
|
|
|
return Request_Binding::Wrap(aCx, this, aGivenProto);
|
2014-07-25 04:53:03 +04:00
|
|
|
}
|
|
|
|
|
2015-03-02 16:08:00 +03:00
|
|
|
void GetUrl(nsAString& aUrl) const {
|
2016-05-03 04:48:40 +03:00
|
|
|
nsAutoCString url;
|
|
|
|
mRequest->GetURL(url);
|
|
|
|
CopyUTF8toUTF16(url, aUrl);
|
2014-07-25 04:53:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GetMethod(nsCString& aMethod) const { aMethod = mRequest->mMethod; }
|
|
|
|
|
2014-09-24 09:03:20 +04:00
|
|
|
RequestMode Mode() const { return mRequest->mMode; }
|
2014-07-25 04:53:03 +04:00
|
|
|
|
2014-09-24 09:03:20 +04:00
|
|
|
RequestCredentials Credentials() const { return mRequest->mCredentialsMode; }
|
2014-07-25 04:53:03 +04:00
|
|
|
|
2015-01-08 03:24:40 +03:00
|
|
|
RequestCache Cache() const { return mRequest->GetCacheMode(); }
|
|
|
|
|
2015-09-01 00:26:29 +03:00
|
|
|
RequestRedirect Redirect() const { return mRequest->GetRedirectMode(); }
|
|
|
|
|
2016-09-07 05:20:23 +03:00
|
|
|
void GetIntegrity(nsAString& aIntegrity) const {
|
|
|
|
aIntegrity = mRequest->GetIntegrity();
|
|
|
|
}
|
|
|
|
|
2017-11-21 01:07:26 +03:00
|
|
|
bool MozErrors() const { return mRequest->MozErrors(); }
|
|
|
|
|
2018-03-09 17:11:27 +03:00
|
|
|
RequestDestination Destination() const { return mRequest->Destination(); }
|
2015-03-25 23:38:42 +03:00
|
|
|
|
2016-04-08 00:13:09 +03:00
|
|
|
void OverrideContentPolicyType(nsContentPolicyType aContentPolicyType) {
|
|
|
|
mRequest->OverrideContentPolicyType(aContentPolicyType);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsContentPolicyTypeOverridden() const {
|
|
|
|
return mRequest->IsContentPolicyTypeOverridden();
|
2015-01-28 03:02:12 +03:00
|
|
|
}
|
|
|
|
|
2014-12-23 18:56:19 +03:00
|
|
|
void GetReferrer(nsAString& aReferrer) const {
|
|
|
|
mRequest->GetReferrer(aReferrer);
|
2014-07-25 04:53:03 +04:00
|
|
|
}
|
|
|
|
|
2016-02-27 01:36:45 +03:00
|
|
|
ReferrerPolicy ReferrerPolicy_() const { return mRequest->ReferrerPolicy_(); }
|
|
|
|
|
2014-10-02 21:59:20 +04:00
|
|
|
InternalHeaders* GetInternalHeaders() const { return mRequest->Headers(); }
|
|
|
|
|
|
|
|
Headers* Headers_();
|
2014-07-25 04:53:03 +04:00
|
|
|
|
2017-08-11 04:04:54 +03:00
|
|
|
using FetchBody::GetBody;
|
|
|
|
|
2017-09-08 17:06:26 +03:00
|
|
|
void GetBody(nsIInputStream** aStream, int64_t* aBodyLength = nullptr) {
|
|
|
|
mRequest->GetBody(aStream, aBodyLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetBody(nsIInputStream* aStream, int64_t aBodyLength) {
|
|
|
|
mRequest->SetBody(aStream, aBodyLength);
|
|
|
|
}
|
2015-08-10 22:06:00 +03:00
|
|
|
|
2018-10-06 20:34:24 +03:00
|
|
|
using FetchBody::BodyBlobURISpec;
|
|
|
|
|
|
|
|
const nsACString& BodyBlobURISpec() const {
|
|
|
|
return mRequest->BodyBlobURISpec();
|
|
|
|
}
|
|
|
|
|
2018-09-11 22:13:15 +03:00
|
|
|
using FetchBody::BodyLocalPath;
|
|
|
|
|
|
|
|
const nsAString& BodyLocalPath() const { return mRequest->BodyLocalPath(); }
|
|
|
|
|
2020-05-11 15:13:48 +03:00
|
|
|
static SafeRefPtr<Request> Constructor(const GlobalObject& aGlobal,
|
|
|
|
const RequestOrUSVString& aInput,
|
|
|
|
const RequestInit& aInit,
|
|
|
|
ErrorResult& rv);
|
2014-07-25 04:53:03 +04:00
|
|
|
|
2020-05-11 15:13:48 +03:00
|
|
|
static SafeRefPtr<Request> Constructor(nsIGlobalObject* aGlobal,
|
|
|
|
JSContext* aCx,
|
|
|
|
const RequestOrUSVString& aInput,
|
|
|
|
const RequestInit& aInit,
|
|
|
|
ErrorResult& rv);
|
2020-03-18 01:24:39 +03:00
|
|
|
|
2014-09-27 03:41:15 +04:00
|
|
|
nsIGlobalObject* GetParentObject() const { return mOwner; }
|
2014-07-25 04:53:03 +04:00
|
|
|
|
2020-05-11 15:13:48 +03:00
|
|
|
SafeRefPtr<Request> Clone(ErrorResult& aRv);
|
2014-07-25 04:53:03 +04:00
|
|
|
|
2020-05-11 15:10:53 +03:00
|
|
|
SafeRefPtr<InternalRequest> GetInternalRequest();
|
2016-10-26 10:07:25 +03:00
|
|
|
|
|
|
|
const UniquePtr<mozilla::ipc::PrincipalInfo>& GetPrincipalInfo() const {
|
|
|
|
return mRequest->GetPrincipalInfo();
|
|
|
|
}
|
|
|
|
|
2017-08-29 12:31:06 +03:00
|
|
|
AbortSignal* GetOrCreateSignal();
|
|
|
|
|
2018-08-26 15:16:21 +03:00
|
|
|
// This can return a null AbortSignalImpl.
|
|
|
|
AbortSignalImpl* GetSignalImpl() const override;
|
2017-08-29 12:31:06 +03:00
|
|
|
|
2014-07-25 04:53:03 +04:00
|
|
|
private:
|
|
|
|
~Request();
|
|
|
|
|
2020-05-11 15:10:53 +03:00
|
|
|
SafeRefPtr<InternalRequest> mRequest;
|
2017-08-29 12:31:06 +03:00
|
|
|
|
2014-10-02 21:59:20 +04:00
|
|
|
// Lazily created.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Headers> mHeaders;
|
2017-08-29 12:31:06 +03:00
|
|
|
RefPtr<AbortSignal> mSignal;
|
2014-07-25 04:53:03 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_Request_h
|