• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 #ifndef ACE_ETS_WEB_NAPIS_TEST_REQUEST_H
16 #define ACE_ETS_WEB_NAPIS_TEST_REQUEST_H
17 
18 #include <bits/alltypes.h>
19 #include <rawfile/raw_file_manager.h>
20 #include <web/arkweb_scheme_handler.h>
21 #include <string>
22 
23 
24 class TestRequest
25 {
26     public:
27     TestRequest(const ArkWeb_ResourceRequest* resourceRequest, const ArkWeb_ResourceHandler* resourceHandler,
28                 const NativeResourceManager* resourceManager);
29     ~TestRequest();
30 
31     void Start();
32     void Stop();
33     void ReadRawfileDataOnWorkerThread();
34 
35     void DidReceiveResponse();
36     void DidReceiveData(const uint8_t *buffer, int64_t bufLen);
37     void DidFinish();
38     void DidFailWithError(ArkWeb_NetError errorCode);
39 
resourceHandler()40     const ArkWeb_ResourceHandler *resourceHandler() { return resourceHandler_; }
resourceRequest()41     const ArkWeb_ResourceRequest *resourceRequest() { return resourceRequest_; }
resourceManager()42     const NativeResourceManager *resourceManager() { return resourceManager_; }
response()43     ArkWeb_Response *response() { return response_; }
stream()44     ArkWeb_HttpBodyStream *stream() { return stream_; }
rawfilePath()45     const std::string rawfilePath() { return rawfilePath_; }
url()46     const std::string url() { return url_; }
method()47     const std::string method() { return method_; }
referrer()48     const std::string referrer() { return referrer_; }
49 
isGetBodyStream()50     bool isGetBodyStream() { return isGetBodyStream_; }
header_size()51     int32_t header_size() { return header_size_; }
hasHeader()52     bool hasHeader() { return hasHeader_; }
isHeaderDestroy()53     bool isHeaderDestroy() { return isHeaderDestroy_; }
hasGesture()54     bool hasGesture() { return hasGesture_; }
isMainFrame()55     bool isMainFrame() { return isMainFrame_; }
isRedirect()56     bool isRedirect() { return isRedirect_; }
resourceRequestDestroy()57     int32_t resourceRequestDestroy() { return resourceRequestDestroy_; }
58 
rspUrl()59     const std::string rspUrl() { return rspUrl_; }
rspNetError()60     int32_t rspNetError() { return rspNetError_; }
rspStatus()61     int32_t rspStatus() { return rspStatus_; }
rspStatusText()62     const std::string rspStatusText() { return rspStatusText_; }
rspMimeType()63     const std::string rspMimeType() { return rspMimeType_; }
rspCharSet()64     const std::string rspCharSet() { return rspCharSet_; }
rspHost()65     const std::string rspHost() { return rspHost_; }
66 
setRspUrl()67     int32_t setRspUrl() { return setRspUrl_; }
setRspError()68     int32_t setRspError() { return setRspError_; }
setStatus()69     int32_t setStatus() { return setStatus_; }
setStatusText()70     int32_t setStatusText() { return setStatusText_; }
setMimeType()71     int32_t setMimeType() { return setMimeType_; }
setCharset()72     int32_t setCharset() { return setCharset_; }
setHeaderByName()73     int32_t setHeaderByName() { return setHeaderByName_; }
74 
rspResourceType()75     int32_t rspResourceType() { return rspResourceType_; }
rspFrameUrl()76     const std::string rspFrameUrl() { return rspFrameUrl_; }
77 
78 private:
79     const ArkWeb_ResourceRequest* resourceRequest_{nullptr};
80     const ArkWeb_ResourceHandler* resourceHandler_{nullptr};
81     const NativeResourceManager* resourceManager_{nullptr};
82     ArkWeb_Response* response_;
83     bool stopped_{false};
84     std::string rawfilePath_;
85     std::string url_;
86     std::string method_;
87     std::string referrer_{"test"};
88     ArkWeb_HttpBodyStream *stream_{nullptr};
89     bool isGetBodyStream_{false};
90     int32_t header_size_;
91     bool hasHeader_{false};
92     bool isHeaderDestroy_{false};
93     bool hasGesture_{false};
94     bool isMainFrame_{false};
95     bool isRedirect_{false};
96     int32_t resourceRequestDestroy_{-1};
97 
98     std::string rspUrl_{"test"};
99     int32_t rspNetError_;
100     int32_t rspStatus_;
101     std::string rspStatusText_;
102     std::string rspMimeType_;
103     std::string rspCharSet_;
104     std::string rspHost_{"test"};
105 
106     int32_t setRspUrl_{-1};
107     int32_t setRspError_{-1};
108     int32_t setStatus_{-1};
109     int32_t setStatusText_{-1};
110     int32_t setMimeType_{-1};
111     int32_t setCharset_{-1};
112     int32_t setHeaderByName_{-1};
113 
114     int32_t rspResourceType_{-100};
115     std::string rspFrameUrl_{"test"};
116 };
117 
118 
119 #endif //ACE_ETS_WEB_NAPIS_TEST_REQUEST_H