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_H
17 #define NET_HTTP_FFI_H
18 
19 #include "ffi_remote_data.h"
20 #include "ffi_structs.h"
21 #include "netstack_log.h"
22 
23 EXTERN_C_START
24     FFI_EXPORT int32_t CJ_CreateHttpResponseCache(uint32_t cacheSize);
25     FFI_EXPORT int32_t CJ_HttpResponseCacheFlush();
26     FFI_EXPORT int32_t CJ_HttpResponseCacheDelete();
27     FFI_EXPORT int64_t CJ_CreateHttp();
28     FFI_EXPORT void CJ_DestroyRequest(int64_t id);
29     FFI_EXPORT RetDataCString CJ_SendRequest(int64_t id, char* url,
30         CHttpRequestOptions* opt, bool isInStream, void (*callback)(CHttpResponse));
31 
32     // callback events
33     FFI_EXPORT void CJ_OnHeadersReceive(int64_t id, bool once, void (*callback)(CArrString));
34     FFI_EXPORT void CJ_OffHeadersReceive(int64_t id);
35     FFI_EXPORT void CJ_OnDataReceive(int64_t id, void (*callback)(CArrUI8));
36     FFI_EXPORT void CJ_OffDataReceive(int64_t id);
37     FFI_EXPORT void CJ_OnDataEnd(int64_t id, void (*callback)());
38     FFI_EXPORT void CJ_OffDataEnd(int64_t id);
39     FFI_EXPORT void CJ_OnDataReceiveProgress(int64_t id, void (*callback)(CDataReceiveProgressInfo));
40     FFI_EXPORT void CJ_OffDataReceiveProgress(int64_t id);
41     FFI_EXPORT void CJ_OnDataSendProgress(int64_t id, void (*callback)(CDataSendProgressInfo));
42     FFI_EXPORT void CJ_OffDataSendProgress(int64_t id);
43 EXTERN_C_END
44 
45 #endif