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
|
|
|
|
|
2015-01-28 02:43:09 +03:00
|
|
|
#include "nsIContentPolicy.h"
|
2014-07-25 04:53:03 +04:00
|
|
|
#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"
|
|
|
|
|
|
|
|
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
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class Request final : public nsISupports
|
2015-03-27 21:52:19 +03:00
|
|
|
, public FetchBody<Request>
|
|
|
|
, public nsWrapperCache
|
2014-07-25 04:53:03 +04:00
|
|
|
{
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Request)
|
|
|
|
|
|
|
|
public:
|
2017-08-29 12:31:06 +03:00
|
|
|
Request(nsIGlobalObject* aOwner, InternalRequest* aRequest,
|
|
|
|
AbortSignal* aSignal);
|
2014-07-25 04:53:03 +04:00
|
|
|
|
|
|
|
JSObject*
|
2015-03-21 19:28:04 +03:00
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
|
2014-07-25 04:53:03 +04:00
|
|
|
{
|
2018-06-26 00:20:54 +03:00
|
|
|
return Request_Binding::Wrap(aCx, this, aGivenProto);
|
2014-07-25 04:53:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-03-02 16:08:00 +03:00
|
|
|
GetUrl(nsAString& aUrl) const
|
2014-07-25 04:53:03 +04:00
|
|
|
{
|
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
|
|
|
|
{
|
2014-09-24 09:03:20 +04:00
|
|
|
aMethod = mRequest->mMethod;
|
2014-07-25 04:53:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
RequestMode
|
|
|
|
Mode() const
|
|
|
|
{
|
2014-09-24 09:03:20 +04:00
|
|
|
return mRequest->mMode;
|
2014-07-25 04:53:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
RequestCredentials
|
|
|
|
Credentials() const
|
|
|
|
{
|
2014-09-24 09:03:20 +04:00
|
|
|
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
|
2015-01-28 02:43:09 +03:00
|
|
|
{
|
2018-03-09 17:11:27 +03:00
|
|
|
return mRequest->Destination();
|
2015-01-28 02:43:09 +03:00
|
|
|
}
|
2015-03-25 23:38:42 +03:00
|
|
|
|
|
|
|
void
|
2016-04-08 00:13:09 +03:00
|
|
|
OverrideContentPolicyType(nsContentPolicyType aContentPolicyType)
|
2015-03-25 23:38:42 +03:00
|
|
|
{
|
2016-04-08 00:13:09 +03:00
|
|
|
mRequest->OverrideContentPolicyType(aContentPolicyType);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsContentPolicyTypeOverridden() const
|
|
|
|
{
|
|
|
|
return mRequest->IsContentPolicyTypeOverridden();
|
2015-01-28 03:02:12 +03:00
|
|
|
}
|
|
|
|
|
2014-07-25 04:53:03 +04:00
|
|
|
void
|
2014-12-23 18:56:19 +03:00
|
|
|
GetReferrer(nsAString& aReferrer) const
|
2014-07-25 04:53:03 +04:00
|
|
|
{
|
2014-12-23 18:56:19 +03:00
|
|
|
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;
|
|
|
|
|
2015-08-10 22:06:00 +03:00
|
|
|
void
|
2017-09-08 17:06:26 +03:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2014-07-25 04:53:03 +04:00
|
|
|
static already_AddRefed<Request>
|
2014-11-20 14:58:00 +03:00
|
|
|
Constructor(const GlobalObject& aGlobal, const RequestOrUSVString& aInput,
|
2014-07-25 04:53:03 +04:00
|
|
|
const RequestInit& aInit, ErrorResult& rv);
|
|
|
|
|
2014-09-27 03:41:15 +04:00
|
|
|
nsIGlobalObject* GetParentObject() const
|
2014-07-25 04:53:03 +04:00
|
|
|
{
|
|
|
|
return mOwner;
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Request>
|
2017-08-29 12:31:06 +03:00
|
|
|
Clone(ErrorResult& aRv);
|
2014-07-25 04:53:03 +04:00
|
|
|
|
2014-09-24 09:03:20 +04:00
|
|
|
already_AddRefed<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();
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<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
|