diff --git a/api/@ohos.net.http.d.ts b/api/@ohos.net.http.d.ts index 056e9aa0a4b07fce4099d93c7e5f892bffdb22e5..14234ae7d3ba577364592caef99485b0c8949ba9 100644 --- a/api/@ohos.net.http.d.ts +++ b/api/@ohos.net.http.d.ts @@ -897,6 +897,48 @@ declare namespace http { * @atomicservice * @since 11 */ + /** + * Initiates an HTTP request to a given URL. + * @permission ohos.permission.INTERNET + * @param { string } url - URL for initiating an HTTP request. + * @param { AsyncCallback } callback - the callback of request. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2300001 - Unsupported protocol. + * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. + * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. + * @throws { BusinessError } 2300006 - Failed to resolve the host name. + * @throws { BusinessError } 2300007 - Failed to connect to the server. + * @throws { BusinessError } 2300008 - Invalid server response. + * @throws { BusinessError } 2300009 - Access to the remote resource denied. + * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. + * @throws { BusinessError } 2300018 - Transferred a partial file. + * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. + * @throws { BusinessError } 2300025 - Upload failed. + * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. + * @throws { BusinessError } 2300027 - Out of memory. + * @throws { BusinessError } 2300028 - Operation timeout. + * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. + * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). + * @throws { BusinessError } 2300055 - Failed to send data to the peer. + * @throws { BusinessError } 2300056 - Failed to receive data from the peer. + * @throws { BusinessError } 2300058 - Local SSL certificate error. + * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. + * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. + * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. + * @throws { BusinessError } 2300063 - Maximum file size exceeded. + * @throws { BusinessError } 2300070 - Remote disk full. + * @throws { BusinessError } 2300073 - Remote file already exists. + * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. + * @throws { BusinessError } 2300078 - Remote file not found. + * @throws { BusinessError } 2300094 - Authentication error. + * @throws { BusinessError } 2300998 - It is not allowed to access this domain. + * @throws { BusinessError } 2300999 - Unknown error. + * @syscap SystemCapability.Communication.NetStack + * @crossplatform + * @atomicservice + * @since 12 + */ request(url: string, callback: AsyncCallback): void; /** @@ -1022,6 +1064,49 @@ declare namespace http { * @atomicservice * @since 11 */ + /** + * Initiates an HTTP request to a given URL. + * @permission ohos.permission.INTERNET + * @param { string } url - URL for initiating an HTTP request. + * @param { HttpRequestOptions } options - Optional parameters {@link HttpRequestOptions}. + * @param { AsyncCallback } callback - the callback of request. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2300001 - Unsupported protocol. + * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. + * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. + * @throws { BusinessError } 2300006 - Failed to resolve the host name. + * @throws { BusinessError } 2300007 - Failed to connect to the server. + * @throws { BusinessError } 2300008 - Invalid server response. + * @throws { BusinessError } 2300009 - Access to the remote resource denied. + * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. + * @throws { BusinessError } 2300018 - Transferred a partial file. + * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. + * @throws { BusinessError } 2300025 - Upload failed. + * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. + * @throws { BusinessError } 2300027 - Out of memory. + * @throws { BusinessError } 2300028 - Operation timeout. + * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. + * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). + * @throws { BusinessError } 2300055 - Failed to send data to the peer. + * @throws { BusinessError } 2300056 - Failed to receive data from the peer. + * @throws { BusinessError } 2300058 - Local SSL certificate error. + * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. + * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. + * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. + * @throws { BusinessError } 2300063 - Maximum file size exceeded. + * @throws { BusinessError } 2300070 - Remote disk full. + * @throws { BusinessError } 2300073 - Remote file already exists. + * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. + * @throws { BusinessError } 2300078 - Remote file not found. + * @throws { BusinessError } 2300094 - Authentication error. + * @throws { BusinessError } 2300998 - It is not allowed to access this domain. + * @throws { BusinessError } 2300999 - Unknown error. + * @syscap SystemCapability.Communication.NetStack + * @crossplatform + * @atomicservice + * @since 12 + */ request(url: string, options: HttpRequestOptions, callback: AsyncCallback): void; /** @@ -1147,6 +1232,49 @@ declare namespace http { * @atomicservice * @since 11 */ + /** + * Initiates an HTTP request to a given URL. + * @permission ohos.permission.INTERNET + * @param { string } url - URL for initiating an HTTP request. + * @param { HttpRequestOptions } [options] - Optional parameters {@link HttpRequestOptions}. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2300001 - Unsupported protocol. + * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. + * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. + * @throws { BusinessError } 2300006 - Failed to resolve the host name. + * @throws { BusinessError } 2300007 - Failed to connect to the server. + * @throws { BusinessError } 2300008 - Invalid server response. + * @throws { BusinessError } 2300009 - Access to the remote resource denied. + * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. + * @throws { BusinessError } 2300018 - Transferred a partial file. + * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. + * @throws { BusinessError } 2300025 - Upload failed. + * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. + * @throws { BusinessError } 2300027 - Out of memory. + * @throws { BusinessError } 2300028 - Operation timeout. + * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. + * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). + * @throws { BusinessError } 2300055 - Failed to send data to the peer. + * @throws { BusinessError } 2300056 - Failed to receive data from the peer. + * @throws { BusinessError } 2300058 - Local SSL certificate error. + * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. + * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. + * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. + * @throws { BusinessError } 2300063 - Maximum file size exceeded. + * @throws { BusinessError } 2300070 - Remote disk full. + * @throws { BusinessError } 2300073 - Remote file already exists. + * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. + * @throws { BusinessError } 2300078 - Remote file not found. + * @throws { BusinessError } 2300094 - Authentication error. + * @throws { BusinessError } 2300998 - It is not allowed to access this domain. + * @throws { BusinessError } 2300999 - Unknown error. + * @syscap SystemCapability.Communication.NetStack + * @crossplatform + * @atomicservice + * @since 12 + */ request(url: string, options?: HttpRequestOptions): Promise; /** @@ -1189,6 +1317,47 @@ declare namespace http { * @syscap SystemCapability.Communication.NetStack * @since 10 */ + /** + * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. + * @permission ohos.permission.INTERNET + * @param { string } url - URL for initiating an HTTP request. + * @param { AsyncCallback } callback - Returns the callback of requestInStream {@link ResponseCode}, + * should use on_headersReceive and on_dataReceive to get http response. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2300001 - Unsupported protocol. + * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. + * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. + * @throws { BusinessError } 2300006 - Failed to resolve the host name. + * @throws { BusinessError } 2300007 - Failed to connect to the server. + * @throws { BusinessError } 2300008 - Invalid server response. + * @throws { BusinessError } 2300009 - Access to the remote resource denied. + * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. + * @throws { BusinessError } 2300018 - Transferred a partial file. + * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. + * @throws { BusinessError } 2300025 - Upload failed. + * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. + * @throws { BusinessError } 2300027 - Out of memory. + * @throws { BusinessError } 2300028 - Operation timeout. + * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. + * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). + * @throws { BusinessError } 2300055 - Failed to send data to the peer. + * @throws { BusinessError } 2300056 - Failed to receive data from the peer. + * @throws { BusinessError } 2300058 - Local SSL certificate error. + * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. + * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. + * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. + * @throws { BusinessError } 2300063 - Maximum file size exceeded. + * @throws { BusinessError } 2300070 - Remote disk full. + * @throws { BusinessError } 2300073 - Remote file already exists. + * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. + * @throws { BusinessError } 2300078 - Remote file not found. + * @throws { BusinessError } 2300094 - Authentication error. + * @throws { BusinessError } 2300998 - It is not allowed to access this domain. + * @throws { BusinessError } 2300999 - Unknown error. + * @syscap SystemCapability.Communication.NetStack + * @since 12 + */ requestInStream(url: string, callback: AsyncCallback): void; /** @@ -1231,6 +1400,47 @@ declare namespace http { * @syscap SystemCapability.Communication.NetStack * @since 10 */ + /** + * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. + * @permission ohos.permission.INTERNET + * @param { string } url - URL for initiating an HTTP request. + * @param { HttpRequestOptions } options - Optional parameters {@link HttpRequestOptions}. + * @param { AsyncCallback } callback - the callback of requestInStream. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2300001 - Unsupported protocol. + * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. + * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. + * @throws { BusinessError } 2300006 - Failed to resolve the host name. + * @throws { BusinessError } 2300007 - Failed to connect to the server. + * @throws { BusinessError } 2300008 - Invalid server response. + * @throws { BusinessError } 2300009 - Access to the remote resource denied. + * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. + * @throws { BusinessError } 2300018 - Transferred a partial file. + * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. + * @throws { BusinessError } 2300025 - Upload failed. + * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. + * @throws { BusinessError } 2300027 - Out of memory. + * @throws { BusinessError } 2300028 - Operation timeout. + * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. + * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). + * @throws { BusinessError } 2300055 - Failed to send data to the peer. + * @throws { BusinessError } 2300056 - Failed to receive data from the peer. + * @throws { BusinessError } 2300058 - Local SSL certificate error. + * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. + * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. + * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. + * @throws { BusinessError } 2300063 - Maximum file size exceeded. + * @throws { BusinessError } 2300070 - Remote disk full. + * @throws { BusinessError } 2300073 - Remote file already exists. + * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. + * @throws { BusinessError } 2300078 - Remote file not found. + * @throws { BusinessError } 2300094 - Authentication error. + * @throws { BusinessError } 2300998 - It is not allowed to access this domain. + * @throws { BusinessError } 2300999 - Unknown error. + * @syscap SystemCapability.Communication.NetStack + * @since 12 + */ requestInStream(url: string, options: HttpRequestOptions, callback: AsyncCallback): void; /** @@ -1273,6 +1483,47 @@ declare namespace http { * @syscap SystemCapability.Communication.NetStack * @since 10 */ + /** + * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. + * @permission ohos.permission.INTERNET + * @param { string } url - URL for initiating an HTTP request. + * @param { HttpRequestOptions } [options] - Optional parameters {@link HttpRequestOptions}. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2300001 - Unsupported protocol. + * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. + * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. + * @throws { BusinessError } 2300006 - Failed to resolve the host name. + * @throws { BusinessError } 2300007 - Failed to connect to the server. + * @throws { BusinessError } 2300008 - Invalid server response. + * @throws { BusinessError } 2300009 - Access to the remote resource denied. + * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. + * @throws { BusinessError } 2300018 - Transferred a partial file. + * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. + * @throws { BusinessError } 2300025 - Upload failed. + * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. + * @throws { BusinessError } 2300027 - Out of memory. + * @throws { BusinessError } 2300028 - Operation timeout. + * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. + * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). + * @throws { BusinessError } 2300055 - Failed to send data to the peer. + * @throws { BusinessError } 2300056 - Failed to receive data from the peer. + * @throws { BusinessError } 2300058 - Local SSL certificate error. + * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. + * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. + * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. + * @throws { BusinessError } 2300063 - Maximum file size exceeded. + * @throws { BusinessError } 2300070 - Remote disk full. + * @throws { BusinessError } 2300073 - Remote file already exists. + * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. + * @throws { BusinessError } 2300078 - Remote file not found. + * @throws { BusinessError } 2300094 - Authentication error. + * @throws { BusinessError } 2300998 - It is not allowed to access this domain. + * @throws { BusinessError } 2300999 - Unknown error. + * @syscap SystemCapability.Communication.NetStack + * @since 12 + */ requestInStream(url: string, options?: HttpRequestOptions): Promise; /** diff --git a/api/@ohos.net.webSocket.d.ts b/api/@ohos.net.webSocket.d.ts index 8812ca63e3d9507889d4490c68ed96db2cb401f1..30729c55393cef1d920903fd1ff30cff03c0bc15 100644 --- a/api/@ohos.net.webSocket.d.ts +++ b/api/@ohos.net.webSocket.d.ts @@ -438,6 +438,7 @@ declare namespace webSocket { * @throws { BusinessError } 2302001 - Websocket url error. * @throws { BusinessError } 2302002 - Websocket certificate file does not exist. * @throws { BusinessError } 2302003 - Websocket connection already exists. + * @throws { BusinessError } 2302998 - It is not allowed to access this domain. * @throws { BusinessError } 2302999 - Websocket other unknown error. * @syscap SystemCapability.Communication.NetStack * @crossplatform @@ -495,6 +496,7 @@ declare namespace webSocket { * @throws { BusinessError } 2302001 - Websocket url error. * @throws { BusinessError } 2302002 - Websocket certificate file does not exist. * @throws { BusinessError } 2302003 - Websocket connection already exists. + * @throws { BusinessError } 2302998 - It is not allowed to access this domain. * @throws { BusinessError } 2302999 - Websocket other unknown error. * @syscap SystemCapability.Communication.NetStack * @crossplatform @@ -552,6 +554,7 @@ declare namespace webSocket { * @throws { BusinessError } 2302001 - Websocket url error. * @throws { BusinessError } 2302002 - Websocket certificate file does not exist. * @throws { BusinessError } 2302003 - Websocket connection already exists. + * @throws { BusinessError } 2302998 - It is not allowed to access this domain. * @throws { BusinessError } 2302999 - Websocket other unknown error. * @syscap SystemCapability.Communication.NetStack * @crossplatform