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 
16 #ifndef APP_DOMAIN_VERIFY_HTTP_TASK_H
17 #define APP_DOMAIN_VERIFY_HTTP_TASK_H
18 #include "i_http_task.h"
19 #include "i_verify_task.h"
20 namespace OHOS::AppDomainVerify {
21 class VerifyHttpTask : public IHttpTask {
22 public:
23     VerifyHttpTask(std::string uri, std::shared_ptr<IVerifyTask> verifyTask);
24     ~VerifyHttpTask() override;
25     std::shared_ptr<OHOS::NetStack::HttpClient::HttpClientTask> CreateHttpClientTask() override;
26     void OnSuccess(const HttpClientRequest& request, const HttpClientResponse& response) override;
27 
28     void OnCancel(const HttpClientRequest& request, const HttpClientResponse& response) override;
29 
30     void OnFail(
31         const HttpClientRequest& request, const HttpClientResponse& response, const HttpClientError& error) override;
32 
33     void OnDataReceive(std::shared_ptr<OHOS::NetStack::HttpClient::HttpClientTask> task,
34         const HttpClientRequest& request, const uint8_t* data, size_t length) override;
35 
36 private:
37     std::string uri_;
38     std::shared_ptr<IVerifyTask> verifyTask_;
39     size_t length_{ 0 };
40 };
41 }
42 
43 #endif  // APP_DOMAIN_VERIFY_HTTP_TASK_H
44