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 NET_HTTP_FFI_STRUCTS_H 17 #define NET_HTTP_FFI_STRUCTS_H 18 19 #include <cstdint> 20 21 #include "cj_ffi/cj_common_ffi.h" 22 23 #ifdef __cplusplus 24 #define EXTERN_C_START extern "C" { 25 #define EXTERN_C_END } 26 #else 27 #define EXTERN_C_START 28 #define EXTERN_C_END 29 #endif 30 31 EXTERN_C_START 32 struct CHttpProxy { 33 char* host; 34 uint16_t port; 35 char** exclusionList; 36 int64_t exclusionListSize; 37 }; 38 39 struct CMultiFormData { 40 char* name; 41 char* contentType; 42 char* remoteFileName; 43 CArrUI8 data; 44 char* filePath; 45 }; 46 47 struct CArrMultiFormData { 48 CMultiFormData* data; 49 int64_t size; 50 }; 51 52 struct CClientCert { 53 char* certPath; 54 char* keyPath; 55 char* certType; 56 char* keyPassword; 57 }; 58 59 struct CPerformanceTiming { 60 double dnsTiming; 61 double tcpTiming; 62 double tlsTiming; 63 double firstSendTiming; 64 double firstReceiveTiming; 65 double totalFinishTiming; 66 double redirectTiming; 67 double responseHeaderTiming; 68 double responseBodyTiming; 69 double totalTiming; 70 }; 71 72 struct CHttpRequestOptions { 73 char* method; 74 CArrUI8 extraData; 75 int32_t expectDataType; 76 bool usingCache; 77 uint32_t priority; 78 CArrString header; 79 uint32_t readTimeout; 80 uint32_t connectTimeout; 81 int32_t usingProtocol; 82 bool usingDefaultProxy; 83 CHttpProxy* usingProxy; 84 char* caPath; 85 int64_t resumeFrom; 86 int64_t resumeTo; 87 CClientCert* clientCert; 88 char* dnsOverHttps; 89 CArrString dnsServer; 90 uint32_t maxLimit; 91 CArrMultiFormData multiFormDataList; 92 }; 93 94 struct CHttpResponse { 95 int32_t errCode; 96 char* errMsg; 97 CArrUI8 result; 98 int32_t resultType; 99 uint32_t responseCode; 100 CArrString header; 101 char* cookies; 102 CArrString setCookie; 103 CPerformanceTiming performanceTiming; 104 }; 105 106 struct CDataReceiveProgressInfo { 107 uint32_t receiveSize; 108 uint32_t totalSize; 109 }; 110 111 struct CDataSendProgressInfo { 112 uint32_t sendSize; 113 uint32_t totalSize; 114 }; 115 EXTERN_C_END 116 117 #endif