1 /*
2  * Copyright (c) 2023-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 COMMUNICATIONNETSTACK_CONSTANT_H
17 #define COMMUNICATIONNETSTACK_CONSTANT_H
18 
19 #include <cstddef>
20 #include <cstdint>
21 #include <string>
22 
23 namespace OHOS {
24 namespace NetStack {
25 namespace HttpClient {
26 
27 class HttpConstant final {
28 public:
29     /* Http Method */
30     static const char *const HTTP_METHOD_GET;
31     static const char *const HTTP_METHOD_HEAD;
32     static const char *const HTTP_METHOD_OPTIONS;
33     static const char *const HTTP_METHOD_TRACE;
34     static const char *const HTTP_METHOD_DELETE;
35     static const char *const HTTP_METHOD_POST;
36     static const char *const HTTP_METHOD_PUT;
37     static const char *const HTTP_METHOD_CONNECT;
38 
39     /* default options */
40     static const uint32_t DEFAULT_READ_TIMEOUT;
41     static const uint32_t DEFAULT_CONNECT_TIMEOUT;
42 
43     static const size_t MAX_JSON_PARSE_SIZE;
44     static const size_t MAX_DATA_LIMIT;
45 
46     /* options key */
47     static const char *const PARAM_KEY_METHOD;
48     static const char *const PARAM_KEY_EXTRA_DATA;
49     static const char *const PARAM_KEY_HEADER;
50     static const char *const PARAM_KEY_READ_TIMEOUT;
51     static const char *const PARAM_KEY_CONNECT_TIMEOUT;
52     static const char *const PARAM_KEY_USING_PROTOCOL;
53     static const char *const PARAM_KEY_USING_CACHE;
54     static const char *const PARAM_KEY_EXPECT_DATA_TYPE;
55     static const char *const PARAM_KEY_PRIORITY;
56     static const char *const PARAM_KEY_CA_PATH;
57     static const char *const HTTP_PREPARE_CA_PATH;
58 
59     static const char *const PARAM_KEY_USING_HTTP_PROXY;
60 
61     static const char *const HTTP_PROXY_KEY_HOST;
62     static const char *const HTTP_PROXY_KEY_PORT;
63     static const char *const HTTP_PROXY_KEY_EXCLUSION_LIST;
64     static const char *const HTTP_PROXY_EXCLUSIONS_SEPARATOR;
65 
66     static const char *const RESPONSE_KEY_RESULT;
67     static const char *const RESPONSE_KEY_RESPONSE_CODE;
68     static const char *const RESPONSE_KEY_HEADER;
69     static const char *const RESPONSE_KEY_COOKIES;
70     static const char *const RESPONSE_KEY_RESULT_TYPE;
71 
72     static const char *const HTTP_URL_PARAM_START;
73     static const char *const HTTP_URL_PARAM_SEPARATOR;
74     static const char *const HTTP_URL_NAME_VALUE_SEPARATOR;
75     static const char *const HTTP_HEADER_SEPARATOR;
76     static const char *const HTTP_LINE_SEPARATOR;
77 
78     static const char *const HTTP_DEFAULT_USER_AGENT;
79 
80 #ifdef HTTP_MULTIPATH_CERT_ENABLE
81     static const int32_t UID_TRANSFORM_DIVISOR;
82     static const std::string USER_CERT_BASE_PATH;
83     static const std::string USER_CERT_ROOT_PATH;
84 #endif
85 
86     static const char *const HTTP_CONTENT_TYPE;
87     static const char *const HTTP_CONTENT_TYPE_URL_ENCODE;
88     static const char *const HTTP_CONTENT_TYPE_JSON;
89     static const char *const HTTP_CONTENT_TYPE_OCTET_STREAM;
90     static const char *const HTTP_CONTENT_TYPE_IMAGE;
91 
92     static const char *const HTTP_CONTENT_ENCODING_GZIP;
93 
94     static const char *const REQUEST_TIME;
95     static const char *const RESPONSE_TIME;
96 };
97 } // namespace HttpClient
98 } // namespace NetStack
99 } // namespace OHOS
100 
101 #endif /* COMMUNICATIONNETSTACK_CONSTANT_H */
102