1 /* 2 * Copyright (c) 2021-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 OHOS_ACELITE_HTTP_REQUEST_UTILS_H 17 #define OHOS_ACELITE_HTTP_REQUEST_UTILS_H 18 19 #include <string> 20 #include <vector> 21 22 #include "curl/curl.h" 23 #include "hilog/log.h" 24 25 #define HTTP_REQUEST_INFO(...) \ 26 do { \ 27 HILOG_INFO(LOG_APP, "[HTTP][INFO] " __VA_ARGS__); \ 28 } while (0) 29 30 #define HTTP_REQUEST_ERROR(...) \ 31 do { \ 32 HILOG_ERROR(LOG_APP, "[HTTP][ERROR] " __VA_ARGS__); \ 33 } while (0) 34 35 namespace OHOS { 36 namespace ACELite { 37 38 std::vector<std::string> Split(const std::string &str, const std::string &sep); 39 40 std::string Strip(const std::string &str, char ch = ' '); 41 42 bool MethodForGet(const std::string &method); 43 44 bool MethodForPost(const std::string &method); 45 46 std::string MakeUrl(const std::string &url, std::string param, const std::string &extraParam); 47 48 bool EncodeUrlParam(CURL *curl, std::string &url); 49 } // namespace ACELite 50 } // namespace OHOS 51 52 #endif /* OHOS_ACELITE_HTTP_REQUEST_UTILS_H */ 53