From 32387173ddd69e256317a2d864776f9d8bd7f071 Mon Sep 17 00:00:00 2001 From: liuleimin_hw Date: Fri, 23 May 2025 16:17:20 +0800 Subject: [PATCH 01/13] =?UTF-8?q?HTTP=20C=E6=8E=A5=E5=8F=A3=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuleimin_hw --- network/netstack/net_http/BUILD.gn | 34 + .../netstack/net_http/libnet_http.ndk.json | 38 ++ network/netstack/net_http/net_http.h | 155 +++++ network/netstack/net_http/net_http_type.h | 606 ++++++++++++++++++ 4 files changed, 833 insertions(+) create mode 100644 network/netstack/net_http/BUILD.gn create mode 100644 network/netstack/net_http/libnet_http.ndk.json create mode 100644 network/netstack/net_http/net_http.h create mode 100644 network/netstack/net_http/net_http_type.h diff --git a/network/netstack/net_http/BUILD.gn b/network/netstack/net_http/BUILD.gn new file mode 100644 index 000000000..c13c6ad39 --- /dev/null +++ b/network/netstack/net_http/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") + +ohos_ndk_library("libnet_http") { + output_name = "net_http" + output_extension = "so" + ndk_description_file = "./libnet_http.ndk.json" + min_compact_version = "1" + system_capability = "SystemCapability.Communication.NetStack" + system_capability_headers = [ + "network/netstack/net_http.h", + "network/netstack/net_http_type.h", + ] +} + +ohos_ndk_headers("nethttp_header") { + dest_dir = "$ndk_headers_out_dir/network/netstack" + sources = [ + "net_http.h", + "net_http_type.h", + ] +} \ No newline at end of file diff --git a/network/netstack/net_http/libnet_http.ndk.json b/network/netstack/net_http/libnet_http.ndk.json new file mode 100644 index 000000000..5a00aa6f2 --- /dev/null +++ b/network/netstack/net_http/libnet_http.ndk.json @@ -0,0 +1,38 @@ +[ + { + "first_introduced":"20", + "name": "OH_Http_CreateHeaders" + }, + { + "first_introduced":"20", + "name": "OH_Http_DestroyHeaders" + }, + { + "first_introduced":"20", + "name": "OH_Http_SetHeaderValue" + }, + { + "first_introduced":"20", + "name": "OH_Http_CreateRequest" + }, + { + "first_introduced":"20", + "name": "OH_Http_Request" + }, + { + "first_introduced":"20", + "name": "OH_Http_Destroy" + }, + { + "first_introduced":"20", + "name": "OH_Http_GetHeaderValue" + }, + { + "first_introduced":"20", + "name": "OH_Http_GetHeaderEntries" + }, + { + "first_introduced":"20", + "name": "OH_Http_DestroyHeaderEntries" + } +] \ No newline at end of file diff --git a/network/netstack/net_http/net_http.h b/network/netstack/net_http/net_http.h new file mode 100644 index 000000000..25cf8a3d9 --- /dev/null +++ b/network/netstack/net_http/net_http.h @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup netstack + * @{ + * + * @brief Defines the APIs for http. + * + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @version 1.0 + */ + +/** + * @file net_http.h + * @brief Defines the APIs for http. + * + * @library libnet_http.so + * @kit NetworkKit + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @version 1.0 + */ + +#ifndef NET_HTTP_H +#define NET_HTTP_H + +#include +#include + +#include "net_http_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates headers for a request or response. + * + * @return Http_Headers* Pointer to {@link Http_Headers}. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @version 1.0 + */ +Http_Headers *OH_Http_CreateHeaders(void); + +/** + * @brief Destroys the headers of a request or response. + * + * @param headers Pointer to the {@link Http_Headers} to be destroyed. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @version 1.0 + */ +void OH_Http_DestroyHeaders(Http_Headers **headers); + +/** + * @brief Sets the key-value pair of the request or response header. + * + * @param headers Pointer to the {@link Http_Headers} to be set. + * @param name Key. + * @param value Value. + * @return uint32_t 0 - success. 401 - Parameter error. 2300027 - Out of memory. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @version 1.0 + */ +uint32_t OH_Http_SetHeaderValue(struct Http_Headers *headers, const char *name, const char *value); + +/** + * @brief Obtains the value of a request or response header by key. + * + * @param headers Pointer to {@link Http_Headers}. + * @param name Key. + * @return Http_HeaderValue* Pointer to the obtained {@link Http_HeaderValue}. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @version 1.0 + */ +Http_HeaderValue *OH_Http_GetHeaderValue(Http_Headers *headers, const char *name); + +/** + * @brief Obtains all the key-value pairs of a request or response header. + * + * @param headers Pointer to {@link Http_Headersaders}. + * @return Http_HeaderEntry* Pointers to all obtained key-value pairs {@link Http_HeaderEntry}. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @version 1.0 + */ +Http_HeaderEntry *OH_Http_GetHeaderEntries(Http_Headers *headers); + +/** + * @brief Destroys all key-value pairs obtained in {@link OH_Http_GetHeaderEntries}. + * + * @param headerEntry Pointer to the {@link Http_HeaderEntry} to be destroyed. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @version 1.0 + */ +void OH_Http_DestroyHeaderEntries(Http_HeaderEntry **headerEntry); + +/** + * @brief Create a http request. + * + * @param url Http request url. + * @return Pointer of HttpRequest if success; Null otherwise. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @version 1.0 + */ +Http_Request *OH_Http_CreateRequest(const char *url); + +/** + * @brief Initiates an HTTP request. + * + * @param request Pointer to {@link Http_Request}. + * @param callback Http response info, pointer to {@link Http_ResponseCallback} + * @param handler Callbacks to watch different events, pointer to {@link Http_EventsHandler}. + * @return 0 if success; non-0 otherwise. For details about error codes, see {@link Http_ErrCode}. + * @permission ohos.permission.INTERNET + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @version 1.0 + */ +int OH_Http_Request(Http_Request *request, Http_ResponseCallback callback, Http_EventsHandler handler); + +/** + * @brief Destroy the HTTP request. + * + * @param request Pointer to the http request {@link Http_Request}. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @version 1.0 + */ +void OH_Http_Destroy(struct Http_Request **request); +#ifdef __cplusplus +} +#endif +#endif // NET_HTTP_H + +/** @} */ \ No newline at end of file diff --git a/network/netstack/net_http/net_http_type.h b/network/netstack/net_http/net_http_type.h new file mode 100644 index 000000000..0019faf84 --- /dev/null +++ b/network/netstack/net_http/net_http_type.h @@ -0,0 +1,606 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup netstack + * @{ + * + * @brief Provides C APIs for the Http client module. + * + * @since 20 + * @version 1.0 + */ + +/** + * @file net_http_type.h + * @brief Defines the data structure for the C APIs of the http module. + * + * @library libnet_http.so + * @kit NetworkKit + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @version 1.0 + */ + +#ifndef NET_HTTP_TYPE_H +#define NET_HTTP_TYPE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define OHOS_HTTP_MAX_PATH_LEN 128 +#define OHOS_HTTP_MAX_STR_LEN 256 +#define OHOS_HTTP_DNS_SERVER_NUM_MAX 3 + +/** + * @brief Defines http error code. + * + * @since 20 + * @version 1.0 + */ +typedef enum Http_ErrCode { + /** Operation success. */ + RESULT_OK = 0, + /** @brief Parameter error. */ + PARAMETER_ERROR = 401, + /** @brief Permission denied. */ + PERMISSION_DENIED = 201, + /** @brief Error code base. */ + NETSTACK_E_BASE = 2300000, + /** @brief Unsupported protocol. */ + UNSUPPORTED_PROTOCOL = (NETSTACK_E_BASE + 1), + /** @brief Invalid URL format or missing URL. */ + INVALID_URL = (NETSTACK_E_BASE + 3), + /** @brief Failed to resolve the proxy name. */ + RESOLVE_PROXY_FAILED = (NETSTACK_E_BASE + 5), + /** @brief Failed to resolve the host name. */ + RESOLVE_HOST_FAILED = (NETSTACK_E_BASE + 6), + /** @brief Failed to connect to the server. */ + CONNECT_SERVER_FAILED = (NETSTACK_E_BASE + 7), + /** @brief Invalid server response. */ + INVALID_SERVER_RESPONSE = (NETSTACK_E_BASE + 8), + /** @brief Access to the remote resource denied. */ + ACCESS_REMOTE_DENIED = (NETSTACK_E_BASE + 9), + /** @brief Error in the HTTP2 framing layer. */ + HTTP2_FRAMING_ERROR = (NETSTACK_E_BASE + 16), + /** @brief Transferred a partial file. */ + TRANSFER_PARTIAL_FILE = (NETSTACK_E_BASE + 18), + /** @brief Failed to write the received data to the disk or application. */ + WRITE_DATA_FAILED = (NETSTACK_E_BASE + 23), + /** @brief Upload failed. */ + UPLOAD_FAILED = (NETSTACK_E_BASE + 25), + /** @brief Failed to open or read local data from the file or application. */ + OPEN_LOCAL_DATA_FAILED = (NETSTACK_E_BASE + 26), + /** @brief Out of memory. */ + OUT_OF_MEMORY = (NETSTACK_E_BASE + 27), + /** @brief Operation timeout. */ + OPERATION_TIMEOUT = (NETSTACK_E_BASE + 28), + /** @brief The number of redirections reaches the maximum allowed. */ + REDIRECTIONS_TOO_LARGE = (NETSTACK_E_BASE + 47), + /** @brief The server returned nothing (no header or data). */ + SERVER_RETURNED_NOTHING = (NETSTACK_E_BASE + 52), + /** @brief Failed to send data to the peer. */ + SEND_DATA_FAILED = (NETSTACK_E_BASE + 55), + /** @brief Failed to receive data from the peer. */ + RECEIVE_DATA_FAILED = (NETSTACK_E_BASE + 56), + /** @brief Local SSL certificate error. */ + SSL_CERTIFICATE_ERROR = (NETSTACK_E_BASE + 58), + /** @brief The specified SSL cipher cannot be used. */ + SSL_CIPHER_USED_ERROR = (NETSTACK_E_BASE + 59), + /** @brief Invalid SSL peer certificate or SSH remote key. */ + INVALID_SSL_PEER_CERT = (NETSTACK_E_BASE + 60), + /** @brief Invalid HTTP encoding format. */ + INVALID_ENCODING_FORMAT = (NETSTACK_E_BASE + 61), + /** @brief Maximum file size exceeded. */ + FILE_TOO_LARGE = (NETSTACK_E_BASE + 63), + /** @brief Remote disk full. */ + REMOTE_DISK_FULL = (NETSTACK_E_BASE + 70), + /** @brief Remote file already exists. */ + REMOTE_FILE_EXISTS = (NETSTACK_E_BASE + 73), + /** @brief The SSL CA certificate does not exist or is inaccessible. */ + SSL_CA_NOT_EXIST = (NETSTACK_E_BASE + 77), + /** @brief Remote file not found. */ + REMOTE_FILE_NOT_FOUND = (NETSTACK_E_BASE + 78), + /** @brief Authentication error. */ + AUTHENTICATION_ERROR = (NETSTACK_E_BASE + 94), + /** @brief It is not allowed to access this domain. */ + ACCESS_DOMAIN_NOT_ALLOWED = (NETSTACK_E_BASE + 998), + /** @brief Unknown error. */ + UNKNOWN_ERROR = (NETSTACK_E_BASE + 999) +} Http_ErrCode; + +/** + * @brief Defines http response code. + * + * @since 20 + * @version 1.0 + */ +typedef enum Http_ResponseCode { + /** @brief The request was successful. */ + HTTP_OK = 200, + /** @brief Successfully requested and created a new resource. */ + CREATED = 201, + /** @brief The request has been accepted but has not been processed completely. */ + ACCEPTED = 202, + /** @brief Unauthorized information. The request was successful. */ + NOT_AUTHORITATIVE = 203, + /** @brief No content. The server successfully processed, but did not return content. */ + NO_CONTENT = 204, + /** @brief Reset the content. */ + RESET = 205, + /** @brief Partial content. The server successfully processed some GET requests. */ + PARTIAL = 206, + /** @brief Multiple options. */ + MULT_CHOICE = 300, + /** + * @brief Permanently move. The requested resource has been permanently moved to a new URI, + * and the returned information will include the new URI. The browser will automatically redirect to the new URI. + */ + MOVED_PERM = 301, + /** @brief Temporary movement. */ + MOVED_TEMP = 302, + /** @brief View other addresses. */ + SEE_OTHER = 303, + /** @brief Not modified. */ + NOT_MODIFIED = 304, + /** @brief Using proxies. */ + USE_PROXY = 305, + /** @brief The server cannot understand the syntax error error requested by the client. */ + BAD_REQUEST = 400, + /** @brief Request for user authentication. */ + UNAUTHORIZED = 401, + /** @brief Reserved for future use. */ + PAYMENT_REQUIRED = 402, + /** @brief The server understands the request from the requesting client, but refuses to execute it. */ + FORBIDDEN = 403, + /** @brief The server was unable to find resources (web pages) based on the client's request. */ + NOT_FOUND = 404, + /** @brief The method in the client request is prohibited. */ + BAD_METHOD = 405, + /** @brief The server unabled to complete request based on the content characteristics requested by the client. */ + NOT_ACCEPTABLE = 406, + /** @brief Request authentication of the proxy's identity. */ + PROXY_AUTH = 407, + /** @brief The request took too long and timed out. */ + CLIENT_TIMEOUT = 408, + /** + * @brief The server may have returned this code when completing the client's PUT request, + * as there was a conflict when the server was processing the request. + */ + CONFLICT = 409, + /** @brief The resource requested by the client no longer exists. */ + GONE = 410, + /** @brief The server is unable to process request information sent by the client without Content Length. */ + LENGTH_REQUIRED = 411, + /** @brief The prerequisite for requesting information from the client is incorrect. */ + PRECON_FAILED = 412, + /** @brief The request was rejected because the requested entity was too large for the server to process. */ + ENTITY_TOO_LARGE = 413, + /** @brief The requested URI is too long (usually a URL) and the server cannot process it. */ + REQ_TOO_LONG = 414, + /** @brief The server is unable to process the requested format. */ + UNSUPPORTED_TYPE = 415, + /** @brief Requested Range not satisfiable. */ + RANGE_NOT_SATISFIABLE = 416, + /** @brief Internal server error, unable to complete the request. */ + INTERNAL_ERROR = 500, + /** @brief * The server does not support the requested functionality and cannot complete the request. */ + NOT_IMPLEMENTED = 501, + /** @brief The server acting as a gateway or proxy received an invalid request from the remote server. */ + BAD_GATEWAY = 502, + /** @brief Due to overload or system maintenance, the server is temporarily unable to process client requests. */ + UNAVAILABLE = 503, + /** @brief The server acting as gateway did not obtain requests from the remote server in a timely manner. */ + GATEWAY_TIMEOUT = 504, + /** @brief The version of the HTTP protocol requested by the server. */ + VERSION = 505 +} Http_ResponseCode; + +/** + * @brief Buffer. + * + * @since 20 + * @version 1.0 + */ +typedef struct Http_Buffer { + /** Content. Buffer will not be copied. */ + const char *buffer; + /** Buffer length. */ + uint32_t length; +} Http_Buffer; + +/** + * @brief Defines the address Family. + * + * @since 20 + * @version 1.0 + */ +typedef enum Http_AddressFamilyType { + /** Default, The system automatically selects the IPv4 or IPv6 address of the domain name. */ + DEFAULT = 0, + /** IPv4, Selects the IPv4 address of the domain name. */ + ONLY_V4 = 1, + /** IPv6, Selects the IPv4 address of the domain name. */ + ONLY_V6 = 2 +} Http_AddressFamilyType; + +/** + * @brief HTTP get method. + * + * @since 20 + * @version 1.0 + */ +#define NET_HTTP_METHOD_GET "GET" + +/** + * @brief HTTP head method. + * + * @since 20 + * @version 1.0 + */ +#define NET_HTTPMETHOD_HEAD "HEAD" + +/** + * @brief HTTP options method. + * + * @since 20 + * @version 1.0 + */ +#define NET_HTTPMETHOD_OPTIONS "OPTIONS" + +/** + * @brief HTTP trace method. + * + * @since 20 + * @version 1.0 + */ +#define NET_HTTPMETHOD_TRACE "TRACE" +/** + * @brief HTTP delete method. + * @since 20 + * @version 1.0 + */ +#define NET_HTTPMETHOD_DELETE "DELETE" + +/** + * @brief HTTP post method. + * + * @since 20 + * @version 1.0 + */ +#define NET_HTTP_METHOD_POST "POST" + +/** + * @brief HTTP put method. + * + * @since 20 + * @version 1.0 + */ +#define NET_HTTP_METHOD_PUT "PUT" + +/** + * @brief HTTP connect method. + * + * @since 20 + * @version 1.0 + */ +#define NET_HTTP_METHOD_PATCH "CONNECT" + +/** + * @brief Defines the HTTP version. + * + * @since 20 + * @version 1.0 + */ +typedef enum Http_HttpProtocol { + /** Default choose by curl. */ + HTTP_NONE = 0, + /** HTTP 1.1 version. */ + HTTP1_1, + /** HTTP 2 version. */ + HTTP2, + /** HTTP 3 version. */ + HTTP3 +} Http_HttpProtocol; + +/** + * @brief Defines the Cert Type. + * + * @since 20 + * @version 1.0 + */ +typedef enum Http_CertType { + /** PEM Cert Type. */ + PEM = 0, + /** DER Cert Type. */ + DER = 1, + /** P12 Cert Type. */ + P12 = 2 +} Http_CertType; + +/** + * @brief Headers of the request or response. + * + * @since 20 + * @version 1.0 + */ +typedef struct Http_Headers Http_Headers; + +/** + * @brief The value type of the header map of the request or response. + * + * @since 20 + * @version 1.0 + */ +typedef struct Http_HeaderValue { + /** Value. */ + char *value; + /** Point to the next {@link Http_HeaderValue}. */ + struct Http_HeaderValue *next; +} Http_HeaderValue; + +/** + * @brief All key-value pairs of the headers of the request or response. + * + * @since 20 + * @version 1.0 + */ +typedef struct Http_HeaderEntry { + /** Key. */ + char *key; + /** Value, see {@link Http_HeaderValue}. */ + Http_HeaderValue *value; + /** Points to the next key-value pair {@link Http_HeaderEntry} */ + struct Http_HeaderEntry *next; +} Http_HeaderEntry; + +/** + * @brief Client certificate which is sent to the remote server, the the remote server will use it to verify the + * client's identification. + * + * @since 20 + * @version 1.0 + */ +typedef struct Http_ClientCert { + /** A path to a client certificate. */ + char *certPath; + /** Client certificate type, see {@link Http_CertType}. */ + Http_CertType type; + /** File path of your client certificate private key. */ + char *keyPath; + /** Password for your client certificate private key. */ + char *keyPassword; +} Http_ClientCert; + +/** + * @brief Proxy type. Used to distinguish different proxy configurations. + * + * @since 20 + * @version 1.0 + */ +typedef enum Http_ProxyType { + /** No proxy */ + HTTP_PROXY_NOT_USE, + /** System proxy */ + HTTP_PROXY_SYSTEM, + /** Use custom proxy */ + HTTP_PROXY_CUSTOM +} Http_ProxyType; + +/** + * @brief Custom proxy configuration. + * + * @since 20 + * @version 1.0 + */ +typedef struct Http_CustomProxy { + /** Indicates the URL of the proxy server. If you do not set port explicitly, port will be 1080. */ + const char *host; + int32_t port; + const char *exclusionLists; +} Http_CustomProxy; + +/** + * @brief Proxy configuration. + * + * @since 20 + * @version 1.0 + */ +typedef struct Http_Proxy { + /** Distinguish the proxy type used by the request, see {@link Http_ProxyType}. */ + Http_ProxyType proxyType; + /** Custom proxy configuration, see {@link Http_CustomProxy}. */ + Http_CustomProxy customProxy; +} Http_Proxy; + +/** + * @brief Response timing information. It will be collected in {@link Http_Response.performanceTiming}. + * + * @since 20 + * @version 1.0 + */ +typedef struct Http_PerformanceTiming { + /** The total time in milliseconds for the HTTP transfer, including name resolving, TCP connect etc. */ + double dnsTiming; + /** The time in milliseconds from the start until the remote host name was resolved. */ + double tcpTiming; + /** The time in milliseconds from the start until the connection to the remote host (or proxy) was completed. */ + double tlsTiming; + /** The time in milliseconds, it took from the start until the transfer is just about to begin. */ + double firstSendTiming; + /** The time in milliseconds from last modification time of the remote file. */ + double firstReceiveTiming; + /** The time in milliseconds, it took from the start until the first byte is received. */ + double totalFinishTiming; + /** The time in milliseconds it took for all redirection steps including name lookup, connect, etc.*/ + double redirectTiming; +} Http_PerformanceTiming; + +/** + * @brief Defines the parameters for http request options. + * + * @since 20 + * @version 1.0 + */ +typedef struct Http_RequestOptions { + /** Request method. */ + const char *method; + /** Priority of http requests. A larger value indicates a higher priority. */ + uint32_t priority; + /** Header of http requests, see {@link Http_Headers}. */ + Http_Headers *headers; + /** Read timeout interval. */ + uint32_t readTimeout; + /** Connection timeout interval. */ + uint32_t connectTimeout; + /** Use the protocol. The default value is automatically specified by the system, see {@link Http_HttpProtocol}. */ + Http_HttpProtocol httpProtocol; + /** + * Indicates whether to use the HTTP proxy. The default value is false, + * and http proxy config, see {@link Http_Proxy}. + */ + Http_Proxy *httpProxy; + /** CA certificate of the user-specified path. */ + const char *caPath; + /** Set the download start position. This parameter can be used only in the GET method. */ + int64_t resumeFrom; + /** Set the download end position. This parameter can be used only in the GET method. */ + int64_t resumeTo; + /** Client certificates can be transferred, see {@link Http_ClientCert}. */ + Http_ClientCert *clientCert; + /** Set the DNS resolution for the https server. */ + const char *dnsOverHttps; + /** Maximum number of bytes in a response message. */ + uint32_t maxLimit; + /** The address family can be specified when target domain name is resolved, see {@link Http_AddressFamilyType}. */ + Http_AddressFamilyType addressFamily; +} Http_RequestOptions; + +/** + * @brief Defines the parameters for http response. + * + * @since 20 + * @version 1.0 + */ +typedef struct Http_Response { + /** Response body, see {@link Http_Buffer}. */ + Http_Buffer body; + /** Server status code, see {@link Http_ResponseCode}. */ + Http_ResponseCode responseCode; + /** Header of http response, see {@link Http_Headers}. */ + Http_Headers *headers; + /** Cookies returned by the server. */ + char *cookies; + /** The time taken of various stages of HTTP request, see {@link Http_PerformanceTiming}. */ + Http_PerformanceTiming *performanceTiming; + /** + * @brief Response deletion function. + * + * @param response Indicates the response to be deleted. It is a pointer that points to {@link Http_Response}. + * @since 20 + * @version 1.0 + */ + void (*destroyResponse)(struct Http_Response **response); +} Http_Response; + +/** + * @brief Http request. + * + * @since 20 + * @version 1.0 + */ +typedef struct Http_Request { + /** The request id for every single request. Generated by system. */ + uint32_t requestId; + /** Request url. */ + char *url; + /** Request options, see {@link Http_RequestOptions}. */ + Http_RequestOptions *options; +} Http_Request; + +/** + * @brief Callback function that is invoked when response is received. + * + * @param response Http response struct, see {@link Http_Response}. + * @param errCode Response error code. + * @since 20 + * @version 1.0 + */ +typedef void (*Http_ResponseCallback)(struct Http_Response *response, uint32_t errCode); + +/** + * @brief Callback function that is invoked when a response body is received. + * + * @param data Response body. + * @return size_t the length of response body. + * @since 20 + * @version 1.0 + */ +typedef size_t (*Http_OnDataReceiveCallback)(const char *data); + +/** + * @brief Callback function invoked during request/response data transmission. + * + * @param totalSize total size. + * @param transferredSize transferred size. + * @since 20 + * @version 1.0 + */ +typedef void (*Http_OnProgressCallback)(uint64_t totalSize, uint64_t transferredSize); + +/** + * @brief Callback called when header are received. + * + * @param headers Headers of the received requests, which points to the pointer of {@link Http_Headers}. + * @since 20 + * @version 1.0 + */ +typedef void (*Http_OnHeaderReceiveCallback)(Http_Headers *headers); + +/** + * @brief Empty callback function for requested DataEnd or Canceled event callback。 + * + * @since 20 + * @version 1.0 + */ +typedef void (*Http_OnVoidCallback)(void); + +/** + * @brief Callbacks to watch different events. + * + * @since 20 + * @version 1.0 + */ +typedef struct Http_EventsHandler { + /** Callback function when the response body is received */ + Http_OnDataReceiveCallback onDataReceive; + /** Callback function during uploading */ + Http_OnProgressCallback onUploadProgress; + /** Callback function during downloading */ + Http_OnProgressCallback onDownloadProgress; + /** Callback function when a header is received */ + Http_OnHeaderReceiveCallback onHeadersReceive; + /** Callback function at the end of the transfer */ + Http_OnVoidCallback onDataEnd; + /** Callback function when a request is canceled */ + Http_OnVoidCallback onCanceled; +} Http_EventsHandler; +#ifdef __cplusplus +} +#endif +#endif // NET_HTTP_TYPE_H + +/** @} */ \ No newline at end of file -- Gitee From e0c96f6cd957eccaad2c4700da4720809f261d1c Mon Sep 17 00:00:00 2001 From: liuleimin_hw Date: Fri, 23 May 2025 09:19:29 +0000 Subject: [PATCH 02/13] update network/netstack/net_http/BUILD.gn. Signed-off-by: liuleimin_hw --- network/netstack/net_http/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/netstack/net_http/BUILD.gn b/network/netstack/net_http/BUILD.gn index c13c6ad39..1e9517228 100644 --- a/network/netstack/net_http/BUILD.gn +++ b/network/netstack/net_http/BUILD.gn @@ -31,4 +31,4 @@ ohos_ndk_headers("nethttp_header") { "net_http.h", "net_http_type.h", ] -} \ No newline at end of file +} -- Gitee From d1bed85851c1cbca0f492f813a5df8049c05a698 Mon Sep 17 00:00:00 2001 From: liuleimin_hw Date: Mon, 26 May 2025 09:29:51 +0000 Subject: [PATCH 03/13] update network/netstack/net_http/net_http_type.h. Signed-off-by: liuleimin_hw --- network/netstack/net_http/net_http_type.h | 172 +++++++++------------- 1 file changed, 69 insertions(+), 103 deletions(-) diff --git a/network/netstack/net_http/net_http_type.h b/network/netstack/net_http/net_http_type.h index 0019faf84..ff83f1a35 100644 --- a/network/netstack/net_http/net_http_type.h +++ b/network/netstack/net_http/net_http_type.h @@ -20,7 +20,6 @@ * @brief Provides C APIs for the Http client module. * * @since 20 - * @version 1.0 */ /** @@ -31,7 +30,6 @@ * @kit NetworkKit * @syscap SystemCapability.Communication.NetStack * @since 20 - * @version 1.0 */ #ifndef NET_HTTP_TYPE_H @@ -49,171 +47,168 @@ extern "C" { * @brief Defines http error code. * * @since 20 - * @version 1.0 */ typedef enum Http_ErrCode { /** Operation success. */ - RESULT_OK = 0, + HTTP_RESULT_OK = 0, /** @brief Parameter error. */ - PARAMETER_ERROR = 401, + HTTP_PARAMETER_ERROR = 401, /** @brief Permission denied. */ - PERMISSION_DENIED = 201, + HTTP_PERMISSION_DENIED = 201, /** @brief Error code base. */ - NETSTACK_E_BASE = 2300000, + HTTP_NETSTACK_E_BASE = 2300000, /** @brief Unsupported protocol. */ - UNSUPPORTED_PROTOCOL = (NETSTACK_E_BASE + 1), + HTTP_UNSUPPORTED_PROTOCOL = (NETSTACK_E_BASE + 1), /** @brief Invalid URL format or missing URL. */ - INVALID_URL = (NETSTACK_E_BASE + 3), + HTTP_INVALID_URL = (NETSTACK_E_BASE + 3), /** @brief Failed to resolve the proxy name. */ - RESOLVE_PROXY_FAILED = (NETSTACK_E_BASE + 5), + HTTP_RESOLVE_PROXY_FAILED = (NETSTACK_E_BASE + 5), /** @brief Failed to resolve the host name. */ - RESOLVE_HOST_FAILED = (NETSTACK_E_BASE + 6), + HTTP_RESOLVE_HOST_FAILED = (NETSTACK_E_BASE + 6), /** @brief Failed to connect to the server. */ - CONNECT_SERVER_FAILED = (NETSTACK_E_BASE + 7), + HTTP_CONNECT_SERVER_FAILED = (NETSTACK_E_BASE + 7), /** @brief Invalid server response. */ - INVALID_SERVER_RESPONSE = (NETSTACK_E_BASE + 8), + HTTP_INVALID_SERVER_RESPONSE = (NETSTACK_E_BASE + 8), /** @brief Access to the remote resource denied. */ - ACCESS_REMOTE_DENIED = (NETSTACK_E_BASE + 9), + HTTP_ACCESS_REMOTE_DENIED = (NETSTACK_E_BASE + 9), /** @brief Error in the HTTP2 framing layer. */ - HTTP2_FRAMING_ERROR = (NETSTACK_E_BASE + 16), + HTTP_HTTP2_FRAMING_ERROR = (NETSTACK_E_BASE + 16), /** @brief Transferred a partial file. */ - TRANSFER_PARTIAL_FILE = (NETSTACK_E_BASE + 18), + HTTP_TRANSFER_PARTIAL_FILE = (NETSTACK_E_BASE + 18), /** @brief Failed to write the received data to the disk or application. */ - WRITE_DATA_FAILED = (NETSTACK_E_BASE + 23), + HTTP_WRITE_DATA_FAILED = (NETSTACK_E_BASE + 23), /** @brief Upload failed. */ - UPLOAD_FAILED = (NETSTACK_E_BASE + 25), + HTTP_UPLOAD_FAILED = (NETSTACK_E_BASE + 25), /** @brief Failed to open or read local data from the file or application. */ - OPEN_LOCAL_DATA_FAILED = (NETSTACK_E_BASE + 26), + HTTP_OPEN_LOCAL_DATA_FAILED = (NETSTACK_E_BASE + 26), /** @brief Out of memory. */ - OUT_OF_MEMORY = (NETSTACK_E_BASE + 27), + HTTP_OUT_OF_MEMORY = (NETSTACK_E_BASE + 27), /** @brief Operation timeout. */ - OPERATION_TIMEOUT = (NETSTACK_E_BASE + 28), + HTTP_OPERATION_TIMEOUT = (NETSTACK_E_BASE + 28), /** @brief The number of redirections reaches the maximum allowed. */ - REDIRECTIONS_TOO_LARGE = (NETSTACK_E_BASE + 47), + HTTP_REDIRECTIONS_TOO_LARGE = (NETSTACK_E_BASE + 47), /** @brief The server returned nothing (no header or data). */ - SERVER_RETURNED_NOTHING = (NETSTACK_E_BASE + 52), + HTTP_SERVER_RETURNED_NOTHING = (NETSTACK_E_BASE + 52), /** @brief Failed to send data to the peer. */ - SEND_DATA_FAILED = (NETSTACK_E_BASE + 55), + HTTP_SEND_DATA_FAILED = (NETSTACK_E_BASE + 55), /** @brief Failed to receive data from the peer. */ - RECEIVE_DATA_FAILED = (NETSTACK_E_BASE + 56), + HTTP_RECEIVE_DATA_FAILED = (NETSTACK_E_BASE + 56), /** @brief Local SSL certificate error. */ - SSL_CERTIFICATE_ERROR = (NETSTACK_E_BASE + 58), + HTTP_SSL_CERTIFICATE_ERROR = (NETSTACK_E_BASE + 58), /** @brief The specified SSL cipher cannot be used. */ - SSL_CIPHER_USED_ERROR = (NETSTACK_E_BASE + 59), + HTTP_SSL_CIPHER_USED_ERROR = (NETSTACK_E_BASE + 59), /** @brief Invalid SSL peer certificate or SSH remote key. */ - INVALID_SSL_PEER_CERT = (NETSTACK_E_BASE + 60), + HTTP_INVALID_SSL_PEER_CERT = (NETSTACK_E_BASE + 60), /** @brief Invalid HTTP encoding format. */ - INVALID_ENCODING_FORMAT = (NETSTACK_E_BASE + 61), + HTTP_INVALID_ENCODING_FORMAT = (NETSTACK_E_BASE + 61), /** @brief Maximum file size exceeded. */ - FILE_TOO_LARGE = (NETSTACK_E_BASE + 63), + HTTP_FILE_TOO_LARGE = (NETSTACK_E_BASE + 63), /** @brief Remote disk full. */ - REMOTE_DISK_FULL = (NETSTACK_E_BASE + 70), + HTTP_REMOTE_DISK_FULL = (NETSTACK_E_BASE + 70), /** @brief Remote file already exists. */ - REMOTE_FILE_EXISTS = (NETSTACK_E_BASE + 73), + HTTP_REMOTE_FILE_EXISTS = (NETSTACK_E_BASE + 73), /** @brief The SSL CA certificate does not exist or is inaccessible. */ - SSL_CA_NOT_EXIST = (NETSTACK_E_BASE + 77), + HTTP_SSL_CA_NOT_EXIST = (NETSTACK_E_BASE + 77), /** @brief Remote file not found. */ - REMOTE_FILE_NOT_FOUND = (NETSTACK_E_BASE + 78), + HTTP_REMOTE_FILE_NOT_FOUND = (NETSTACK_E_BASE + 78), /** @brief Authentication error. */ - AUTHENTICATION_ERROR = (NETSTACK_E_BASE + 94), + HTTP_AUTHENTICATION_ERROR = (NETSTACK_E_BASE + 94), /** @brief It is not allowed to access this domain. */ - ACCESS_DOMAIN_NOT_ALLOWED = (NETSTACK_E_BASE + 998), + HTTP_ACCESS_DOMAIN_NOT_ALLOWED = (NETSTACK_E_BASE + 998), /** @brief Unknown error. */ - UNKNOWN_ERROR = (NETSTACK_E_BASE + 999) + HTTP_UNKNOWN_ERROR = (NETSTACK_E_BASE + 999) } Http_ErrCode; /** * @brief Defines http response code. * * @since 20 - * @version 1.0 */ typedef enum Http_ResponseCode { /** @brief The request was successful. */ HTTP_OK = 200, /** @brief Successfully requested and created a new resource. */ - CREATED = 201, + HTTP_CREATED = 201, /** @brief The request has been accepted but has not been processed completely. */ - ACCEPTED = 202, + HTTP_ACCEPTED = 202, /** @brief Unauthorized information. The request was successful. */ - NOT_AUTHORITATIVE = 203, + HTTP_NOT_AUTHORITATIVE = 203, /** @brief No content. The server successfully processed, but did not return content. */ - NO_CONTENT = 204, + HTTP_NO_CONTENT = 204, /** @brief Reset the content. */ - RESET = 205, + HTTP_RESET = 205, /** @brief Partial content. The server successfully processed some GET requests. */ - PARTIAL = 206, + HTTP_PARTIAL = 206, /** @brief Multiple options. */ - MULT_CHOICE = 300, + HTTP_MULT_CHOICE = 300, /** * @brief Permanently move. The requested resource has been permanently moved to a new URI, * and the returned information will include the new URI. The browser will automatically redirect to the new URI. */ - MOVED_PERM = 301, + HTTP_MOVED_PERM = 301, /** @brief Temporary movement. */ - MOVED_TEMP = 302, + HTTP_MOVED_TEMP = 302, /** @brief View other addresses. */ - SEE_OTHER = 303, + HTTP_SEE_OTHER = 303, /** @brief Not modified. */ - NOT_MODIFIED = 304, + HTTP_NOT_MODIFIED = 304, /** @brief Using proxies. */ - USE_PROXY = 305, + HTTP_USE_PROXY = 305, /** @brief The server cannot understand the syntax error error requested by the client. */ - BAD_REQUEST = 400, + HTTP_BAD_REQUEST = 400, /** @brief Request for user authentication. */ - UNAUTHORIZED = 401, + HTTP_UNAUTHORIZED = 401, /** @brief Reserved for future use. */ - PAYMENT_REQUIRED = 402, + HTTP_PAYMENT_REQUIRED = 402, /** @brief The server understands the request from the requesting client, but refuses to execute it. */ - FORBIDDEN = 403, + HTTP_FORBIDDEN = 403, /** @brief The server was unable to find resources (web pages) based on the client's request. */ - NOT_FOUND = 404, + HTTP_NOT_FOUND = 404, /** @brief The method in the client request is prohibited. */ - BAD_METHOD = 405, + HTTP_BAD_METHOD = 405, /** @brief The server unabled to complete request based on the content characteristics requested by the client. */ - NOT_ACCEPTABLE = 406, + HTTP_NOT_ACCEPTABLE = 406, /** @brief Request authentication of the proxy's identity. */ - PROXY_AUTH = 407, + HTTP_PROXY_AUTH = 407, /** @brief The request took too long and timed out. */ - CLIENT_TIMEOUT = 408, + HTTP_CLIENT_TIMEOUT = 408, /** * @brief The server may have returned this code when completing the client's PUT request, * as there was a conflict when the server was processing the request. */ - CONFLICT = 409, + HTTP_CONFLICT = 409, /** @brief The resource requested by the client no longer exists. */ - GONE = 410, + HTTP_GONE = 410, /** @brief The server is unable to process request information sent by the client without Content Length. */ - LENGTH_REQUIRED = 411, + HTTP_LENGTH_REQUIRED = 411, /** @brief The prerequisite for requesting information from the client is incorrect. */ - PRECON_FAILED = 412, + HTTP_PRECON_FAILED = 412, /** @brief The request was rejected because the requested entity was too large for the server to process. */ - ENTITY_TOO_LARGE = 413, + HTTP_ENTITY_TOO_LARGE = 413, /** @brief The requested URI is too long (usually a URL) and the server cannot process it. */ - REQ_TOO_LONG = 414, + HTTP_REQ_TOO_LONG = 414, /** @brief The server is unable to process the requested format. */ - UNSUPPORTED_TYPE = 415, + HTTP_UNSUPPORTED_TYPE = 415, /** @brief Requested Range not satisfiable. */ - RANGE_NOT_SATISFIABLE = 416, + HTTP_RANGE_NOT_SATISFIABLE = 416, /** @brief Internal server error, unable to complete the request. */ - INTERNAL_ERROR = 500, + HTTP_INTERNAL_ERROR = 500, /** @brief * The server does not support the requested functionality and cannot complete the request. */ - NOT_IMPLEMENTED = 501, + HTTP_NOT_IMPLEMENTED = 501, /** @brief The server acting as a gateway or proxy received an invalid request from the remote server. */ - BAD_GATEWAY = 502, + HTTP_BAD_GATEWAY = 502, /** @brief Due to overload or system maintenance, the server is temporarily unable to process client requests. */ - UNAVAILABLE = 503, + HTTP_UNAVAILABLE = 503, /** @brief The server acting as gateway did not obtain requests from the remote server in a timely manner. */ - GATEWAY_TIMEOUT = 504, + HTTP_GATEWAY_TIMEOUT = 504, /** @brief The version of the HTTP protocol requested by the server. */ - VERSION = 505 + HTTP_VERSION = 505 } Http_ResponseCode; /** * @brief Buffer. * * @since 20 - * @version 1.0 */ typedef struct Http_Buffer { /** Content. Buffer will not be copied. */ @@ -226,7 +221,6 @@ typedef struct Http_Buffer { * @brief Defines the address Family. * * @since 20 - * @version 1.0 */ typedef enum Http_AddressFamilyType { /** Default, The system automatically selects the IPv4 or IPv6 address of the domain name. */ @@ -241,7 +235,6 @@ typedef enum Http_AddressFamilyType { * @brief HTTP get method. * * @since 20 - * @version 1.0 */ #define NET_HTTP_METHOD_GET "GET" @@ -249,7 +242,6 @@ typedef enum Http_AddressFamilyType { * @brief HTTP head method. * * @since 20 - * @version 1.0 */ #define NET_HTTPMETHOD_HEAD "HEAD" @@ -257,7 +249,6 @@ typedef enum Http_AddressFamilyType { * @brief HTTP options method. * * @since 20 - * @version 1.0 */ #define NET_HTTPMETHOD_OPTIONS "OPTIONS" @@ -265,13 +256,11 @@ typedef enum Http_AddressFamilyType { * @brief HTTP trace method. * * @since 20 - * @version 1.0 */ #define NET_HTTPMETHOD_TRACE "TRACE" /** * @brief HTTP delete method. * @since 20 - * @version 1.0 */ #define NET_HTTPMETHOD_DELETE "DELETE" @@ -279,7 +268,6 @@ typedef enum Http_AddressFamilyType { * @brief HTTP post method. * * @since 20 - * @version 1.0 */ #define NET_HTTP_METHOD_POST "POST" @@ -287,7 +275,6 @@ typedef enum Http_AddressFamilyType { * @brief HTTP put method. * * @since 20 - * @version 1.0 */ #define NET_HTTP_METHOD_PUT "PUT" @@ -295,7 +282,6 @@ typedef enum Http_AddressFamilyType { * @brief HTTP connect method. * * @since 20 - * @version 1.0 */ #define NET_HTTP_METHOD_PATCH "CONNECT" @@ -303,7 +289,6 @@ typedef enum Http_AddressFamilyType { * @brief Defines the HTTP version. * * @since 20 - * @version 1.0 */ typedef enum Http_HttpProtocol { /** Default choose by curl. */ @@ -320,7 +305,6 @@ typedef enum Http_HttpProtocol { * @brief Defines the Cert Type. * * @since 20 - * @version 1.0 */ typedef enum Http_CertType { /** PEM Cert Type. */ @@ -335,7 +319,6 @@ typedef enum Http_CertType { * @brief Headers of the request or response. * * @since 20 - * @version 1.0 */ typedef struct Http_Headers Http_Headers; @@ -343,7 +326,6 @@ typedef struct Http_Headers Http_Headers; * @brief The value type of the header map of the request or response. * * @since 20 - * @version 1.0 */ typedef struct Http_HeaderValue { /** Value. */ @@ -356,7 +338,6 @@ typedef struct Http_HeaderValue { * @brief All key-value pairs of the headers of the request or response. * * @since 20 - * @version 1.0 */ typedef struct Http_HeaderEntry { /** Key. */ @@ -372,7 +353,6 @@ typedef struct Http_HeaderEntry { * client's identification. * * @since 20 - * @version 1.0 */ typedef struct Http_ClientCert { /** A path to a client certificate. */ @@ -389,7 +369,6 @@ typedef struct Http_ClientCert { * @brief Proxy type. Used to distinguish different proxy configurations. * * @since 20 - * @version 1.0 */ typedef enum Http_ProxyType { /** No proxy */ @@ -404,7 +383,6 @@ typedef enum Http_ProxyType { * @brief Custom proxy configuration. * * @since 20 - * @version 1.0 */ typedef struct Http_CustomProxy { /** Indicates the URL of the proxy server. If you do not set port explicitly, port will be 1080. */ @@ -417,7 +395,6 @@ typedef struct Http_CustomProxy { * @brief Proxy configuration. * * @since 20 - * @version 1.0 */ typedef struct Http_Proxy { /** Distinguish the proxy type used by the request, see {@link Http_ProxyType}. */ @@ -430,7 +407,6 @@ typedef struct Http_Proxy { * @brief Response timing information. It will be collected in {@link Http_Response.performanceTiming}. * * @since 20 - * @version 1.0 */ typedef struct Http_PerformanceTiming { /** The total time in milliseconds for the HTTP transfer, including name resolving, TCP connect etc. */ @@ -453,7 +429,6 @@ typedef struct Http_PerformanceTiming { * @brief Defines the parameters for http request options. * * @since 20 - * @version 1.0 */ typedef struct Http_RequestOptions { /** Request method. */ @@ -493,7 +468,6 @@ typedef struct Http_RequestOptions { * @brief Defines the parameters for http response. * * @since 20 - * @version 1.0 */ typedef struct Http_Response { /** Response body, see {@link Http_Buffer}. */ @@ -511,7 +485,6 @@ typedef struct Http_Response { * * @param response Indicates the response to be deleted. It is a pointer that points to {@link Http_Response}. * @since 20 - * @version 1.0 */ void (*destroyResponse)(struct Http_Response **response); } Http_Response; @@ -520,7 +493,6 @@ typedef struct Http_Response { * @brief Http request. * * @since 20 - * @version 1.0 */ typedef struct Http_Request { /** The request id for every single request. Generated by system. */ @@ -537,7 +509,6 @@ typedef struct Http_Request { * @param response Http response struct, see {@link Http_Response}. * @param errCode Response error code. * @since 20 - * @version 1.0 */ typedef void (*Http_ResponseCallback)(struct Http_Response *response, uint32_t errCode); @@ -547,7 +518,6 @@ typedef void (*Http_ResponseCallback)(struct Http_Response *response, uint32_t e * @param data Response body. * @return size_t the length of response body. * @since 20 - * @version 1.0 */ typedef size_t (*Http_OnDataReceiveCallback)(const char *data); @@ -557,7 +527,6 @@ typedef size_t (*Http_OnDataReceiveCallback)(const char *data); * @param totalSize total size. * @param transferredSize transferred size. * @since 20 - * @version 1.0 */ typedef void (*Http_OnProgressCallback)(uint64_t totalSize, uint64_t transferredSize); @@ -566,7 +535,6 @@ typedef void (*Http_OnProgressCallback)(uint64_t totalSize, uint64_t transferred * * @param headers Headers of the received requests, which points to the pointer of {@link Http_Headers}. * @since 20 - * @version 1.0 */ typedef void (*Http_OnHeaderReceiveCallback)(Http_Headers *headers); @@ -574,7 +542,6 @@ typedef void (*Http_OnHeaderReceiveCallback)(Http_Headers *headers); * @brief Empty callback function for requested DataEnd or Canceled event callback。 * * @since 20 - * @version 1.0 */ typedef void (*Http_OnVoidCallback)(void); @@ -582,7 +549,6 @@ typedef void (*Http_OnVoidCallback)(void); * @brief Callbacks to watch different events. * * @since 20 - * @version 1.0 */ typedef struct Http_EventsHandler { /** Callback function when the response body is received */ -- Gitee From 2094c7e5125951cb16cfcde1c79ce12b6e453720 Mon Sep 17 00:00:00 2001 From: liuleimin_hw Date: Mon, 26 May 2025 09:34:34 +0000 Subject: [PATCH 04/13] update network/netstack/net_http/net_http.h. Signed-off-by: liuleimin_hw --- network/netstack/net_http/net_http.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/network/netstack/net_http/net_http.h b/network/netstack/net_http/net_http.h index 25cf8a3d9..58d78cd21 100644 --- a/network/netstack/net_http/net_http.h +++ b/network/netstack/net_http/net_http.h @@ -60,7 +60,7 @@ Http_Headers *OH_Http_CreateHeaders(void); /** * @brief Destroys the headers of a request or response. * - * @param headers Pointer to the {@link Http_Headers} to be destroyed. + * @param headers Pointer to the {@link Http_Headers} to be destroyed, headers ends with null. * @syscap SystemCapability.Communication.NetStack * @since 20 * @version 1.0 @@ -106,7 +106,7 @@ Http_HeaderEntry *OH_Http_GetHeaderEntries(Http_Headers *headers); /** * @brief Destroys all key-value pairs obtained in {@link OH_Http_GetHeaderEntries}. * - * @param headerEntry Pointer to the {@link Http_HeaderEntry} to be destroyed. + * @param headerEntry Pointer to the {@link Http_HeaderEntry} to be destroyed, headerEntry ends with null. * @syscap SystemCapability.Communication.NetStack * @since 20 * @version 1.0 -- Gitee From ded2ab71892d5a951187869de5f6f21be452d513 Mon Sep 17 00:00:00 2001 From: liuleimin_hw Date: Mon, 26 May 2025 09:36:01 +0000 Subject: [PATCH 05/13] update network/netstack/net_http/net_http.h. Signed-off-by: liuleimin_hw --- network/netstack/net_http/net_http.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/network/netstack/net_http/net_http.h b/network/netstack/net_http/net_http.h index 58d78cd21..24878f4da 100644 --- a/network/netstack/net_http/net_http.h +++ b/network/netstack/net_http/net_http.h @@ -21,7 +21,6 @@ * * @syscap SystemCapability.Communication.NetStack * @since 20 - * @version 1.0 */ /** @@ -32,7 +31,6 @@ * @kit NetworkKit * @syscap SystemCapability.Communication.NetStack * @since 20 - * @version 1.0 */ #ifndef NET_HTTP_H @@ -53,7 +51,6 @@ extern "C" { * @return Http_Headers* Pointer to {@link Http_Headers}. * @syscap SystemCapability.Communication.NetStack * @since 20 - * @version 1.0 */ Http_Headers *OH_Http_CreateHeaders(void); @@ -63,7 +60,6 @@ Http_Headers *OH_Http_CreateHeaders(void); * @param headers Pointer to the {@link Http_Headers} to be destroyed, headers ends with null. * @syscap SystemCapability.Communication.NetStack * @since 20 - * @version 1.0 */ void OH_Http_DestroyHeaders(Http_Headers **headers); @@ -76,7 +72,6 @@ void OH_Http_DestroyHeaders(Http_Headers **headers); * @return uint32_t 0 - success. 401 - Parameter error. 2300027 - Out of memory. * @syscap SystemCapability.Communication.NetStack * @since 20 - * @version 1.0 */ uint32_t OH_Http_SetHeaderValue(struct Http_Headers *headers, const char *name, const char *value); @@ -88,7 +83,6 @@ uint32_t OH_Http_SetHeaderValue(struct Http_Headers *headers, const char *name, * @return Http_HeaderValue* Pointer to the obtained {@link Http_HeaderValue}. * @syscap SystemCapability.Communication.NetStack * @since 20 - * @version 1.0 */ Http_HeaderValue *OH_Http_GetHeaderValue(Http_Headers *headers, const char *name); @@ -99,7 +93,6 @@ Http_HeaderValue *OH_Http_GetHeaderValue(Http_Headers *headers, const char *name * @return Http_HeaderEntry* Pointers to all obtained key-value pairs {@link Http_HeaderEntry}. * @syscap SystemCapability.Communication.NetStack * @since 20 - * @version 1.0 */ Http_HeaderEntry *OH_Http_GetHeaderEntries(Http_Headers *headers); @@ -109,7 +102,6 @@ Http_HeaderEntry *OH_Http_GetHeaderEntries(Http_Headers *headers); * @param headerEntry Pointer to the {@link Http_HeaderEntry} to be destroyed, headerEntry ends with null. * @syscap SystemCapability.Communication.NetStack * @since 20 - * @version 1.0 */ void OH_Http_DestroyHeaderEntries(Http_HeaderEntry **headerEntry); @@ -120,7 +112,6 @@ void OH_Http_DestroyHeaderEntries(Http_HeaderEntry **headerEntry); * @return Pointer of HttpRequest if success; Null otherwise. * @syscap SystemCapability.Communication.NetStack * @since 20 - * @version 1.0 */ Http_Request *OH_Http_CreateRequest(const char *url); @@ -134,7 +125,6 @@ Http_Request *OH_Http_CreateRequest(const char *url); * @permission ohos.permission.INTERNET * @syscap SystemCapability.Communication.NetStack * @since 20 - * @version 1.0 */ int OH_Http_Request(Http_Request *request, Http_ResponseCallback callback, Http_EventsHandler handler); @@ -144,7 +134,6 @@ int OH_Http_Request(Http_Request *request, Http_ResponseCallback callback, Http_ * @param request Pointer to the http request {@link Http_Request}. * @syscap SystemCapability.Communication.NetStack * @since 20 - * @version 1.0 */ void OH_Http_Destroy(struct Http_Request **request); #ifdef __cplusplus -- Gitee From 25e2bfb39a7d1366a0e2d28a37226ba0cef65537 Mon Sep 17 00:00:00 2001 From: liuleimin_hw Date: Mon, 26 May 2025 10:37:15 +0000 Subject: [PATCH 06/13] update network/netstack/net_http/net_http_type.h. Signed-off-by: liuleimin_hw --- network/netstack/net_http/net_http_type.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/netstack/net_http/net_http_type.h b/network/netstack/net_http/net_http_type.h index ff83f1a35..fb4c181f9 100644 --- a/network/netstack/net_http/net_http_type.h +++ b/network/netstack/net_http/net_http_type.h @@ -539,7 +539,7 @@ typedef void (*Http_OnProgressCallback)(uint64_t totalSize, uint64_t transferred typedef void (*Http_OnHeaderReceiveCallback)(Http_Headers *headers); /** - * @brief Empty callback function for requested DataEnd or Canceled event callback。 + * @brief Empty callback function for requested DataEnd or Canceled event callback. * * @since 20 */ -- Gitee From 1f9a554ea8c84f611a4eae5d988521aae8e6e820 Mon Sep 17 00:00:00 2001 From: liuleimin_hw Date: Mon, 26 May 2025 10:46:02 +0000 Subject: [PATCH 07/13] update network/netstack/net_http/net_http_type.h. Signed-off-by: liuleimin_hw --- network/netstack/net_http/net_http_type.h | 60 +++++++++++------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/network/netstack/net_http/net_http_type.h b/network/netstack/net_http/net_http_type.h index fb4c181f9..d495ef7b2 100644 --- a/network/netstack/net_http/net_http_type.h +++ b/network/netstack/net_http/net_http_type.h @@ -58,65 +58,65 @@ typedef enum Http_ErrCode { /** @brief Error code base. */ HTTP_NETSTACK_E_BASE = 2300000, /** @brief Unsupported protocol. */ - HTTP_UNSUPPORTED_PROTOCOL = (NETSTACK_E_BASE + 1), + HTTP_UNSUPPORTED_PROTOCOL = (HTTP_NETSTACK_E_BASE + 1), /** @brief Invalid URL format or missing URL. */ - HTTP_INVALID_URL = (NETSTACK_E_BASE + 3), + HTTP_INVALID_URL = (HTTP_NETSTACK_E_BASE + 3), /** @brief Failed to resolve the proxy name. */ - HTTP_RESOLVE_PROXY_FAILED = (NETSTACK_E_BASE + 5), + HTTP_RESOLVE_PROXY_FAILED = (HTTP_NETSTACK_E_BASE + 5), /** @brief Failed to resolve the host name. */ - HTTP_RESOLVE_HOST_FAILED = (NETSTACK_E_BASE + 6), + HTTP_RESOLVE_HOST_FAILED = (HTTP_NETSTACK_E_BASE + 6), /** @brief Failed to connect to the server. */ - HTTP_CONNECT_SERVER_FAILED = (NETSTACK_E_BASE + 7), + HTTP_CONNECT_SERVER_FAILED = (HTTP_NETSTACK_E_BASE + 7), /** @brief Invalid server response. */ - HTTP_INVALID_SERVER_RESPONSE = (NETSTACK_E_BASE + 8), + HTTP_INVALID_SERVER_RESPONSE = (HTTP_NETSTACK_E_BASE + 8), /** @brief Access to the remote resource denied. */ - HTTP_ACCESS_REMOTE_DENIED = (NETSTACK_E_BASE + 9), + HTTP_ACCESS_REMOTE_DENIED = (HTTP_NETSTACK_E_BASE + 9), /** @brief Error in the HTTP2 framing layer. */ - HTTP_HTTP2_FRAMING_ERROR = (NETSTACK_E_BASE + 16), + HTTP_HTTP2_FRAMING_ERROR = (HTTP_NETSTACK_E_BASE + 16), /** @brief Transferred a partial file. */ - HTTP_TRANSFER_PARTIAL_FILE = (NETSTACK_E_BASE + 18), + HTTP_TRANSFER_PARTIAL_FILE = (HTTP_NETSTACK_E_BASE + 18), /** @brief Failed to write the received data to the disk or application. */ - HTTP_WRITE_DATA_FAILED = (NETSTACK_E_BASE + 23), + HTTP_WRITE_DATA_FAILED = (HTTP_NETSTACK_E_BASE + 23), /** @brief Upload failed. */ - HTTP_UPLOAD_FAILED = (NETSTACK_E_BASE + 25), + HTTP_UPLOAD_FAILED = (HTTP_NETSTACK_E_BASE + 25), /** @brief Failed to open or read local data from the file or application. */ - HTTP_OPEN_LOCAL_DATA_FAILED = (NETSTACK_E_BASE + 26), + HTTP_OPEN_LOCAL_DATA_FAILED = (HTTP_NETSTACK_E_BASE + 26), /** @brief Out of memory. */ - HTTP_OUT_OF_MEMORY = (NETSTACK_E_BASE + 27), + HTTP_OUT_OF_MEMORY = (HTTP_NETSTACK_E_BASE + 27), /** @brief Operation timeout. */ - HTTP_OPERATION_TIMEOUT = (NETSTACK_E_BASE + 28), + HTTP_OPERATION_TIMEOUT = (HTTP_NETSTACK_E_BASE + 28), /** @brief The number of redirections reaches the maximum allowed. */ - HTTP_REDIRECTIONS_TOO_LARGE = (NETSTACK_E_BASE + 47), + HTTP_REDIRECTIONS_TOO_LARGE = (HTTP_NETSTACK_E_BASE + 47), /** @brief The server returned nothing (no header or data). */ - HTTP_SERVER_RETURNED_NOTHING = (NETSTACK_E_BASE + 52), + HTTP_SERVER_RETURNED_NOTHING = (HTTP_NETSTACK_E_BASE + 52), /** @brief Failed to send data to the peer. */ - HTTP_SEND_DATA_FAILED = (NETSTACK_E_BASE + 55), + HTTP_SEND_DATA_FAILED = (HTTP_NETSTACK_E_BASE + 55), /** @brief Failed to receive data from the peer. */ - HTTP_RECEIVE_DATA_FAILED = (NETSTACK_E_BASE + 56), + HTTP_RECEIVE_DATA_FAILED = (HTTP_NETSTACK_E_BASE + 56), /** @brief Local SSL certificate error. */ - HTTP_SSL_CERTIFICATE_ERROR = (NETSTACK_E_BASE + 58), + HTTP_SSL_CERTIFICATE_ERROR = (HTTP_NETSTACK_E_BASE + 58), /** @brief The specified SSL cipher cannot be used. */ - HTTP_SSL_CIPHER_USED_ERROR = (NETSTACK_E_BASE + 59), + HTTP_SSL_CIPHER_USED_ERROR = (HTTP_NETSTACK_E_BASE + 59), /** @brief Invalid SSL peer certificate or SSH remote key. */ - HTTP_INVALID_SSL_PEER_CERT = (NETSTACK_E_BASE + 60), + HTTP_INVALID_SSL_PEER_CERT = (HTTP_NETSTACK_E_BASE + 60), /** @brief Invalid HTTP encoding format. */ - HTTP_INVALID_ENCODING_FORMAT = (NETSTACK_E_BASE + 61), + HTTP_INVALID_ENCODING_FORMAT = (HTTP_NETSTACK_E_BASE + 61), /** @brief Maximum file size exceeded. */ - HTTP_FILE_TOO_LARGE = (NETSTACK_E_BASE + 63), + HTTP_FILE_TOO_LARGE = (HTTP_NETSTACK_E_BASE + 63), /** @brief Remote disk full. */ - HTTP_REMOTE_DISK_FULL = (NETSTACK_E_BASE + 70), + HTTP_REMOTE_DISK_FULL = (HTTP_NETSTACK_E_BASE + 70), /** @brief Remote file already exists. */ - HTTP_REMOTE_FILE_EXISTS = (NETSTACK_E_BASE + 73), + HTTP_REMOTE_FILE_EXISTS = (HTTP_NETSTACK_E_BASE + 73), /** @brief The SSL CA certificate does not exist or is inaccessible. */ - HTTP_SSL_CA_NOT_EXIST = (NETSTACK_E_BASE + 77), + HTTP_SSL_CA_NOT_EXIST = (HTTP_NETSTACK_E_BASE + 77), /** @brief Remote file not found. */ - HTTP_REMOTE_FILE_NOT_FOUND = (NETSTACK_E_BASE + 78), + HTTP_REMOTE_FILE_NOT_FOUND = (HTTP_NETSTACK_E_BASE + 78), /** @brief Authentication error. */ - HTTP_AUTHENTICATION_ERROR = (NETSTACK_E_BASE + 94), + HTTP_AUTHENTICATION_ERROR = (HTTP_NETSTACK_E_BASE + 94), /** @brief It is not allowed to access this domain. */ - HTTP_ACCESS_DOMAIN_NOT_ALLOWED = (NETSTACK_E_BASE + 998), + HTTP_ACCESS_DOMAIN_NOT_ALLOWED = (HTTP_NETSTACK_E_BASE + 998), /** @brief Unknown error. */ - HTTP_UNKNOWN_ERROR = (NETSTACK_E_BASE + 999) + HTTP_UNKNOWN_ERROR = (HTTP_NETSTACK_E_BASE + 999) } Http_ErrCode; /** -- Gitee From 4eb0cc251fd3ed07ea9b5710661b687a1d620543 Mon Sep 17 00:00:00 2001 From: liuleimin_hw Date: Mon, 26 May 2025 11:22:56 +0000 Subject: [PATCH 08/13] update network/netstack/net_http/net_http_type.h. Signed-off-by: liuleimin_hw --- network/netstack/net_http/net_http_type.h | 70 +++++++++++------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/network/netstack/net_http/net_http_type.h b/network/netstack/net_http/net_http_type.h index d495ef7b2..dd6f9bbc0 100644 --- a/network/netstack/net_http/net_http_type.h +++ b/network/netstack/net_http/net_http_type.h @@ -50,73 +50,73 @@ extern "C" { */ typedef enum Http_ErrCode { /** Operation success. */ - HTTP_RESULT_OK = 0, + HTTP_NDK_RESULT_OK = 0, /** @brief Parameter error. */ - HTTP_PARAMETER_ERROR = 401, + HTTP_NDK_PARAMETER_ERROR = 401, /** @brief Permission denied. */ - HTTP_PERMISSION_DENIED = 201, + HTTP_NDK_PERMISSION_DENIED = 201, /** @brief Error code base. */ - HTTP_NETSTACK_E_BASE = 2300000, + HTTP_NDK_NETSTACK_E_BASE = 2300000, /** @brief Unsupported protocol. */ - HTTP_UNSUPPORTED_PROTOCOL = (HTTP_NETSTACK_E_BASE + 1), + HTTP_NDK_UNSUPPORTED_PROTOCOL = (HTTP_NDK_NETSTACK_E_BASE + 1), /** @brief Invalid URL format or missing URL. */ - HTTP_INVALID_URL = (HTTP_NETSTACK_E_BASE + 3), + HTTP_NDK_INVALID_URL = (HTTP_NDK_NETSTACK_E_BASE + 3), /** @brief Failed to resolve the proxy name. */ - HTTP_RESOLVE_PROXY_FAILED = (HTTP_NETSTACK_E_BASE + 5), + HTTP_NDK_RESOLVE_PROXY_FAILED = (HTTP_NDK_NETSTACK_E_BASE + 5), /** @brief Failed to resolve the host name. */ - HTTP_RESOLVE_HOST_FAILED = (HTTP_NETSTACK_E_BASE + 6), + HTTP_NDK_RESOLVE_HOST_FAILED = (HTTP_NDK_NETSTACK_E_BASE + 6), /** @brief Failed to connect to the server. */ - HTTP_CONNECT_SERVER_FAILED = (HTTP_NETSTACK_E_BASE + 7), + HTTP_NDK_CONNECT_SERVER_FAILED = (HTTP_NDK_NETSTACK_E_BASE + 7), /** @brief Invalid server response. */ - HTTP_INVALID_SERVER_RESPONSE = (HTTP_NETSTACK_E_BASE + 8), + HTTP_NDK_INVALID_SERVER_RESPONSE = (HTTP_NDK_NETSTACK_E_BASE + 8), /** @brief Access to the remote resource denied. */ - HTTP_ACCESS_REMOTE_DENIED = (HTTP_NETSTACK_E_BASE + 9), + HTTP_NDK_ACCESS_REMOTE_DENIED = (HTTP_NDK_NETSTACK_E_BASE + 9), /** @brief Error in the HTTP2 framing layer. */ - HTTP_HTTP2_FRAMING_ERROR = (HTTP_NETSTACK_E_BASE + 16), + HTTP_NDK_HTTP2_FRAMING_ERROR = (HTTP_NDK_NETSTACK_E_BASE + 16), /** @brief Transferred a partial file. */ - HTTP_TRANSFER_PARTIAL_FILE = (HTTP_NETSTACK_E_BASE + 18), + HTTP_NDK_TRANSFER_PARTIAL_FILE = (HTTP_NDK_NETSTACK_E_BASE + 18), /** @brief Failed to write the received data to the disk or application. */ - HTTP_WRITE_DATA_FAILED = (HTTP_NETSTACK_E_BASE + 23), + HTTP_NDK_WRITE_DATA_FAILED = (HTTP_NDK_NETSTACK_E_BASE + 23), /** @brief Upload failed. */ - HTTP_UPLOAD_FAILED = (HTTP_NETSTACK_E_BASE + 25), + HTTP_NDK_UPLOAD_FAILED = (HTTP_NDK_NETSTACK_E_BASE + 25), /** @brief Failed to open or read local data from the file or application. */ - HTTP_OPEN_LOCAL_DATA_FAILED = (HTTP_NETSTACK_E_BASE + 26), + HTTP_NDK_OPEN_LOCAL_DATA_FAILED = (HTTP_NDK_NETSTACK_E_BASE + 26), /** @brief Out of memory. */ - HTTP_OUT_OF_MEMORY = (HTTP_NETSTACK_E_BASE + 27), + HTTP_NDK_OUT_OF_MEMORY = (HTTP_NDK_NETSTACK_E_BASE + 27), /** @brief Operation timeout. */ - HTTP_OPERATION_TIMEOUT = (HTTP_NETSTACK_E_BASE + 28), + HTTP_NDK_OPERATION_TIMEOUT = (HTTP_NDK_NETSTACK_E_BASE + 28), /** @brief The number of redirections reaches the maximum allowed. */ - HTTP_REDIRECTIONS_TOO_LARGE = (HTTP_NETSTACK_E_BASE + 47), + HTTP_NDK_REDIRECTIONS_TOO_LARGE = (HTTP_NDK_NETSTACK_E_BASE + 47), /** @brief The server returned nothing (no header or data). */ - HTTP_SERVER_RETURNED_NOTHING = (HTTP_NETSTACK_E_BASE + 52), + HTTP_NDK_SERVER_RETURNED_NOTHING = (HTTP_NDK_NETSTACK_E_BASE + 52), /** @brief Failed to send data to the peer. */ - HTTP_SEND_DATA_FAILED = (HTTP_NETSTACK_E_BASE + 55), + HTTP_NDK_SEND_DATA_FAILED = (HTTP_NDK_NETSTACK_E_BASE + 55), /** @brief Failed to receive data from the peer. */ - HTTP_RECEIVE_DATA_FAILED = (HTTP_NETSTACK_E_BASE + 56), + HTTP_NDK_RECEIVE_DATA_FAILED = (HTTP_NDK_NETSTACK_E_BASE + 56), /** @brief Local SSL certificate error. */ - HTTP_SSL_CERTIFICATE_ERROR = (HTTP_NETSTACK_E_BASE + 58), + HTTP_NDK_SSL_CERTIFICATE_ERROR = (HTTP_NDK_NETSTACK_E_BASE + 58), /** @brief The specified SSL cipher cannot be used. */ - HTTP_SSL_CIPHER_USED_ERROR = (HTTP_NETSTACK_E_BASE + 59), + HTTP_NDK_SSL_CIPHER_USED_ERROR = (HTTP_NDK_NETSTACK_E_BASE + 59), /** @brief Invalid SSL peer certificate or SSH remote key. */ - HTTP_INVALID_SSL_PEER_CERT = (HTTP_NETSTACK_E_BASE + 60), + HTTP_NDK_INVALID_SSL_PEER_CERT = (HTTP_NDK_NETSTACK_E_BASE + 60), /** @brief Invalid HTTP encoding format. */ - HTTP_INVALID_ENCODING_FORMAT = (HTTP_NETSTACK_E_BASE + 61), + HTTP_NDK_INVALID_ENCODING_FORMAT = (HTTP_NDK_NETSTACK_E_BASE + 61), /** @brief Maximum file size exceeded. */ - HTTP_FILE_TOO_LARGE = (HTTP_NETSTACK_E_BASE + 63), + HTTP_NDK_FILE_TOO_LARGE = (HTTP_NDK_NETSTACK_E_BASE + 63), /** @brief Remote disk full. */ - HTTP_REMOTE_DISK_FULL = (HTTP_NETSTACK_E_BASE + 70), + HTTP_NDK_REMOTE_DISK_FULL = (HTTP_NDK_NETSTACK_E_BASE + 70), /** @brief Remote file already exists. */ - HTTP_REMOTE_FILE_EXISTS = (HTTP_NETSTACK_E_BASE + 73), + HTTP_NDK_REMOTE_FILE_EXISTS = (HTTP_NDK_NETSTACK_E_BASE + 73), /** @brief The SSL CA certificate does not exist or is inaccessible. */ - HTTP_SSL_CA_NOT_EXIST = (HTTP_NETSTACK_E_BASE + 77), + HTTP_NDK_SSL_CA_NOT_EXIST = (HTTP_NDK_NETSTACK_E_BASE + 77), /** @brief Remote file not found. */ - HTTP_REMOTE_FILE_NOT_FOUND = (HTTP_NETSTACK_E_BASE + 78), + HTTP_NDK_REMOTE_FILE_NOT_FOUND = (HTTP_NDK_NETSTACK_E_BASE + 78), /** @brief Authentication error. */ - HTTP_AUTHENTICATION_ERROR = (HTTP_NETSTACK_E_BASE + 94), + HTTP_NDK_AUTHENTICATION_ERROR = (HTTP_NDK_NETSTACK_E_BASE + 94), /** @brief It is not allowed to access this domain. */ - HTTP_ACCESS_DOMAIN_NOT_ALLOWED = (HTTP_NETSTACK_E_BASE + 998), + HTTP_NDK_ACCESS_DOMAIN_NOT_ALLOWED = (HTTP_NDK_NETSTACK_E_BASE + 998), /** @brief Unknown error. */ - HTTP_UNKNOWN_ERROR = (HTTP_NETSTACK_E_BASE + 999) + HTTP_NDK_UNKNOWN_ERROR = (HTTP_NDK_NETSTACK_E_BASE + 999) } Http_ErrCode; /** @@ -539,7 +539,7 @@ typedef void (*Http_OnProgressCallback)(uint64_t totalSize, uint64_t transferred typedef void (*Http_OnHeaderReceiveCallback)(Http_Headers *headers); /** - * @brief Empty callback function for requested DataEnd or Canceled event callback. + * @brief Empty callback function for requested DataEnd or Canceled event callback * * @since 20 */ -- Gitee From f3b72c80d05c7a61faec40ae5a1090a261b6d621 Mon Sep 17 00:00:00 2001 From: liuleimin_hw Date: Mon, 26 May 2025 12:10:37 +0000 Subject: [PATCH 09/13] update network/netstack/net_http/net_http_type.h. Signed-off-by: liuleimin_hw --- network/netstack/net_http/net_http_type.h | 72 +++++++++++------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/network/netstack/net_http/net_http_type.h b/network/netstack/net_http/net_http_type.h index dd6f9bbc0..75dc035ba 100644 --- a/network/netstack/net_http/net_http_type.h +++ b/network/netstack/net_http/net_http_type.h @@ -126,83 +126,83 @@ typedef enum Http_ErrCode { */ typedef enum Http_ResponseCode { /** @brief The request was successful. */ - HTTP_OK = 200, + HTTP_NDK_OK = 200, /** @brief Successfully requested and created a new resource. */ - HTTP_CREATED = 201, + HTTP_NDK_CREATED = 201, /** @brief The request has been accepted but has not been processed completely. */ - HTTP_ACCEPTED = 202, + HTTP_NDK_ACCEPTED = 202, /** @brief Unauthorized information. The request was successful. */ - HTTP_NOT_AUTHORITATIVE = 203, + HTTP_NDK_NOT_AUTHORITATIVE = 203, /** @brief No content. The server successfully processed, but did not return content. */ - HTTP_NO_CONTENT = 204, + HTTP_NDK_NO_CONTENT = 204, /** @brief Reset the content. */ - HTTP_RESET = 205, + HTTP_NDK_RESET = 205, /** @brief Partial content. The server successfully processed some GET requests. */ - HTTP_PARTIAL = 206, + HTTP_NDK_PARTIAL = 206, /** @brief Multiple options. */ - HTTP_MULT_CHOICE = 300, + HTTP_NDK_MULT_CHOICE = 300, /** * @brief Permanently move. The requested resource has been permanently moved to a new URI, * and the returned information will include the new URI. The browser will automatically redirect to the new URI. */ - HTTP_MOVED_PERM = 301, + HTTP_NDK_MOVED_PERM = 301, /** @brief Temporary movement. */ - HTTP_MOVED_TEMP = 302, + HTTP_NDK_MOVED_TEMP = 302, /** @brief View other addresses. */ - HTTP_SEE_OTHER = 303, + HTTP_NDK_SEE_OTHER = 303, /** @brief Not modified. */ - HTTP_NOT_MODIFIED = 304, + HTTP_NDK_NOT_MODIFIED = 304, /** @brief Using proxies. */ - HTTP_USE_PROXY = 305, + HTTP_NDK_USE_PROXY = 305, /** @brief The server cannot understand the syntax error error requested by the client. */ - HTTP_BAD_REQUEST = 400, + HTTP_NDK_BAD_REQUEST = 400, /** @brief Request for user authentication. */ - HTTP_UNAUTHORIZED = 401, + HTTP_NDK_UNAUTHORIZED = 401, /** @brief Reserved for future use. */ - HTTP_PAYMENT_REQUIRED = 402, + HTTP_NDK_PAYMENT_REQUIRED = 402, /** @brief The server understands the request from the requesting client, but refuses to execute it. */ - HTTP_FORBIDDEN = 403, + HTTP_NDK_FORBIDDEN = 403, /** @brief The server was unable to find resources (web pages) based on the client's request. */ - HTTP_NOT_FOUND = 404, + HTTP_NDK_NOT_FOUND = 404, /** @brief The method in the client request is prohibited. */ - HTTP_BAD_METHOD = 405, + HTTP_NDK_BAD_METHOD = 405, /** @brief The server unabled to complete request based on the content characteristics requested by the client. */ - HTTP_NOT_ACCEPTABLE = 406, + HTTP_NDK_NOT_ACCEPTABLE = 406, /** @brief Request authentication of the proxy's identity. */ - HTTP_PROXY_AUTH = 407, + HTTP_NDK_PROXY_AUTH = 407, /** @brief The request took too long and timed out. */ - HTTP_CLIENT_TIMEOUT = 408, + HTTP_NDK_CLIENT_TIMEOUT = 408, /** * @brief The server may have returned this code when completing the client's PUT request, * as there was a conflict when the server was processing the request. */ - HTTP_CONFLICT = 409, + HTTP_NDK_CONFLICT = 409, /** @brief The resource requested by the client no longer exists. */ - HTTP_GONE = 410, + HTTP_NDK_GONE = 410, /** @brief The server is unable to process request information sent by the client without Content Length. */ - HTTP_LENGTH_REQUIRED = 411, + HTTP_NDK_LENGTH_REQUIRED = 411, /** @brief The prerequisite for requesting information from the client is incorrect. */ - HTTP_PRECON_FAILED = 412, + HTTP_NDK_PRECON_FAILED = 412, /** @brief The request was rejected because the requested entity was too large for the server to process. */ - HTTP_ENTITY_TOO_LARGE = 413, + HTTP_NDK_ENTITY_TOO_LARGE = 413, /** @brief The requested URI is too long (usually a URL) and the server cannot process it. */ - HTTP_REQ_TOO_LONG = 414, + HTTP_NDK_REQ_TOO_LONG = 414, /** @brief The server is unable to process the requested format. */ - HTTP_UNSUPPORTED_TYPE = 415, + HTTP_NDK_UNSUPPORTED_TYPE = 415, /** @brief Requested Range not satisfiable. */ - HTTP_RANGE_NOT_SATISFIABLE = 416, + HTTP_NDK_RANGE_NOT_SATISFIABLE = 416, /** @brief Internal server error, unable to complete the request. */ - HTTP_INTERNAL_ERROR = 500, + HTTP_NDK_INTERNAL_ERROR = 500, /** @brief * The server does not support the requested functionality and cannot complete the request. */ - HTTP_NOT_IMPLEMENTED = 501, + HTTP_NDK_NOT_IMPLEMENTED = 501, /** @brief The server acting as a gateway or proxy received an invalid request from the remote server. */ - HTTP_BAD_GATEWAY = 502, + HTTP_NDK_BAD_GATEWAY = 502, /** @brief Due to overload or system maintenance, the server is temporarily unable to process client requests. */ - HTTP_UNAVAILABLE = 503, + HTTP_NDK_UNAVAILABLE = 503, /** @brief The server acting as gateway did not obtain requests from the remote server in a timely manner. */ - HTTP_GATEWAY_TIMEOUT = 504, + HTTP_NDK_GATEWAY_TIMEOUT = 504, /** @brief The version of the HTTP protocol requested by the server. */ - HTTP_VERSION = 505 + HTTP_NDK_VERSION = 505 } Http_ResponseCode; /** -- Gitee From d045bee0c057ea21691d84010519c430a6a0b927 Mon Sep 17 00:00:00 2001 From: liuleimin_hw Date: Mon, 26 May 2025 13:57:09 +0000 Subject: [PATCH 10/13] update network/netstack/net_http/net_http_type.h. Signed-off-by: liuleimin_hw --- network/netstack/net_http/net_http_type.h | 140 +++++++++++----------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/network/netstack/net_http/net_http_type.h b/network/netstack/net_http/net_http_type.h index 75dc035ba..0c0055ba1 100644 --- a/network/netstack/net_http/net_http_type.h +++ b/network/netstack/net_http/net_http_type.h @@ -50,73 +50,73 @@ extern "C" { */ typedef enum Http_ErrCode { /** Operation success. */ - HTTP_NDK_RESULT_OK = 0, + OH_HTTP_RESULT_OK = 0, /** @brief Parameter error. */ - HTTP_NDK_PARAMETER_ERROR = 401, + OH_HTTP_PARAMETER_ERROR = 401, /** @brief Permission denied. */ - HTTP_NDK_PERMISSION_DENIED = 201, + OH_HTTP_PERMISSION_DENIED = 201, /** @brief Error code base. */ - HTTP_NDK_NETSTACK_E_BASE = 2300000, + OH_HTTP_NETSTACK_E_BASE = 2300000, /** @brief Unsupported protocol. */ - HTTP_NDK_UNSUPPORTED_PROTOCOL = (HTTP_NDK_NETSTACK_E_BASE + 1), + OH_HTTP_UNSUPPORTED_PROTOCOL = (OH_HTTP_NETSTACK_E_BASE + 1), /** @brief Invalid URL format or missing URL. */ - HTTP_NDK_INVALID_URL = (HTTP_NDK_NETSTACK_E_BASE + 3), + OH_HTTP_INVALID_URL = (OH_HTTP_NETSTACK_E_BASE + 3), /** @brief Failed to resolve the proxy name. */ - HTTP_NDK_RESOLVE_PROXY_FAILED = (HTTP_NDK_NETSTACK_E_BASE + 5), + OH_HTTP_RESOLVE_PROXY_FAILED = (OH_HTTP_NETSTACK_E_BASE + 5), /** @brief Failed to resolve the host name. */ - HTTP_NDK_RESOLVE_HOST_FAILED = (HTTP_NDK_NETSTACK_E_BASE + 6), + OH_HTTP_RESOLVE_HOST_FAILED = (OH_HTTP_NETSTACK_E_BASE + 6), /** @brief Failed to connect to the server. */ - HTTP_NDK_CONNECT_SERVER_FAILED = (HTTP_NDK_NETSTACK_E_BASE + 7), + OH_HTTP_CONNECT_SERVER_FAILED = (OH_HTTP_NETSTACK_E_BASE + 7), /** @brief Invalid server response. */ - HTTP_NDK_INVALID_SERVER_RESPONSE = (HTTP_NDK_NETSTACK_E_BASE + 8), + OH_HTTP_INVALID_SERVER_RESPONSE = (OH_HTTP_NETSTACK_E_BASE + 8), /** @brief Access to the remote resource denied. */ - HTTP_NDK_ACCESS_REMOTE_DENIED = (HTTP_NDK_NETSTACK_E_BASE + 9), + OH_HTTP_ACCESS_REMOTE_DENIED = (OH_HTTP_NETSTACK_E_BASE + 9), /** @brief Error in the HTTP2 framing layer. */ - HTTP_NDK_HTTP2_FRAMING_ERROR = (HTTP_NDK_NETSTACK_E_BASE + 16), + OH_HTTP_HTTP2_FRAMING_ERROR = (OH_HTTP_NETSTACK_E_BASE + 16), /** @brief Transferred a partial file. */ - HTTP_NDK_TRANSFER_PARTIAL_FILE = (HTTP_NDK_NETSTACK_E_BASE + 18), + OH_HTTP_TRANSFER_PARTIAL_FILE = (OH_HTTP_NETSTACK_E_BASE + 18), /** @brief Failed to write the received data to the disk or application. */ - HTTP_NDK_WRITE_DATA_FAILED = (HTTP_NDK_NETSTACK_E_BASE + 23), + OH_HTTP_WRITE_DATA_FAILED = (OH_HTTP_NETSTACK_E_BASE + 23), /** @brief Upload failed. */ - HTTP_NDK_UPLOAD_FAILED = (HTTP_NDK_NETSTACK_E_BASE + 25), + OH_HTTP_UPLOAD_FAILED = (OH_HTTP_NETSTACK_E_BASE + 25), /** @brief Failed to open or read local data from the file or application. */ - HTTP_NDK_OPEN_LOCAL_DATA_FAILED = (HTTP_NDK_NETSTACK_E_BASE + 26), + OH_HTTP_OPEN_LOCAL_DATA_FAILED = (OH_HTTP_NETSTACK_E_BASE + 26), /** @brief Out of memory. */ - HTTP_NDK_OUT_OF_MEMORY = (HTTP_NDK_NETSTACK_E_BASE + 27), + OH_HTTP_OUT_OF_MEMORY = (OH_HTTP_NETSTACK_E_BASE + 27), /** @brief Operation timeout. */ - HTTP_NDK_OPERATION_TIMEOUT = (HTTP_NDK_NETSTACK_E_BASE + 28), + OH_HTTP_OPERATION_TIMEOUT = (OH_HTTP_NETSTACK_E_BASE + 28), /** @brief The number of redirections reaches the maximum allowed. */ - HTTP_NDK_REDIRECTIONS_TOO_LARGE = (HTTP_NDK_NETSTACK_E_BASE + 47), + OH_HTTP_REDIRECTIONS_TOO_LARGE = (OH_HTTP_NETSTACK_E_BASE + 47), /** @brief The server returned nothing (no header or data). */ - HTTP_NDK_SERVER_RETURNED_NOTHING = (HTTP_NDK_NETSTACK_E_BASE + 52), + OH_HTTP_SERVER_RETURNED_NOTHING = (OH_HTTP_NETSTACK_E_BASE + 52), /** @brief Failed to send data to the peer. */ - HTTP_NDK_SEND_DATA_FAILED = (HTTP_NDK_NETSTACK_E_BASE + 55), + OH_HTTP_SEND_DATA_FAILED = (OH_HTTP_NETSTACK_E_BASE + 55), /** @brief Failed to receive data from the peer. */ - HTTP_NDK_RECEIVE_DATA_FAILED = (HTTP_NDK_NETSTACK_E_BASE + 56), + OH_HTTP_RECEIVE_DATA_FAILED = (OH_HTTP_NETSTACK_E_BASE + 56), /** @brief Local SSL certificate error. */ - HTTP_NDK_SSL_CERTIFICATE_ERROR = (HTTP_NDK_NETSTACK_E_BASE + 58), + OH_HTTP_SSL_CERTIFICATE_ERROR = (OH_HTTP_NETSTACK_E_BASE + 58), /** @brief The specified SSL cipher cannot be used. */ - HTTP_NDK_SSL_CIPHER_USED_ERROR = (HTTP_NDK_NETSTACK_E_BASE + 59), + OH_HTTP_SSL_CIPHER_USED_ERROR = (OH_HTTP_NETSTACK_E_BASE + 59), /** @brief Invalid SSL peer certificate or SSH remote key. */ - HTTP_NDK_INVALID_SSL_PEER_CERT = (HTTP_NDK_NETSTACK_E_BASE + 60), + OH_HTTP_INVALID_SSL_PEER_CERT = (OH_HTTP_NETSTACK_E_BASE + 60), /** @brief Invalid HTTP encoding format. */ - HTTP_NDK_INVALID_ENCODING_FORMAT = (HTTP_NDK_NETSTACK_E_BASE + 61), + OH_HTTP_INVALID_ENCODING_FORMAT = (OH_HTTP_NETSTACK_E_BASE + 61), /** @brief Maximum file size exceeded. */ - HTTP_NDK_FILE_TOO_LARGE = (HTTP_NDK_NETSTACK_E_BASE + 63), + OH_HTTP_FILE_TOO_LARGE = (OH_HTTP_NETSTACK_E_BASE + 63), /** @brief Remote disk full. */ - HTTP_NDK_REMOTE_DISK_FULL = (HTTP_NDK_NETSTACK_E_BASE + 70), + OH_HTTP_REMOTE_DISK_FULL = (OH_HTTP_NETSTACK_E_BASE + 70), /** @brief Remote file already exists. */ - HTTP_NDK_REMOTE_FILE_EXISTS = (HTTP_NDK_NETSTACK_E_BASE + 73), + OH_HTTP_REMOTE_FILE_EXISTS = (OH_HTTP_NETSTACK_E_BASE + 73), /** @brief The SSL CA certificate does not exist or is inaccessible. */ - HTTP_NDK_SSL_CA_NOT_EXIST = (HTTP_NDK_NETSTACK_E_BASE + 77), + OH_HTTP_SSL_CA_NOT_EXIST = (OH_HTTP_NETSTACK_E_BASE + 77), /** @brief Remote file not found. */ - HTTP_NDK_REMOTE_FILE_NOT_FOUND = (HTTP_NDK_NETSTACK_E_BASE + 78), + OH_HTTP_REMOTE_FILE_NOT_FOUND = (OH_HTTP_NETSTACK_E_BASE + 78), /** @brief Authentication error. */ - HTTP_NDK_AUTHENTICATION_ERROR = (HTTP_NDK_NETSTACK_E_BASE + 94), + OH_HTTP_AUTHENTICATION_ERROR = (OH_HTTP_NETSTACK_E_BASE + 94), /** @brief It is not allowed to access this domain. */ - HTTP_NDK_ACCESS_DOMAIN_NOT_ALLOWED = (HTTP_NDK_NETSTACK_E_BASE + 998), + OH_HTTP_ACCESS_DOMAIN_NOT_ALLOWED = (OH_HTTP_NETSTACK_E_BASE + 998), /** @brief Unknown error. */ - HTTP_NDK_UNKNOWN_ERROR = (HTTP_NDK_NETSTACK_E_BASE + 999) + OH_HTTP_UNKNOWN_ERROR = (OH_HTTP_NETSTACK_E_BASE + 999) } Http_ErrCode; /** @@ -126,83 +126,83 @@ typedef enum Http_ErrCode { */ typedef enum Http_ResponseCode { /** @brief The request was successful. */ - HTTP_NDK_OK = 200, + OH_HTTP_OK = 200, /** @brief Successfully requested and created a new resource. */ - HTTP_NDK_CREATED = 201, + OH_HTTP_CREATED = 201, /** @brief The request has been accepted but has not been processed completely. */ - HTTP_NDK_ACCEPTED = 202, + OH_HTTP_ACCEPTED = 202, /** @brief Unauthorized information. The request was successful. */ - HTTP_NDK_NOT_AUTHORITATIVE = 203, + OH_HTTP_NOT_AUTHORITATIVE = 203, /** @brief No content. The server successfully processed, but did not return content. */ - HTTP_NDK_NO_CONTENT = 204, + OH_HTTP_NO_CONTENT = 204, /** @brief Reset the content. */ - HTTP_NDK_RESET = 205, + OH_HTTP_RESET = 205, /** @brief Partial content. The server successfully processed some GET requests. */ - HTTP_NDK_PARTIAL = 206, + OH_HTTP_PARTIAL = 206, /** @brief Multiple options. */ - HTTP_NDK_MULT_CHOICE = 300, + OH_HTTP_MULT_CHOICE = 300, /** * @brief Permanently move. The requested resource has been permanently moved to a new URI, * and the returned information will include the new URI. The browser will automatically redirect to the new URI. */ - HTTP_NDK_MOVED_PERM = 301, + OH_HTTP_MOVED_PERM = 301, /** @brief Temporary movement. */ - HTTP_NDK_MOVED_TEMP = 302, + OH_HTTP_MOVED_TEMP = 302, /** @brief View other addresses. */ - HTTP_NDK_SEE_OTHER = 303, + OH_HTTP_SEE_OTHER = 303, /** @brief Not modified. */ - HTTP_NDK_NOT_MODIFIED = 304, + OH_HTTP_NOT_MODIFIED = 304, /** @brief Using proxies. */ - HTTP_NDK_USE_PROXY = 305, + OH_HTTP_USE_PROXY = 305, /** @brief The server cannot understand the syntax error error requested by the client. */ - HTTP_NDK_BAD_REQUEST = 400, + OH_HTTP_BAD_REQUEST = 400, /** @brief Request for user authentication. */ - HTTP_NDK_UNAUTHORIZED = 401, + OH_HTTP_UNAUTHORIZED = 401, /** @brief Reserved for future use. */ - HTTP_NDK_PAYMENT_REQUIRED = 402, + OH_HTTP_PAYMENT_REQUIRED = 402, /** @brief The server understands the request from the requesting client, but refuses to execute it. */ - HTTP_NDK_FORBIDDEN = 403, + OH_HTTP_FORBIDDEN = 403, /** @brief The server was unable to find resources (web pages) based on the client's request. */ - HTTP_NDK_NOT_FOUND = 404, + OH_HTTP_NOT_FOUND = 404, /** @brief The method in the client request is prohibited. */ - HTTP_NDK_BAD_METHOD = 405, + OH_HTTP_BAD_METHOD = 405, /** @brief The server unabled to complete request based on the content characteristics requested by the client. */ - HTTP_NDK_NOT_ACCEPTABLE = 406, + OH_HTTP_NOT_ACCEPTABLE = 406, /** @brief Request authentication of the proxy's identity. */ - HTTP_NDK_PROXY_AUTH = 407, + OH_HTTP_PROXY_AUTH = 407, /** @brief The request took too long and timed out. */ - HTTP_NDK_CLIENT_TIMEOUT = 408, + OH_HTTP_CLIENT_TIMEOUT = 408, /** * @brief The server may have returned this code when completing the client's PUT request, * as there was a conflict when the server was processing the request. */ - HTTP_NDK_CONFLICT = 409, + OH_HTTP_CONFLICT = 409, /** @brief The resource requested by the client no longer exists. */ - HTTP_NDK_GONE = 410, + OH_HTTP_GONE = 410, /** @brief The server is unable to process request information sent by the client without Content Length. */ - HTTP_NDK_LENGTH_REQUIRED = 411, + OH_HTTP_LENGTH_REQUIRED = 411, /** @brief The prerequisite for requesting information from the client is incorrect. */ - HTTP_NDK_PRECON_FAILED = 412, + OH_HTTP_PRECON_FAILED = 412, /** @brief The request was rejected because the requested entity was too large for the server to process. */ - HTTP_NDK_ENTITY_TOO_LARGE = 413, + OH_HTTP_ENTITY_TOO_LARGE = 413, /** @brief The requested URI is too long (usually a URL) and the server cannot process it. */ - HTTP_NDK_REQ_TOO_LONG = 414, + OH_HTTP_REQ_TOO_LONG = 414, /** @brief The server is unable to process the requested format. */ - HTTP_NDK_UNSUPPORTED_TYPE = 415, + OH_HTTP_UNSUPPORTED_TYPE = 415, /** @brief Requested Range not satisfiable. */ - HTTP_NDK_RANGE_NOT_SATISFIABLE = 416, + OH_HTTP_RANGE_NOT_SATISFIABLE = 416, /** @brief Internal server error, unable to complete the request. */ - HTTP_NDK_INTERNAL_ERROR = 500, + OH_HTTP_INTERNAL_ERROR = 500, /** @brief * The server does not support the requested functionality and cannot complete the request. */ - HTTP_NDK_NOT_IMPLEMENTED = 501, + OH_HTTP_NOT_IMPLEMENTED = 501, /** @brief The server acting as a gateway or proxy received an invalid request from the remote server. */ - HTTP_NDK_BAD_GATEWAY = 502, + OH_HTTP_BAD_GATEWAY = 502, /** @brief Due to overload or system maintenance, the server is temporarily unable to process client requests. */ - HTTP_NDK_UNAVAILABLE = 503, + OH_HTTP_UNAVAILABLE = 503, /** @brief The server acting as gateway did not obtain requests from the remote server in a timely manner. */ - HTTP_NDK_GATEWAY_TIMEOUT = 504, + OH_HTTP_GATEWAY_TIMEOUT = 504, /** @brief The version of the HTTP protocol requested by the server. */ - HTTP_NDK_VERSION = 505 + OH_HTTP_VERSION = 505 } Http_ResponseCode; /** -- Gitee From f35887250cd0b9c02417440bb7ebd4ab0c6a7116 Mon Sep 17 00:00:00 2001 From: liuleimin_hw Date: Mon, 26 May 2025 14:27:13 +0000 Subject: [PATCH 11/13] update network/netstack/net_http/net_http_type.h. Signed-off-by: liuleimin_hw --- network/netstack/net_http/net_http_type.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/network/netstack/net_http/net_http_type.h b/network/netstack/net_http/net_http_type.h index 0c0055ba1..0ff183be8 100644 --- a/network/netstack/net_http/net_http_type.h +++ b/network/netstack/net_http/net_http_type.h @@ -224,11 +224,11 @@ typedef struct Http_Buffer { */ typedef enum Http_AddressFamilyType { /** Default, The system automatically selects the IPv4 or IPv6 address of the domain name. */ - DEFAULT = 0, + HTTP_ADDRESS_FAIMILY_DEFAULT = 0, /** IPv4, Selects the IPv4 address of the domain name. */ - ONLY_V4 = 1, + HTTP_ADDRESS_FAIMILY_ONLY_V4 = 1, /** IPv6, Selects the IPv4 address of the domain name. */ - ONLY_V6 = 2 + HTTP_ADDRESS_FAIMILY_ONLY_V6 = 2 } Http_AddressFamilyType; /** @@ -292,13 +292,13 @@ typedef enum Http_AddressFamilyType { */ typedef enum Http_HttpProtocol { /** Default choose by curl. */ - HTTP_NONE = 0, + OH_HTTP_NONE = 0, /** HTTP 1.1 version. */ - HTTP1_1, + OH_HTTP1_1, /** HTTP 2 version. */ - HTTP2, + OH_HTTP2, /** HTTP 3 version. */ - HTTP3 + OH_HTTP3 } Http_HttpProtocol; /** @@ -308,11 +308,11 @@ typedef enum Http_HttpProtocol { */ typedef enum Http_CertType { /** PEM Cert Type. */ - PEM = 0, + OH_HTTP_PEM = 0, /** DER Cert Type. */ - DER = 1, + OH_HTTP_DER = 1, /** P12 Cert Type. */ - P12 = 2 + OH_HTTP_P12 = 2 } Http_CertType; /** -- Gitee From 000c10d82433ec9df3b4305ab92be26555ed0e4f Mon Sep 17 00:00:00 2001 From: liuleimin_hw Date: Mon, 26 May 2025 14:28:34 +0000 Subject: [PATCH 12/13] update network/netstack/net_http/net_http_type.h. Signed-off-by: liuleimin_hw --- network/netstack/net_http/net_http_type.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/network/netstack/net_http/net_http_type.h b/network/netstack/net_http/net_http_type.h index 0ff183be8..849d50845 100644 --- a/network/netstack/net_http/net_http_type.h +++ b/network/netstack/net_http/net_http_type.h @@ -224,11 +224,11 @@ typedef struct Http_Buffer { */ typedef enum Http_AddressFamilyType { /** Default, The system automatically selects the IPv4 or IPv6 address of the domain name. */ - HTTP_ADDRESS_FAIMILY_DEFAULT = 0, + HTTP_ADDRESS_FAMILY_DEFAULT = 0, /** IPv4, Selects the IPv4 address of the domain name. */ - HTTP_ADDRESS_FAIMILY_ONLY_V4 = 1, + HTTP_ADDRESS_FAMILY_ONLY_V4 = 1, /** IPv6, Selects the IPv4 address of the domain name. */ - HTTP_ADDRESS_FAIMILY_ONLY_V6 = 2 + HTTP_ADDRESS_FAMILY_ONLY_V6 = 2 } Http_AddressFamilyType; /** -- Gitee From 956440b55fa60e1e83747793e18673a8b48adc18 Mon Sep 17 00:00:00 2001 From: liuleimin_hw Date: Mon, 26 May 2025 15:13:45 +0000 Subject: [PATCH 13/13] update network/netstack/net_http/net_http_type.h. Signed-off-by: liuleimin_hw --- network/netstack/net_http/net_http_type.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/network/netstack/net_http/net_http_type.h b/network/netstack/net_http/net_http_type.h index 849d50845..f02019792 100644 --- a/network/netstack/net_http/net_http_type.h +++ b/network/netstack/net_http/net_http_type.h @@ -86,7 +86,7 @@ typedef enum Http_ErrCode { /** @brief Operation timeout. */ OH_HTTP_OPERATION_TIMEOUT = (OH_HTTP_NETSTACK_E_BASE + 28), /** @brief The number of redirections reaches the maximum allowed. */ - OH_HTTP_REDIRECTIONS_TOO_LARGE = (OH_HTTP_NETSTACK_E_BASE + 47), + OH_HTTP_TOO_MANY_REDIRECTIONS = (OH_HTTP_NETSTACK_E_BASE + 47), /** @brief The server returned nothing (no header or data). */ OH_HTTP_SERVER_RETURNED_NOTHING = (OH_HTTP_NETSTACK_E_BASE + 52), /** @brief Failed to send data to the peer. */ @@ -193,7 +193,7 @@ typedef enum Http_ResponseCode { OH_HTTP_RANGE_NOT_SATISFIABLE = 416, /** @brief Internal server error, unable to complete the request. */ OH_HTTP_INTERNAL_ERROR = 500, - /** @brief * The server does not support the requested functionality and cannot complete the request. */ + /** @brief The server does not support the requested functionality and cannot complete the request. */ OH_HTTP_NOT_IMPLEMENTED = 501, /** @brief The server acting as a gateway or proxy received an invalid request from the remote server. */ OH_HTTP_BAD_GATEWAY = 502, -- Gitee