1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef NWEB_URL_RESOURCE_REQUEST_H
17 #define NWEB_URL_RESOURCE_REQUEST_H
18 #include <map>
19 #include <string>
20 
21 #include "nweb_export.h"
22 
23 namespace OHOS::NWeb {
24 
25 class OHOS_NWEB_EXPORT NWebUrlResourceRequest {
26 public:
27     NWebUrlResourceRequest() = default;
28 
29     virtual ~NWebUrlResourceRequest() = default;
30 
31     /**
32      * @brief Gets the method associated with the request, for example "GET".
33      *
34      * @retval method the method associated with the request.
35      */
36     virtual std::string Method() = 0;
37 
38     /**
39      * @brief Gets the headers associated with the request.
40      *
41      * @retval the headers associated with the request.
42      */
43     virtual std::map<std::string, std::string> RequestHeaders() = 0;
44 
45     /**
46      * @brief Gets the URL for which the resource request was made.
47      *
48      * @retval URL url string
49      */
50     virtual std::string Url() = 0;
51 
52     /**
53      * @brief Gets whether a gesture (such as a click) was associated with the
54      * request.
55      *
56      * @retval gesture whether was associated with the request.
57      */
58     virtual bool FromGesture() = 0;
59 
60     /**
61      * @brief Gets whether the request was made in order to fetch the main frame's
62      * document.
63      *
64      * @retval Is main frame
65      */
66     virtual bool IsAboutMainFrame() = 0;
67 
68     /**
69      * @brief Gets whether the request was a result of a server-side redirect.
70      *
71      * @retval is redirect
72      */
73     virtual bool IsRequestRedirect() = 0;
74 };
75 
76 } // namespace OHOS::NWeb
77 
78 #endif // NWEB_URL_RESOURCE_REQUEST_H