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