1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_dom_Request_h
7 #define mozilla_dom_Request_h
9 #include "nsISupportsImpl.h"
10 #include "nsWrapperCache.h"
12 #include "mozilla/dom/Fetch.h"
13 #include "mozilla/dom/InternalRequest.h"
14 // Required here due to certain WebIDL enums/classes being declared in both
16 #include "mozilla/dom/RequestBinding.h"
24 class InternalHeaders
;
26 class RequestOrUSVString
;
28 class Request MOZ_FINAL
: public nsISupports
29 , public nsWrapperCache
30 , public FetchBody
<Request
>
32 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
33 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Request
)
36 Request(nsIGlobalObject
* aOwner
, InternalRequest
* aRequest
);
39 WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
41 return RequestBinding::Wrap(aCx
, this);
45 GetUrl(DOMString
& aUrl
) const
47 aUrl
.AsAString() = NS_ConvertUTF8toUTF16(mRequest
->mURL
);
51 GetMethod(nsCString
& aMethod
) const
53 aMethod
= mRequest
->mMethod
;
59 return mRequest
->mMode
;
65 return mRequest
->mCredentialsMode
;
69 GetReferrer(DOMString
& aReferrer
) const
71 if (mRequest
->ReferrerIsNone()) {
72 aReferrer
.AsAString() = EmptyString();
76 // FIXME(nsm): Spec doesn't say what to do if referrer is client.
77 aReferrer
.AsAString() = NS_ConvertUTF8toUTF16(mRequest
->mReferrerURL
);
81 GetInternalHeaders() const
83 return mRequest
->Headers();
89 GetBody(nsIInputStream
** aStream
) { return mRequest
->GetBody(aStream
); }
91 static already_AddRefed
<Request
>
92 Constructor(const GlobalObject
& aGlobal
, const RequestOrUSVString
& aInput
,
93 const RequestInit
& aInit
, ErrorResult
& rv
);
95 nsIGlobalObject
* GetParentObject() const
100 already_AddRefed
<Request
>
103 already_AddRefed
<InternalRequest
>
104 GetInternalRequest();
108 nsCOMPtr
<nsIGlobalObject
> mOwner
;
109 nsRefPtr
<InternalRequest
> mRequest
;
111 nsRefPtr
<Headers
> mHeaders
;
115 } // namespace mozilla
117 #endif // mozilla_dom_Request_h