1 /*
2  * Copyright (c) 2023 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 #include "http_client_constant.h"
17 #include <unistd.h>
18 #include <string>
19 
20 namespace OHOS {
21 namespace NetStack {
22 namespace HttpClient {
23 const char *const HttpConstant::HTTP_METHOD_GET = "GET";
24 const char *const HttpConstant::HTTP_METHOD_HEAD = "HEAD";
25 const char *const HttpConstant::HTTP_METHOD_OPTIONS = "OPTIONS";
26 const char *const HttpConstant::HTTP_METHOD_TRACE = "TRACE";
27 const char *const HttpConstant::HTTP_METHOD_DELETE = "DELETE";
28 const char *const HttpConstant::HTTP_METHOD_POST = "POST";
29 const char *const HttpConstant::HTTP_METHOD_PUT = "PUT";
30 const char *const HttpConstant::HTTP_METHOD_CONNECT = "CONNECT";
31 
32 const uint32_t HttpConstant::DEFAULT_READ_TIMEOUT = 60000;
33 const uint32_t HttpConstant::DEFAULT_CONNECT_TIMEOUT = 60000;
34 
35 const size_t HttpConstant::MAX_JSON_PARSE_SIZE = 65536;
36 const size_t HttpConstant::MAX_DATA_LIMIT = 100 * 1024 * 1024;
37 
38 const char *const HttpConstant::PARAM_KEY_METHOD = "method";
39 const char *const HttpConstant::PARAM_KEY_EXTRA_DATA = "extraData";
40 const char *const HttpConstant::PARAM_KEY_HEADER = "header";
41 const char *const HttpConstant::PARAM_KEY_READ_TIMEOUT = "readTimeout";
42 const char *const HttpConstant::PARAM_KEY_CONNECT_TIMEOUT = "connectTimeout";
43 const char *const HttpConstant::PARAM_KEY_USING_PROTOCOL = "usingProtocol";
44 const char *const HttpConstant::PARAM_KEY_USING_CACHE = "usingCache";
45 const char *const HttpConstant::PARAM_KEY_EXPECT_DATA_TYPE = "expectDataType";
46 const char *const HttpConstant::PARAM_KEY_PRIORITY = "priority";
47 
48 const char *const HttpConstant::PARAM_KEY_USING_HTTP_PROXY = "usingProxy";
49 const char *const HttpConstant::PARAM_KEY_CA_PATH = "caPath";
50 
51 const char *const HttpConstant::HTTP_PROXY_KEY_HOST = "host";
52 const char *const HttpConstant::HTTP_PROXY_KEY_PORT = "port";
53 const char *const HttpConstant::HTTP_PROXY_KEY_EXCLUSION_LIST = "exclusionList";
54 const char *const HttpConstant::HTTP_PROXY_EXCLUSIONS_SEPARATOR = ",";
55 
56 const char *const HttpConstant::RESPONSE_KEY_RESULT = "result";
57 const char *const HttpConstant::RESPONSE_KEY_RESPONSE_CODE = "responseCode";
58 const char *const HttpConstant::RESPONSE_KEY_HEADER = "header";
59 const char *const HttpConstant::RESPONSE_KEY_COOKIES = "cookies";
60 const char *const HttpConstant::RESPONSE_KEY_RESULT_TYPE = "resultType";
61 
62 const char *const HttpConstant::HTTP_URL_PARAM_START = "?";
63 const char *const HttpConstant::HTTP_URL_PARAM_SEPARATOR = "&";
64 const char *const HttpConstant::HTTP_URL_NAME_VALUE_SEPARATOR = "=";
65 const char *const HttpConstant::HTTP_HEADER_SEPARATOR = ":";
66 const char *const HttpConstant::HTTP_LINE_SEPARATOR = "\r\n";
67 
68 const char *const HttpConstant::HTTP_DEFAULT_USER_AGENT = "libcurl-agent/1.0";
69 
70 #ifdef HTTP_MULTIPATH_CERT_ENABLE
71 const int32_t HttpConstant::UID_TRANSFORM_DIVISOR = 200000;
72 const std::string HttpConstant::USER_CERT_BASE_PATH = "/data/certificates/user_cacerts/";
73 const std::string HttpConstant::USER_CERT_ROOT_PATH = "/data/certificates/user_cacerts/0/";
74 #endif
75 
76 const char *const HttpConstant::HTTP_CONTENT_TYPE = "content-type";
77 const char *const HttpConstant::HTTP_CONTENT_TYPE_URL_ENCODE = "application/x-www-form-urlencoded";
78 const char *const HttpConstant::HTTP_CONTENT_TYPE_JSON = "application/json";
79 const char *const HttpConstant::HTTP_CONTENT_TYPE_OCTET_STREAM = "application/octet-stream";
80 const char *const HttpConstant::HTTP_CONTENT_TYPE_IMAGE = "image";
81 const char *const HttpConstant::HTTP_PREPARE_CA_PATH = "/etc/security/certificates";
82 
83 const char *const HttpConstant::HTTP_CONTENT_ENCODING_GZIP = "gzip";
84 
85 const char *const HttpConstant::REQUEST_TIME = "requestTime";
86 const char *const HttpConstant::RESPONSE_TIME = "responseTime";
87 } // namespace HttpClient
88 } // namespace NetStack
89 } // namespace OHOS