1/* 2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit NetworkKit 19 */ 20 21import type { AsyncCallback, Callback } from './@ohos.base'; 22import type connection from './@ohos.net.connection'; 23 24/** 25 * Provides http related APIs. 26 * @namespace http 27 * @syscap SystemCapability.Communication.NetStack 28 * @since 6 29 */ 30/** 31 * Provides http related APIs. 32 * @namespace http 33 * @syscap SystemCapability.Communication.NetStack 34 * @crossplatform 35 * @since 10 36 */ 37/** 38 * Provides http related APIs. 39 * @namespace http 40 * @syscap SystemCapability.Communication.NetStack 41 * @crossplatform 42 * @atomicservice 43 * @since 11 44 */ 45declare namespace http { 46 /** 47 * @syscap SystemCapability.Communication.NetStack 48 * @since 10 49 */ 50 /** 51 * @syscap SystemCapability.Communication.NetStack 52 * @atomicservice 53 * @since 11 54 */ 55 type HttpProxy = connection.HttpProxy; 56 57 /** 58 * Creates an HTTP request task. 59 * @returns { HttpRequest } the HttpRequest of the createHttp. 60 * @syscap SystemCapability.Communication.NetStack 61 * @since 6 62 */ 63 /** 64 * Creates an HTTP request task. 65 * @returns { HttpRequest } the HttpRequest of the createHttp. 66 * @syscap SystemCapability.Communication.NetStack 67 * @crossplatform 68 * @since 10 69 */ 70 /** 71 * Creates an HTTP request task. 72 * @returns { HttpRequest } the HttpRequest of the createHttp. 73 * @syscap SystemCapability.Communication.NetStack 74 * @crossplatform 75 * @atomicservice 76 * @since 11 77 */ 78 function createHttp(): HttpRequest; 79 80 /** 81 * Specifies the type and value range of the optional parameters in the HTTP request. 82 * @interface HttpRequestOptions 83 * @syscap SystemCapability.Communication.NetStack 84 * @since 6 85 */ 86 /** 87 * Specifies the type and value range of the optional parameters in the HTTP request. 88 * @interface HttpRequestOptions 89 * @syscap SystemCapability.Communication.NetStack 90 * @crossplatform 91 * @since 10 92 */ 93 /** 94 * Specifies the type and value range of the optional parameters in the HTTP request. 95 * @interface HttpRequestOptions 96 * @syscap SystemCapability.Communication.NetStack 97 * @crossplatform 98 * @atomicservice 99 * @since 11 100 */ 101 export interface HttpRequestOptions { 102 /** 103 * Request method,default is GET. 104 * @type {?RequestMethod} 105 * @syscap SystemCapability.Communication.NetStack 106 * @since 6 107 */ 108 /** 109 * Request method,default is GET. 110 * @type {?RequestMethod} 111 * @syscap SystemCapability.Communication.NetStack 112 * @crossplatform 113 * @since 10 114 */ 115 /** 116 * Request method,default is GET. 117 * @type {?RequestMethod} 118 * @syscap SystemCapability.Communication.NetStack 119 * @crossplatform 120 * @atomicservice 121 * @since 11 122 */ 123 method?: RequestMethod; 124 125 /** 126 * Additional data of the request. 127 * extraData can be a string or an Object (API 6) or an ArrayBuffer(API 8). 128 * @type {?string | Object | ArrayBuffer} 129 * @syscap SystemCapability.Communication.NetStack 130 * @since 6 131 */ 132 /** 133 * Additional data of the request. 134 * extraData can be a string or an Object (API 6) or an ArrayBuffer(API 8). 135 * @type {?string | Object | ArrayBuffer} 136 * @syscap SystemCapability.Communication.NetStack 137 * @crossplatform 138 * @since 10 139 */ 140 /** 141 * Additional data of the request. 142 * extraData can be a string or an Object (API 6) or an ArrayBuffer(API 8). 143 * @type { ?(string | Object | ArrayBuffer) } 144 * @syscap SystemCapability.Communication.NetStack 145 * @crossplatform 146 * @atomicservice 147 * @since 11 148 */ 149 extraData?: string | Object | ArrayBuffer; 150 151 /** 152 * Data type to be returned. If this parameter is set, the system preferentially returns the specified type. 153 * @type {?HttpDataType} 154 * @syscap SystemCapability.Communication.NetStack 155 * @since 9 156 */ 157 /** 158 * Data type to be returned. If this parameter is set, the system preferentially returns the specified type. 159 * @type {?HttpDataType} 160 * @syscap SystemCapability.Communication.NetStack 161 * @crossplatform 162 * @since 10 163 */ 164 /** 165 * Data type to be returned. If this parameter is set, the system preferentially returns the specified type. 166 * @type {?HttpDataType} 167 * @syscap SystemCapability.Communication.NetStack 168 * @crossplatform 169 * @atomicservice 170 * @since 11 171 */ 172 expectDataType?: HttpDataType; 173 174 /** 175 * default is true 176 * @type {?boolean} 177 * @syscap SystemCapability.Communication.NetStack 178 * @since 9 179 */ 180 /** 181 * default is true 182 * @type {?boolean} 183 * @syscap SystemCapability.Communication.NetStack 184 * @crossplatform 185 * @since 10 186 */ 187 /** 188 * default is true 189 * @type {?boolean} 190 * @syscap SystemCapability.Communication.NetStack 191 * @crossplatform 192 * @atomicservice 193 * @since 11 194 */ 195 usingCache?: boolean; 196 197 /** 198 * [1, 1000], default is 1. 199 * @type {?number} 200 * @syscap SystemCapability.Communication.NetStack 201 * @since 9 202 */ 203 /** 204 * [1, 1000], default is 1. 205 * @type {?number} 206 * @syscap SystemCapability.Communication.NetStack 207 * @crossplatform 208 * @since 10 209 */ 210 /** 211 * [1, 1000], default is 1. 212 * @type {?number} 213 * @syscap SystemCapability.Communication.NetStack 214 * @crossplatform 215 * @atomicservice 216 * @since 11 217 */ 218 priority?: number; 219 220 /** 221 * HTTP request header. default is 'content-type': 'application/json' 222 * @type {?Object} 223 * @syscap SystemCapability.Communication.NetStack 224 * @since 6 225 */ 226 /** 227 * HTTP request header. default is 'content-type': 'application/json' 228 * @type {?Object} 229 * @syscap SystemCapability.Communication.NetStack 230 * @crossplatform 231 * @since 10 232 */ 233 /** 234 * HTTP request header. default is 'content-type': 'application/json' 235 * @type {?Object} 236 * @syscap SystemCapability.Communication.NetStack 237 * @crossplatform 238 * @atomicservice 239 * @since 11 240 */ 241 header?: Object; 242 243 /** 244 * Read timeout period. The default value is 60,000, in ms. 245 * @type {?number} 246 * @syscap SystemCapability.Communication.NetStack 247 * @since 6 248 */ 249 /** 250 * Read timeout period. The default value is 60,000, in ms. 251 * @type {?number} 252 * @syscap SystemCapability.Communication.NetStack 253 * @crossplatform 254 * @since 10 255 */ 256 /** 257 * Read timeout period. The default value is 60,000, in ms. 258 * @type {?number} 259 * @syscap SystemCapability.Communication.NetStack 260 * @crossplatform 261 * @atomicservice 262 * @since 11 263 */ 264 readTimeout?: number; 265 266 /** 267 * Connection timeout interval. The default value is 60,000, in ms. 268 * @type {?number} 269 * @syscap SystemCapability.Communication.NetStack 270 * @since 6 271 */ 272 /** 273 * Connection timeout interval. The default value is 60,000, in ms. 274 * @type {?number} 275 * @syscap SystemCapability.Communication.NetStack 276 * @crossplatform 277 * @since 10 278 */ 279 /** 280 * Connection timeout interval. The default value is 60,000, in ms. 281 * @type {?number} 282 * @syscap SystemCapability.Communication.NetStack 283 * @crossplatform 284 * @atomicservice 285 * @since 11 286 */ 287 connectTimeout?: number; 288 289 /** 290 * default is automatically specified by the system. 291 * @type {?HttpProtocol} 292 * @syscap SystemCapability.Communication.NetStack 293 * @since 9 294 */ 295 /** 296 * default is automatically specified by the system. 297 * @type {?HttpProtocol} 298 * @syscap SystemCapability.Communication.NetStack 299 * @crossplatform 300 * @since 10 301 */ 302 /** 303 * default is automatically specified by the system. 304 * @type {?HttpProtocol} 305 * @syscap SystemCapability.Communication.NetStack 306 * @crossplatform 307 * @atomicservice 308 * @since 11 309 */ 310 usingProtocol?: HttpProtocol; 311 312 /** 313 * If this parameter is set as type of boolean, the system will use default proxy or not use proxy. 314 * If this parameter is set as type of HttpProxy, the system will use the specified HttpProxy. 315 * @type {?boolean | HttpProxy} 316 * @syscap SystemCapability.Communication.NetStack 317 * @since 10 318 */ 319 /** 320 * If this parameter is set as type of boolean, the system will use default proxy or not use proxy. 321 * If this parameter is set as type of HttpProxy, the system will use the specified HttpProxy. 322 * @type { ?(boolean | HttpProxy) } 323 * @syscap SystemCapability.Communication.NetStack 324 * @atomicservice 325 * @since 11 326 */ 327 usingProxy?: boolean | HttpProxy; 328 329 /** 330 * If this parameter is set, the system will use ca path specified by user, or else use preset ca by the system. 331 * @type {?string} 332 * @syscap SystemCapability.Communication.NetStack 333 * @since 10 334 */ 335 /** 336 * If this parameter is set, the system will use ca path specified by user, or else use preset ca by the system. 337 * @type {?string} 338 * @syscap SystemCapability.Communication.NetStack 339 * @atomicservice 340 * @since 11 341 */ 342 caPath?: string; 343 344 /** 345 * Used to set to uploading or downloading the start bytes. The default value is 0. 346 * HTTP standard (RFC 7233 section 3.1) allows servers to ignore range requests. 347 * For HTTP PUT uploads this option should not be used, since it may conflict with other options. 348 * @type {?number} 349 * @syscap SystemCapability.Communication.NetStack 350 * @since 11 351 */ 352 resumeFrom?: number; 353 354 /** 355 * Used to set to uploading or downloading the end bytes. Translate to the end if not set. 356 * HTTP standard (RFC 7233 section 3.1) allows servers to ignore range requests. 357 * For HTTP PUT uploads this option should not be used, since it may conflict with other options. 358 * @type {?number} 359 * @syscap SystemCapability.Communication.NetStack 360 * @since 11 361 */ 362 resumeTo?: number; 363 364 /** 365 * Support the application to pass in client certificates, allowing the server to verify the client's identity. 366 * @type {?ClientCert} 367 * @syscap SystemCapability.Communication.NetStack 368 * @since 11 369 */ 370 clientCert?: ClientCert; 371 372 /** 373 * If this parameter is set, incoming DNS resolution server URL for the DoH server to use for name resolving. 374 * The parameter must be URL-encoded in the following format: "https://host:port/path". 375 * It MUST specify an HTTPS URL. 376 * @type {?string} 377 * @syscap SystemCapability.Communication.NetStack 378 * @since 11 379 */ 380 dnsOverHttps?: string; 381 382 /** 383 * If this parameter is set, use the specified DNS server for DNS resolution. 384 * Multiple DNS resolution servers can be set up, with a maximum of 3 servers. 385 * Only take the first three if there are more than three. 386 * @type {?Array<string>} 387 * @syscap SystemCapability.Communication.NetStack 388 * @since 11 389 */ 390 dnsServers?: Array<string>; 391 392 /** 393 * The maximum limit of the response body. The default value is 5 * 1024 * 1024, in Byte. 394 * The maximum value is 100 * 1024 *1024, in Byte. 395 * @type {?number} 396 * @syscap SystemCapability.Communication.NetStack 397 * @since 11 398 */ 399 maxLimit?: number; 400 401 /** 402 * The data fields which is supported by the HTTP protocol to post 403 * forms and by the SMTP and IMAP protocols to provide 404 * the email data to send/upload. 405 * @type {?Array<MultiFormData>} 406 * @syscap SystemCapability.Communication.NetStack 407 * @since 11 408 */ 409 multiFormDataList?: Array<MultiFormData>; 410 } 411 412 /** 413 * Represents the properties of a form object. 414 * @interface MultiFormData 415 * @syscap SystemCapability.Communication.NetStack 416 * @since 11 417 */ 418 export interface MultiFormData { 419 /** 420 * MIME name for the data field. 421 * @type {string} 422 * @syscap SystemCapability.Communication.NetStack 423 * @since 11 424 */ 425 name: string; 426 427 /** 428 * Content type of the data field. 429 * @type {string} 430 * @syscap SystemCapability.Communication.NetStack 431 * @since 11 432 */ 433 contentType: string; 434 435 /** 436 * Remote file name for the data field. 437 * @type {?string} 438 * @syscap SystemCapability.Communication.NetStack 439 * @since 11 440 */ 441 remoteFileName?: string; 442 443 /** 444 * This parameter sets a mime part's body content from memory data. 445 * @type {?(string | Object | ArrayBuffer)} 446 * @syscap SystemCapability.Communication.NetStack 447 * @since 11 448 */ 449 data?: string | Object | ArrayBuffer; 450 451 /** 452 * This parameter sets a mime part's body content from the file's contents. 453 * This is an alternative to curl_mime_data for setting data to a mime part. 454 * If data is empty, filePath must be set. 455 * If data has a value, filePath does not take effect. 456 * @type {?string} 457 * @syscap SystemCapability.Communication.NetStack 458 * @since 11 459 */ 460 filePath?: string; 461 } 462 463 /** 464 * Enum for certificate types 465 * @enum {string} 466 * @syscap SystemCapability.Communication.NetStack 467 * @since 11 468 */ 469 export enum CertType { 470 /** 471 * PEM format certificate 472 * @syscap SystemCapability.Communication.NetStack 473 * @since 11 474 */ 475 PEM = 'PEM', 476 477 /** 478 * DER format certificate 479 * @syscap SystemCapability.Communication.NetStack 480 * @since 11 481 */ 482 DER = 'DER', 483 484 /** 485 * P12 format certificate 486 * @syscap SystemCapability.Communication.NetStack 487 * @since 11 488 */ 489 P12 = 'P12' 490 } 491 492 /** 493 * The clientCert field of the client certificate, which includes 4 attributes: 494 * client certificate (cert), client certificate type (certType), certificate private key (key), and passphrase (keyPassword). 495 * @interface ClientCert 496 * @syscap SystemCapability.Communication.NetStack 497 * @since 11 498 */ 499 export interface ClientCert { 500 /** 501 * The path to the client certificate file. 502 * @type {string} 503 * @syscap SystemCapability.Communication.NetStack 504 * @since 11 505 */ 506 certPath: string; 507 508 /** 509 * The type of the client certificate. 510 * @type {?CertType} 511 * @syscap SystemCapability.Communication.NetStack 512 * @since 11 513 */ 514 certType?: CertType; 515 516 /** 517 * The path of the client certificate private key file. 518 * @type {string} 519 * @syscap SystemCapability.Communication.NetStack 520 * @since 11 521 */ 522 keyPath: string; 523 524 /** 525 * Password required to use the client certificate private key. 526 * @type {?string} 527 * @syscap SystemCapability.Communication.NetStack 528 * @since 11 529 */ 530 keyPassword?: string; 531 } 532 533 /** 534 * <p>Defines an HTTP request task. Before invoking APIs provided by HttpRequest, 535 * you must call createHttp() to create an HttpRequestTask object.</p> 536 * @interface HttpRequest 537 * @syscap SystemCapability.Communication.NetStack 538 * @since 6 539 */ 540 /** 541 * <p>Defines an HTTP request task. Before invoking APIs provided by HttpRequest, 542 * you must call createHttp() to create an HttpRequestTask object.</p> 543 * @interface HttpRequest 544 * @syscap SystemCapability.Communication.NetStack 545 * @crossplatform 546 * @since 10 547 */ 548 /** 549 * <p>Defines an HTTP request task. Before invoking APIs provided by HttpRequest, 550 * you must call createHttp() to create an HttpRequestTask object.</p> 551 * @interface HttpRequest 552 * @syscap SystemCapability.Communication.NetStack 553 * @crossplatform 554 * @atomicservice 555 * @since 11 556 */ 557 export interface HttpRequest { 558 /** 559 * Initiates an HTTP request to a given URL. 560 * @permission ohos.permission.INTERNET 561 * @param { string } url - URL for initiating an HTTP request. 562 * @param { AsyncCallback<HttpResponse> } callback - the callback of request. 563 * @throws { BusinessError } 401 - Parameter error. 564 * @throws { BusinessError } 201 - Permission denied. 565 * @throws { BusinessError } 2300001 - Unsupported protocol. 566 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 567 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 568 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 569 * @throws { BusinessError } 2300007 - Failed to connect to the server. 570 * @throws { BusinessError } 2300008 - Invalid server response. 571 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 572 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 573 * @throws { BusinessError } 2300018 - Transferred a partial file. 574 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 575 * @throws { BusinessError } 2300025 - Upload failed. 576 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 577 * @throws { BusinessError } 2300027 - Out of memory. 578 * @throws { BusinessError } 2300028 - Operation timeout. 579 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 580 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 581 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 582 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 583 * @throws { BusinessError } 2300058 - Local SSL certificate error. 584 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 585 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 586 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 587 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 588 * @throws { BusinessError } 2300070 - Remote disk full. 589 * @throws { BusinessError } 2300073 - Remote file already exists. 590 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is unaccessible. 591 * @throws { BusinessError } 2300078 - Remote file not found. 592 * @throws { BusinessError } 2300094 - Authentication error. 593 * @throws { BusinessError } 2300999 - Unknown error. 594 * @syscap SystemCapability.Communication.NetStack 595 * @since 6 596 */ 597 /** 598 * Initiates an HTTP request to a given URL. 599 * @permission ohos.permission.INTERNET 600 * @param { string } url - URL for initiating an HTTP request. 601 * @param { AsyncCallback<HttpResponse> } callback - the callback of request. 602 * @throws { BusinessError } 401 - Parameter error. 603 * @throws { BusinessError } 201 - Permission denied. 604 * @throws { BusinessError } 2300001 - Unsupported protocol. 605 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 606 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 607 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 608 * @throws { BusinessError } 2300007 - Failed to connect to the server. 609 * @throws { BusinessError } 2300008 - Invalid server response. 610 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 611 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 612 * @throws { BusinessError } 2300018 - Transferred a partial file. 613 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 614 * @throws { BusinessError } 2300025 - Upload failed. 615 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 616 * @throws { BusinessError } 2300027 - Out of memory. 617 * @throws { BusinessError } 2300028 - Operation timeout. 618 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 619 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 620 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 621 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 622 * @throws { BusinessError } 2300058 - Local SSL certificate error. 623 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 624 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 625 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 626 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 627 * @throws { BusinessError } 2300070 - Remote disk full. 628 * @throws { BusinessError } 2300073 - Remote file already exists. 629 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is unaccessible. 630 * @throws { BusinessError } 2300078 - Remote file not found. 631 * @throws { BusinessError } 2300094 - Authentication error. 632 * @throws { BusinessError } 2300999 - Unknown error. 633 * @syscap SystemCapability.Communication.NetStack 634 * @crossplatform 635 * @since 10 636 */ 637 /** 638 * Initiates an HTTP request to a given URL. 639 * @permission ohos.permission.INTERNET 640 * @param { string } url - URL for initiating an HTTP request. 641 * @param { AsyncCallback<HttpResponse> } callback - the callback of request. 642 * @throws { BusinessError } 401 - Parameter error. 643 * @throws { BusinessError } 201 - Permission denied. 644 * @throws { BusinessError } 2300001 - Unsupported protocol. 645 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 646 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 647 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 648 * @throws { BusinessError } 2300007 - Failed to connect to the server. 649 * @throws { BusinessError } 2300008 - Invalid server response. 650 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 651 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 652 * @throws { BusinessError } 2300018 - Transferred a partial file. 653 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 654 * @throws { BusinessError } 2300025 - Upload failed. 655 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 656 * @throws { BusinessError } 2300027 - Out of memory. 657 * @throws { BusinessError } 2300028 - Operation timeout. 658 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 659 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 660 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 661 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 662 * @throws { BusinessError } 2300058 - Local SSL certificate error. 663 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 664 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 665 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 666 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 667 * @throws { BusinessError } 2300070 - Remote disk full. 668 * @throws { BusinessError } 2300073 - Remote file already exists. 669 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is unaccessible. 670 * @throws { BusinessError } 2300078 - Remote file not found. 671 * @throws { BusinessError } 2300094 - Authentication error. 672 * @throws { BusinessError } 2300999 - Unknown error. 673 * @syscap SystemCapability.Communication.NetStack 674 * @crossplatform 675 * @atomicservice 676 * @since 11 677 */ 678 request(url: string, callback: AsyncCallback<HttpResponse>): void; 679 680 /** 681 * Initiates an HTTP request to a given URL. 682 * @permission ohos.permission.INTERNET 683 * @param { string } url - URL for initiating an HTTP request. 684 * @param { HttpRequestOptions } options - Optional parameters {@link HttpRequestOptions}. 685 * @param { AsyncCallback<HttpResponse> } callback - the callback of request.. 686 * @throws { BusinessError } 401 - Parameter error. 687 * @throws { BusinessError } 201 - Permission denied. 688 * @throws { BusinessError } 2300001 - Unsupported protocol. 689 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 690 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 691 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 692 * @throws { BusinessError } 2300007 - Failed to connect to the server. 693 * @throws { BusinessError } 2300008 - Invalid server response. 694 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 695 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 696 * @throws { BusinessError } 2300018 - Transferred a partial file. 697 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 698 * @throws { BusinessError } 2300025 - Upload failed. 699 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 700 * @throws { BusinessError } 2300027 - Out of memory. 701 * @throws { BusinessError } 2300028 - Operation timeout. 702 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 703 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 704 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 705 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 706 * @throws { BusinessError } 2300058 - Local SSL certificate error. 707 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 708 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 709 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 710 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 711 * @throws { BusinessError } 2300070 - Remote disk full. 712 * @throws { BusinessError } 2300073 - Remote file already exists. 713 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is unaccessible. 714 * @throws { BusinessError } 2300078 - Remote file not found. 715 * @throws { BusinessError } 2300094 - Authentication error. 716 * @throws { BusinessError } 2300999 - Unknown error. 717 * @syscap SystemCapability.Communication.NetStack 718 * @since 6 719 */ 720 /** 721 * Initiates an HTTP request to a given URL. 722 * @permission ohos.permission.INTERNET 723 * @param { string } url - URL for initiating an HTTP request. 724 * @param { HttpRequestOptions } options - Optional parameters {@link HttpRequestOptions}. 725 * @param { AsyncCallback<HttpResponse> } callback - the callback of request. 726 * @throws { BusinessError } 401 - Parameter error. 727 * @throws { BusinessError } 201 - Permission denied. 728 * @throws { BusinessError } 2300001 - Unsupported protocol. 729 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 730 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 731 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 732 * @throws { BusinessError } 2300007 - Failed to connect to the server. 733 * @throws { BusinessError } 2300008 - Invalid server response. 734 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 735 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 736 * @throws { BusinessError } 2300018 - Transferred a partial file. 737 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 738 * @throws { BusinessError } 2300025 - Upload failed. 739 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 740 * @throws { BusinessError } 2300027 - Out of memory. 741 * @throws { BusinessError } 2300028 - Operation timeout. 742 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 743 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 744 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 745 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 746 * @throws { BusinessError } 2300058 - Local SSL certificate error. 747 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 748 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 749 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 750 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 751 * @throws { BusinessError } 2300070 - Remote disk full. 752 * @throws { BusinessError } 2300073 - Remote file already exists. 753 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is unaccessible. 754 * @throws { BusinessError } 2300078 - Remote file not found. 755 * @throws { BusinessError } 2300094 - Authentication error. 756 * @throws { BusinessError } 2300999 - Unknown error. 757 * @syscap SystemCapability.Communication.NetStack 758 * @crossplatform 759 * @since 10 760 */ 761 /** 762 * Initiates an HTTP request to a given URL. 763 * @permission ohos.permission.INTERNET 764 * @param { string } url - URL for initiating an HTTP request. 765 * @param { HttpRequestOptions } options - Optional parameters {@link HttpRequestOptions}. 766 * @param { AsyncCallback<HttpResponse> } callback - the callback of request. 767 * @throws { BusinessError } 401 - Parameter error. 768 * @throws { BusinessError } 201 - Permission denied. 769 * @throws { BusinessError } 2300001 - Unsupported protocol. 770 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 771 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 772 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 773 * @throws { BusinessError } 2300007 - Failed to connect to the server. 774 * @throws { BusinessError } 2300008 - Invalid server response. 775 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 776 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 777 * @throws { BusinessError } 2300018 - Transferred a partial file. 778 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 779 * @throws { BusinessError } 2300025 - Upload failed. 780 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 781 * @throws { BusinessError } 2300027 - Out of memory. 782 * @throws { BusinessError } 2300028 - Operation timeout. 783 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 784 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 785 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 786 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 787 * @throws { BusinessError } 2300058 - Local SSL certificate error. 788 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 789 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 790 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 791 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 792 * @throws { BusinessError } 2300070 - Remote disk full. 793 * @throws { BusinessError } 2300073 - Remote file already exists. 794 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is unaccessible. 795 * @throws { BusinessError } 2300078 - Remote file not found. 796 * @throws { BusinessError } 2300094 - Authentication error. 797 * @throws { BusinessError } 2300999 - Unknown error. 798 * @syscap SystemCapability.Communication.NetStack 799 * @crossplatform 800 * @atomicservice 801 * @since 11 802 */ 803 request(url: string, options: HttpRequestOptions, callback: AsyncCallback<HttpResponse>): void; 804 805 /** 806 * Initiates an HTTP request to a given URL. 807 * @permission ohos.permission.INTERNET 808 * @param { string } url - URL for initiating an HTTP request. 809 * @param { HttpRequestOptions } [options] - Optional parameters {@link HttpRequestOptions}. 810 * @returns { Promise<HttpResponse> } The promise returned by the function. 811 * @throws { BusinessError } 401 - Parameter error. 812 * @throws { BusinessError } 201 - Permission denied. 813 * @throws { BusinessError } 2300001 - Unsupported protocol. 814 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 815 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 816 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 817 * @throws { BusinessError } 2300007 - Failed to connect to the server. 818 * @throws { BusinessError } 2300008 - Invalid server response. 819 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 820 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 821 * @throws { BusinessError } 2300018 - Transferred a partial file. 822 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 823 * @throws { BusinessError } 2300025 - Upload failed. 824 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 825 * @throws { BusinessError } 2300027 - Out of memory. 826 * @throws { BusinessError } 2300028 - Operation timeout. 827 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 828 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 829 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 830 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 831 * @throws { BusinessError } 2300058 - Local SSL certificate error. 832 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 833 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 834 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 835 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 836 * @throws { BusinessError } 2300070 - Remote disk full. 837 * @throws { BusinessError } 2300073 - Remote file already exists. 838 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is unaccessible. 839 * @throws { BusinessError } 2300078 - Remote file not found. 840 * @throws { BusinessError } 2300094 - Authentication error. 841 * @throws { BusinessError } 2300999 - Unknown error. 842 * @syscap SystemCapability.Communication.NetStack 843 * @since 6 844 */ 845 /** 846 * Initiates an HTTP request to a given URL. 847 * @permission ohos.permission.INTERNET 848 * @param { string } url - URL for initiating an HTTP request. 849 * @param { HttpRequestOptions } [options] - Optional parameters {@link HttpRequestOptions}. 850 * @returns { Promise<HttpResponse> } The promise returned by the function. 851 * @throws { BusinessError } 401 - Parameter error. 852 * @throws { BusinessError } 201 - Permission denied. 853 * @throws { BusinessError } 2300001 - Unsupported protocol. 854 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 855 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 856 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 857 * @throws { BusinessError } 2300007 - Failed to connect to the server. 858 * @throws { BusinessError } 2300008 - Invalid server response. 859 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 860 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 861 * @throws { BusinessError } 2300018 - Transferred a partial file. 862 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 863 * @throws { BusinessError } 2300025 - Upload failed. 864 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 865 * @throws { BusinessError } 2300027 - Out of memory. 866 * @throws { BusinessError } 2300028 - Operation timeout. 867 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 868 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 869 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 870 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 871 * @throws { BusinessError } 2300058 - Local SSL certificate error. 872 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 873 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 874 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 875 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 876 * @throws { BusinessError } 2300070 - Remote disk full. 877 * @throws { BusinessError } 2300073 - Remote file already exists. 878 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is unaccessible. 879 * @throws { BusinessError } 2300078 - Remote file not found. 880 * @throws { BusinessError } 2300094 - Authentication error. 881 * @throws { BusinessError } 2300999 - Unknown error. 882 * @syscap SystemCapability.Communication.NetStack 883 * @crossplatform 884 * @since 10 885 */ 886 /** 887 * Initiates an HTTP request to a given URL. 888 * @permission ohos.permission.INTERNET 889 * @param { string } url - URL for initiating an HTTP request. 890 * @param { HttpRequestOptions } [options] - Optional parameters {@link HttpRequestOptions}. 891 * @returns { Promise<HttpResponse> } The promise returned by the function. 892 * @throws { BusinessError } 401 - Parameter error. 893 * @throws { BusinessError } 201 - Permission denied. 894 * @throws { BusinessError } 2300001 - Unsupported protocol. 895 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 896 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 897 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 898 * @throws { BusinessError } 2300007 - Failed to connect to the server. 899 * @throws { BusinessError } 2300008 - Invalid server response. 900 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 901 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 902 * @throws { BusinessError } 2300018 - Transferred a partial file. 903 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 904 * @throws { BusinessError } 2300025 - Upload failed. 905 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 906 * @throws { BusinessError } 2300027 - Out of memory. 907 * @throws { BusinessError } 2300028 - Operation timeout. 908 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 909 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 910 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 911 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 912 * @throws { BusinessError } 2300058 - Local SSL certificate error. 913 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 914 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 915 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 916 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 917 * @throws { BusinessError } 2300070 - Remote disk full. 918 * @throws { BusinessError } 2300073 - Remote file already exists. 919 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is unaccessible. 920 * @throws { BusinessError } 2300078 - Remote file not found. 921 * @throws { BusinessError } 2300094 - Authentication error. 922 * @throws { BusinessError } 2300999 - Unknown error. 923 * @syscap SystemCapability.Communication.NetStack 924 * @crossplatform 925 * @atomicservice 926 * @since 11 927 */ 928 request(url: string, options?: HttpRequestOptions): Promise<HttpResponse>; 929 930 /** 931 * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. 932 * @permission ohos.permission.INTERNET 933 * @param { string } url - URL for initiating an HTTP request. 934 * @param { AsyncCallback<number> } callback - Returns the callback of requestInStream {@link ResponseCode}, 935 * should use on_headersReceive and on_dataReceive to get http response. 936 * @throws { BusinessError } 401 - Parameter error. 937 * @throws { BusinessError } 201 - Permission denied. 938 * @throws { BusinessError } 2300001 - Unsupported protocol. 939 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 940 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 941 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 942 * @throws { BusinessError } 2300007 - Failed to connect to the server. 943 * @throws { BusinessError } 2300008 - Invalid server response. 944 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 945 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 946 * @throws { BusinessError } 2300018 - Transferred a partial file. 947 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 948 * @throws { BusinessError } 2300025 - Upload failed. 949 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 950 * @throws { BusinessError } 2300027 - Out of memory. 951 * @throws { BusinessError } 2300028 - Operation timeout. 952 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 953 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 954 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 955 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 956 * @throws { BusinessError } 2300058 - Local SSL certificate error. 957 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 958 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 959 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 960 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 961 * @throws { BusinessError } 2300070 - Remote disk full. 962 * @throws { BusinessError } 2300073 - Remote file already exists. 963 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is unaccessible. 964 * @throws { BusinessError } 2300078 - Remote file not found. 965 * @throws { BusinessError } 2300094 - Authentication error. 966 * @throws { BusinessError } 2300999 - Unknown error. 967 * @syscap SystemCapability.Communication.NetStack 968 * @since 10 969 */ 970 requestInStream(url: string, callback: AsyncCallback<number>): void; 971 972 /** 973 * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. 974 * @permission ohos.permission.INTERNET 975 * @param { string } url - URL for initiating an HTTP request. 976 * @param { HttpRequestOptions } options - Optional parameters {@link HttpRequestOptions}. 977 * @param { AsyncCallback<number> } callback - the callback of requestInStream. 978 * @throws { BusinessError } 401 - Parameter error. 979 * @throws { BusinessError } 201 - Permission denied. 980 * @throws { BusinessError } 2300001 - Unsupported protocol. 981 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 982 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 983 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 984 * @throws { BusinessError } 2300007 - Failed to connect to the server. 985 * @throws { BusinessError } 2300008 - Invalid server response. 986 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 987 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 988 * @throws { BusinessError } 2300018 - Transferred a partial file. 989 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 990 * @throws { BusinessError } 2300025 - Upload failed. 991 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 992 * @throws { BusinessError } 2300027 - Out of memory. 993 * @throws { BusinessError } 2300028 - Operation timeout. 994 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 995 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 996 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 997 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 998 * @throws { BusinessError } 2300058 - Local SSL certificate error. 999 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1000 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1001 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1002 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1003 * @throws { BusinessError } 2300070 - Remote disk full. 1004 * @throws { BusinessError } 2300073 - Remote file already exists. 1005 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is unaccessible. 1006 * @throws { BusinessError } 2300078 - Remote file not found. 1007 * @throws { BusinessError } 2300094 - Authentication error. 1008 * @throws { BusinessError } 2300999 - Unknown error. 1009 * @syscap SystemCapability.Communication.NetStack 1010 * @since 10 1011 */ 1012 requestInStream(url: string, options: HttpRequestOptions, callback: AsyncCallback<number>): void; 1013 1014 /** 1015 * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. 1016 * @permission ohos.permission.INTERNET 1017 * @param { string } url - URL for initiating an HTTP request. 1018 * @param { HttpRequestOptions } [options] - Optional parameters {@link HttpRequestOptions}. 1019 * @returns { Promise<number> } the promise returned by the function. 1020 * @throws { BusinessError } 401 - Parameter error. 1021 * @throws { BusinessError } 201 - Permission denied. 1022 * @throws { BusinessError } 2300001 - Unsupported protocol. 1023 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1024 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1025 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1026 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1027 * @throws { BusinessError } 2300008 - Invalid server response. 1028 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1029 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1030 * @throws { BusinessError } 2300018 - Transferred a partial file. 1031 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1032 * @throws { BusinessError } 2300025 - Upload failed. 1033 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1034 * @throws { BusinessError } 2300027 - Out of memory. 1035 * @throws { BusinessError } 2300028 - Operation timeout. 1036 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1037 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1038 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1039 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1040 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1041 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1042 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1043 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1044 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1045 * @throws { BusinessError } 2300070 - Remote disk full. 1046 * @throws { BusinessError } 2300073 - Remote file already exists. 1047 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is unaccessible. 1048 * @throws { BusinessError } 2300078 - Remote file not found. 1049 * @throws { BusinessError } 2300094 - Authentication error. 1050 * @throws { BusinessError } 2300999 - Unknown error. 1051 * @syscap SystemCapability.Communication.NetStack 1052 * @since 10 1053 */ 1054 requestInStream(url: string, options?: HttpRequestOptions): Promise<number>; 1055 1056 /** 1057 * Destroys an HTTP request. 1058 * @syscap SystemCapability.Communication.NetStack 1059 * @since 6 1060 */ 1061 /** 1062 * Destroys an HTTP request. 1063 * @syscap SystemCapability.Communication.NetStack 1064 * @crossplatform 1065 * @since 10 1066 */ 1067 /** 1068 * Destroys an HTTP request. 1069 * @syscap SystemCapability.Communication.NetStack 1070 * @crossplatform 1071 * @atomicservice 1072 * @since 11 1073 */ 1074 destroy(): void; 1075 1076 /** 1077 * Registers an observer for HTTP Response Header events. 1078 * @param { "headerReceive" } type - Indicates Event name. 1079 * @param { AsyncCallback<Object> } callback - the callback used to return the result. 1080 * @syscap SystemCapability.Communication.NetStack 1081 * @since 6 1082 * @deprecated since 8 1083 * @useinstead on_headersReceive 1084 */ 1085 on(type: "headerReceive", callback: AsyncCallback<Object>): void; 1086 1087 /** 1088 * Unregisters the observer for HTTP Response Header events. 1089 * @param { "headerReceive" } type - Indicates Event name. 1090 * @param { AsyncCallback<Object> } [callback] - the callback used to return the result. 1091 * @syscap SystemCapability.Communication.NetStack 1092 * @since 6 1093 * @deprecated since 8 1094 * @useinstead off_headersReceive 1095 */ 1096 off(type: "headerReceive", callback?: AsyncCallback<Object>): void; 1097 1098 /** 1099 * Registers an observer for HTTP Response Header events. 1100 * @param { "headersReceive" } type - Indicates Event name. 1101 * @param { Callback<Object> } callback - the callback used to return the result. 1102 * @syscap SystemCapability.Communication.NetStack 1103 * @since 8 1104 */ 1105 /** 1106 * Registers an observer for HTTP Response Header events. 1107 * @param { "headersReceive" } type - Indicates Event name. 1108 * @param { Callback<Object> } callback - the callback used to return the result. 1109 * @syscap SystemCapability.Communication.NetStack 1110 * @crossplatform 1111 * @since 10 1112 */ 1113 /** 1114 * Registers an observer for HTTP Response Header events. 1115 * @param { "headersReceive" } type - Indicates Event name. 1116 * @param { Callback<Object> } callback - the callback used to return the result. 1117 * @syscap SystemCapability.Communication.NetStack 1118 * @crossplatform 1119 * @atomicservice 1120 * @since 11 1121 */ 1122 on(type: "headersReceive", callback: Callback<Object>): void; 1123 1124 /** 1125 * Unregisters the observer for HTTP Response Header events. 1126 * @param { "headersReceive" } type - Indicates Event name. 1127 * @param { Callback<Object> } callback - the callback used to return the result. 1128 * @syscap SystemCapability.Communication.NetStack 1129 * @since 8 1130 */ 1131 /** 1132 * Unregisters the observer for HTTP Response Header events. 1133 * @param { "headersReceive" } type - Indicates Event name. 1134 * @param { Callback<Object> } callback - the callback used to return the result. 1135 * @syscap SystemCapability.Communication.NetStack 1136 * @crossplatform 1137 * @since 10 1138 */ 1139 /** 1140 * Unregisters the observer for HTTP Response Header events. 1141 * @param { "headersReceive" } type - Indicates Event name. 1142 * @param { Callback<Object> } [callback] - the callback used to return the result. 1143 * @syscap SystemCapability.Communication.NetStack 1144 * @crossplatform 1145 * @atomicservice 1146 * @since 11 1147 */ 1148 off(type: "headersReceive", callback?: Callback<Object>): void; 1149 1150 /** 1151 * Registers a one-time observer for HTTP Response Header events. 1152 * @param { "headersReceive" } type - Indicates Event name. 1153 * @param { Callback<Object> } callback - the callback used to return the result. 1154 * @syscap SystemCapability.Communication.NetStack 1155 * @since 8 1156 */ 1157 /** 1158 * Registers a one-time observer for HTTP Response Header events. 1159 * @param { "headersReceive" } type - Indicates Event name. 1160 * @param { Callback<Object> } callback - the callback used to return the result. 1161 * @syscap SystemCapability.Communication.NetStack 1162 * @crossplatform 1163 * @since 10 1164 */ 1165 once(type: "headersReceive", callback: Callback<Object>): void; 1166 1167 /** 1168 * Registers an observer for receiving HTTP Response data events continuously. 1169 * @param { "dataReceive" } type - Indicates Event name. 1170 * @param { Callback<ArrayBuffer> } callback - the callback used to return the result. 1171 * @syscap SystemCapability.Communication.NetStack 1172 * @since 10 1173 */ 1174 on(type: "dataReceive", callback: Callback<ArrayBuffer>): void; 1175 1176 /** 1177 * Unregisters an observer for receiving HTTP Response data events continuously. 1178 * @param { "dataReceive" } type - Indicates Event name. 1179 * @param { Callback<ArrayBuffer> } [callback] - the callback used to return the result. 1180 * @syscap SystemCapability.Communication.NetStack 1181 * @since 10 1182 */ 1183 off(type: "dataReceive", callback?: Callback<ArrayBuffer>): void; 1184 1185 /** 1186 * Registers an observer for receiving HTTP Response data ends events. 1187 * @param { "dataEnd" } type - Indicates Event name. 1188 * @param { Callback<void> } callback - the callback used to return the result. 1189 * @syscap SystemCapability.Communication.NetStack 1190 * @since 10 1191 */ 1192 on(type: "dataEnd", callback: Callback<void>): void; 1193 1194 /** 1195 * Unregisters an observer for receiving HTTP Response data ends events. 1196 * @param { "dataEnd" } type - Indicates Event name. 1197 * @param { Callback<void> } [callback] - the callback used to return the result. 1198 * @syscap SystemCapability.Communication.NetStack 1199 * @since 10 1200 */ 1201 off(type: "dataEnd", callback?: Callback<void>): void; 1202 1203 /** 1204 * Registers an observer for progress of receiving HTTP Response data events. 1205 * @param { 'dataReceiveProgress' } type - Indicates Event name. 1206 * @param { Callback<{ receiveSize: number, totalSize: number }> } callback - the callback used to return the result. 1207 * @syscap SystemCapability.Communication.NetStack 1208 * @since 10 1209 */ 1210 /** 1211 * Registers an observer for progress of receiving HTTP Response data events. 1212 * @param { 'dataReceiveProgress' } type - Indicates Event name. 1213 * @param { Callback<DataReceiveProgressInfo> } callback - the callback used to return the result. 1214 * @syscap SystemCapability.Communication.NetStack 1215 * @since 11 1216 */ 1217 on(type: 'dataReceiveProgress', callback: Callback<DataReceiveProgressInfo>): void; 1218 1219 /** 1220 * Unregisters an observer for progress of receiving HTTP Response data events. 1221 * @param { 'dataReceiveProgress' } type - Indicates Event name. 1222 * @param { Callback<{ receiveSize: number, totalSize: number }> } [callback] - the callback used to return the result. 1223 * @syscap SystemCapability.Communication.NetStack 1224 * @since 10 1225 */ 1226 /** 1227 * Unregisters an observer for progress of receiving HTTP Response data events. 1228 * @param { 'dataReceiveProgress' } type - Indicates Event name. 1229 * @param { Callback<DataReceiveProgressInfo> } callback - the callback used to return the result. 1230 * @syscap SystemCapability.Communication.NetStack 1231 * @since 11 1232 */ 1233 off(type: 'dataReceiveProgress', callback?: Callback<DataReceiveProgressInfo>): void; 1234 1235 /** 1236 * Registers an observer for progress of sendSize HTTP Response data events. 1237 * @param { 'dataSendProgress' } type - Indicates Event name. 1238 * @param { Callback<DataSendProgressInfo> } callback - the callback of on. 1239 * @syscap SystemCapability.Communication.NetStack 1240 * @since 11 1241 */ 1242 on(type: 'dataSendProgress', callback: Callback<DataSendProgressInfo>): void 1243 1244 /** 1245 * Unregisters an observer for progress of sendSize HTTP Response data events. 1246 * @param { 'dataSendProgress' } type - Indicates Event name. 1247 * @param { Callback<DataSendProgressInfo> } [callback] - the callback of off. 1248 * @syscap SystemCapability.Communication.NetStack 1249 * @since 11 1250 */ 1251 off(type: 'dataSendProgress', callback?: Callback<DataSendProgressInfo>): void 1252 } 1253 1254 /** 1255 * Defines an HTTP request method. 1256 * @enum {string} 1257 * @syscap SystemCapability.Communication.NetStack 1258 * @since 6 1259 */ 1260 /** 1261 * Defines an HTTP request method. 1262 * @enum {string} 1263 * @syscap SystemCapability.Communication.NetStack 1264 * @crossplatform 1265 * @since 10 1266 */ 1267 /** 1268 * Defines an HTTP request method. 1269 * @enum {string} 1270 * @syscap SystemCapability.Communication.NetStack 1271 * @crossplatform 1272 * @atomicservice 1273 * @since 11 1274 */ 1275 export enum RequestMethod { 1276 /** 1277 * OPTIONS method. 1278 * @syscap SystemCapability.Communication.NetStack 1279 * @since 6 1280 */ 1281 /** 1282 * OPTIONS method. 1283 * @syscap SystemCapability.Communication.NetStack 1284 * @crossplatform 1285 * @since 10 1286 */ 1287 /** 1288 * OPTIONS method. 1289 * @syscap SystemCapability.Communication.NetStack 1290 * @crossplatform 1291 * @atomicservice 1292 * @since 11 1293 */ 1294 OPTIONS = "OPTIONS", 1295 1296 /** 1297 * GET method. 1298 * @syscap SystemCapability.Communication.NetStack 1299 * @since 6 1300 */ 1301 /** 1302 * GET method. 1303 * @syscap SystemCapability.Communication.NetStack 1304 * @crossplatform 1305 * @since 10 1306 */ 1307 /** 1308 * GET method. 1309 * @syscap SystemCapability.Communication.NetStack 1310 * @crossplatform 1311 * @atomicservice 1312 * @since 11 1313 */ 1314 GET = "GET", 1315 1316 /** 1317 * HEAD method. 1318 * @syscap SystemCapability.Communication.NetStack 1319 * @since 6 1320 */ 1321 /** 1322 * HEAD method. 1323 * @syscap SystemCapability.Communication.NetStack 1324 * @crossplatform 1325 * @since 10 1326 */ 1327 /** 1328 * HEAD method. 1329 * @syscap SystemCapability.Communication.NetStack 1330 * @crossplatform 1331 * @atomicservice 1332 * @since 11 1333 */ 1334 HEAD = "HEAD", 1335 1336 /** 1337 * POST method. 1338 * @syscap SystemCapability.Communication.NetStack 1339 * @since 6 1340 */ 1341 /** 1342 * POST method. 1343 * @syscap SystemCapability.Communication.NetStack 1344 * @crossplatform 1345 * @since 10 1346 */ 1347 /** 1348 * POST method. 1349 * @syscap SystemCapability.Communication.NetStack 1350 * @crossplatform 1351 * @atomicservice 1352 * @since 11 1353 */ 1354 POST = "POST", 1355 1356 /** 1357 * PUT method. 1358 * @syscap SystemCapability.Communication.NetStack 1359 * @since 6 1360 */ 1361 /** 1362 * PUT method. 1363 * @syscap SystemCapability.Communication.NetStack 1364 * @crossplatform 1365 * @since 10 1366 */ 1367 /** 1368 * PUT method. 1369 * @syscap SystemCapability.Communication.NetStack 1370 * @crossplatform 1371 * @atomicservice 1372 * @since 11 1373 */ 1374 PUT = "PUT", 1375 1376 /** 1377 * DELETE method. 1378 * @syscap SystemCapability.Communication.NetStack 1379 * @since 6 1380 */ 1381 /** 1382 * DELETE method. 1383 * @syscap SystemCapability.Communication.NetStack 1384 * @crossplatform 1385 * @since 10 1386 */ 1387 /** 1388 * DELETE method. 1389 * @syscap SystemCapability.Communication.NetStack 1390 * @crossplatform 1391 * @atomicservice 1392 * @since 11 1393 */ 1394 DELETE = "DELETE", 1395 1396 /** 1397 * TRACE method. 1398 * @syscap SystemCapability.Communication.NetStack 1399 * @since 6 1400 */ 1401 /** 1402 * TRACE method. 1403 * @syscap SystemCapability.Communication.NetStack 1404 * @crossplatform 1405 * @since 10 1406 */ 1407 /** 1408 * TRACE method. 1409 * @syscap SystemCapability.Communication.NetStack 1410 * @crossplatform 1411 * @atomicservice 1412 * @since 11 1413 */ 1414 TRACE = "TRACE", 1415 1416 /** 1417 * CONNECT method. 1418 * @syscap SystemCapability.Communication.NetStack 1419 * @since 6 1420 */ 1421 /** 1422 * CONNECT method. 1423 * @syscap SystemCapability.Communication.NetStack 1424 * @crossplatform 1425 * @since 10 1426 */ 1427 /** 1428 * CONNECT method. 1429 * @syscap SystemCapability.Communication.NetStack 1430 * @crossplatform 1431 * @atomicservice 1432 * @since 11 1433 */ 1434 CONNECT = "CONNECT" 1435 } 1436 1437 /** 1438 * Enumerates the response codes for an HTTP request. 1439 * @enum {number} 1440 * @syscap SystemCapability.Communication.NetStack 1441 * @since 6 1442 */ 1443 /** 1444 * Enumerates the response codes for an HTTP request. 1445 * @enum {number} 1446 * @syscap SystemCapability.Communication.NetStack 1447 * @crossplatform 1448 * @since 10 1449 */ 1450 /** 1451 * Enumerates the response codes for an HTTP request. 1452 * @enum {number} 1453 * @syscap SystemCapability.Communication.NetStack 1454 * @crossplatform 1455 * @atomicservice 1456 * @since 11 1457 */ 1458 export enum ResponseCode { 1459 /** 1460 * The request was successful. Typically used for GET and POST requests. 1461 * @syscap SystemCapability.Communication.NetStack 1462 * @since 6 1463 */ 1464 /** 1465 * The request was successful. Typically used for GET and POST requests. 1466 * @syscap SystemCapability.Communication.NetStack 1467 * @crossplatform 1468 * @since 10 1469 */ 1470 /** 1471 * The request was successful. Typically used for GET and POST requests. 1472 * @syscap SystemCapability.Communication.NetStack 1473 * @crossplatform 1474 * @atomicservice 1475 * @since 11 1476 */ 1477 OK = 200, 1478 1479 /** 1480 * Successfully requested and created a new resource. 1481 * @syscap SystemCapability.Communication.NetStack 1482 * @since 6 1483 */ 1484 /** 1485 * Successfully requested and created a new resource. 1486 * @syscap SystemCapability.Communication.NetStack 1487 * @crossplatform 1488 * @since 10 1489 */ 1490 /** 1491 * Successfully requested and created a new resource. 1492 * @syscap SystemCapability.Communication.NetStack 1493 * @crossplatform 1494 * @atomicservice 1495 * @since 11 1496 */ 1497 CREATED, 1498 1499 /** 1500 * The request has been accepted but has not been processed completely. 1501 * @syscap SystemCapability.Communication.NetStack 1502 * @since 6 1503 */ 1504 /** 1505 * The request has been accepted but has not been processed completely. 1506 * @syscap SystemCapability.Communication.NetStack 1507 * @crossplatform 1508 * @since 10 1509 */ 1510 /** 1511 * The request has been accepted but has not been processed completely. 1512 * @syscap SystemCapability.Communication.NetStack 1513 * @crossplatform 1514 * @atomicservice 1515 * @since 11 1516 */ 1517 ACCEPTED, 1518 1519 /** 1520 * Unauthorized information. The request was successful. 1521 * @syscap SystemCapability.Communication.NetStack 1522 * @since 6 1523 */ 1524 /** 1525 * Unauthorized information. The request was successful. 1526 * @syscap SystemCapability.Communication.NetStack 1527 * @crossplatform 1528 * @since 10 1529 */ 1530 /** 1531 * Unauthorized information. The request was successful. 1532 * @syscap SystemCapability.Communication.NetStack 1533 * @crossplatform 1534 * @atomicservice 1535 * @since 11 1536 */ 1537 NOT_AUTHORITATIVE, 1538 1539 /** 1540 * No content. The server successfully processed, but did not return content. 1541 * @syscap SystemCapability.Communication.NetStack 1542 * @since 6 1543 */ 1544 /** 1545 * No content. The server successfully processed, but did not return content. 1546 * @syscap SystemCapability.Communication.NetStack 1547 * @crossplatform 1548 * @since 10 1549 */ 1550 /** 1551 * No content. The server successfully processed, but did not return content. 1552 * @syscap SystemCapability.Communication.NetStack 1553 * @crossplatform 1554 * @atomicservice 1555 * @since 11 1556 */ 1557 NO_CONTENT, 1558 1559 /** 1560 * Reset the content. 1561 * @syscap SystemCapability.Communication.NetStack 1562 * @since 6 1563 */ 1564 /** 1565 * Reset the content. 1566 * @syscap SystemCapability.Communication.NetStack 1567 * @crossplatform 1568 * @since 10 1569 */ 1570 /** 1571 * Reset the content. 1572 * @syscap SystemCapability.Communication.NetStack 1573 * @crossplatform 1574 * @atomicservice 1575 * @since 11 1576 */ 1577 RESET, 1578 1579 /** 1580 * Partial content. The server successfully processed some GET requests. 1581 * @syscap SystemCapability.Communication.NetStack 1582 * @since 6 1583 */ 1584 /** 1585 * Partial content. The server successfully processed some GET requests. 1586 * @syscap SystemCapability.Communication.NetStack 1587 * @crossplatform 1588 * @since 10 1589 */ 1590 /** 1591 * Partial content. The server successfully processed some GET requests. 1592 * @syscap SystemCapability.Communication.NetStack 1593 * @crossplatform 1594 * @atomicservice 1595 * @since 11 1596 */ 1597 PARTIAL, 1598 1599 /** 1600 * Multiple options. 1601 * @syscap SystemCapability.Communication.NetStack 1602 * @since 6 1603 */ 1604 /** 1605 * Multiple options. 1606 * @syscap SystemCapability.Communication.NetStack 1607 * @crossplatform 1608 * @since 10 1609 */ 1610 /** 1611 * Multiple options. 1612 * @syscap SystemCapability.Communication.NetStack 1613 * @crossplatform 1614 * @atomicservice 1615 * @since 11 1616 */ 1617 MULT_CHOICE = 300, 1618 1619 /** 1620 * <p>Permanently move. The requested resource has been permanently moved to a new URI, 1621 * and the returned information will include the new URI. The browser will automatically redirect to the new URI.</p> 1622 * @syscap SystemCapability.Communication.NetStack 1623 * @since 6 1624 */ 1625 /** 1626 * <p>Permanently move. The requested resource has been permanently moved to a new URI, 1627 * and the returned information will include the new URI. The browser will automatically redirect to the new URI.</p> 1628 * @syscap SystemCapability.Communication.NetStack 1629 * @crossplatform 1630 * @since 10 1631 */ 1632 /** 1633 * <p>Permanently move. The requested resource has been permanently moved to a new URI, 1634 * and the returned information will include the new URI. The browser will automatically redirect to the new URI.</p> 1635 * @syscap SystemCapability.Communication.NetStack 1636 * @crossplatform 1637 * @atomicservice 1638 * @since 11 1639 */ 1640 MOVED_PERM, 1641 1642 /** 1643 * Temporary movement. 1644 * @syscap SystemCapability.Communication.NetStack 1645 * @since 6 1646 */ 1647 /** 1648 * Temporary movement. 1649 * @syscap SystemCapability.Communication.NetStack 1650 * @crossplatform 1651 * @since 10 1652 */ 1653 /** 1654 * Temporary movement. 1655 * @syscap SystemCapability.Communication.NetStack 1656 * @crossplatform 1657 * @atomicservice 1658 * @since 11 1659 */ 1660 MOVED_TEMP, 1661 1662 /** 1663 * View other addresses. 1664 * @syscap SystemCapability.Communication.NetStack 1665 * @since 6 1666 */ 1667 /** 1668 * View other addresses. 1669 * @syscap SystemCapability.Communication.NetStack 1670 * @crossplatform 1671 * @since 10 1672 */ 1673 /** 1674 * View other addresses. 1675 * @syscap SystemCapability.Communication.NetStack 1676 * @crossplatform 1677 * @atomicservice 1678 * @since 11 1679 */ 1680 SEE_OTHER, 1681 1682 /** 1683 * Not modified. 1684 * @syscap SystemCapability.Communication.NetStack 1685 * @since 6 1686 */ 1687 /** 1688 * Not modified. 1689 * @syscap SystemCapability.Communication.NetStack 1690 * @crossplatform 1691 * @since 10 1692 */ 1693 /** 1694 * Not modified. 1695 * @syscap SystemCapability.Communication.NetStack 1696 * @crossplatform 1697 * @atomicservice 1698 * @since 11 1699 */ 1700 NOT_MODIFIED, 1701 1702 /** 1703 * Using proxies. 1704 * @syscap SystemCapability.Communication.NetStack 1705 * @since 6 1706 */ 1707 /** 1708 * Using proxies. 1709 * @syscap SystemCapability.Communication.NetStack 1710 * @crossplatform 1711 * @since 10 1712 */ 1713 /** 1714 * Using proxies. 1715 * @syscap SystemCapability.Communication.NetStack 1716 * @crossplatform 1717 * @atomicservice 1718 * @since 11 1719 */ 1720 USE_PROXY, 1721 1722 /** 1723 * The server cannot understand the syntax error error requested by the client. 1724 * @syscap SystemCapability.Communication.NetStack 1725 * @since 6 1726 */ 1727 /** 1728 * The server cannot understand the syntax error error requested by the client. 1729 * @syscap SystemCapability.Communication.NetStack 1730 * @crossplatform 1731 * @since 10 1732 */ 1733 /** 1734 * The server cannot understand the syntax error error requested by the client. 1735 * @syscap SystemCapability.Communication.NetStack 1736 * @crossplatform 1737 * @atomicservice 1738 * @since 11 1739 */ 1740 BAD_REQUEST = 400, 1741 1742 /** 1743 * Request for user authentication. 1744 * @syscap SystemCapability.Communication.NetStack 1745 * @since 6 1746 */ 1747 /** 1748 * Request for user authentication. 1749 * @syscap SystemCapability.Communication.NetStack 1750 * @crossplatform 1751 * @since 10 1752 */ 1753 /** 1754 * Request for user authentication. 1755 * @syscap SystemCapability.Communication.NetStack 1756 * @crossplatform 1757 * @atomicservice 1758 * @since 11 1759 */ 1760 UNAUTHORIZED, 1761 1762 /** 1763 * Reserved for future use. 1764 * @syscap SystemCapability.Communication.NetStack 1765 * @since 6 1766 */ 1767 /** 1768 * Reserved for future use. 1769 * @syscap SystemCapability.Communication.NetStack 1770 * @crossplatform 1771 * @since 10 1772 */ 1773 /** 1774 * Reserved for future use. 1775 * @syscap SystemCapability.Communication.NetStack 1776 * @crossplatform 1777 * @atomicservice 1778 * @since 11 1779 */ 1780 PAYMENT_REQUIRED, 1781 1782 /** 1783 * The server understands the request from the requesting client, but refuses to execute it. 1784 * @syscap SystemCapability.Communication.NetStack 1785 * @since 6 1786 */ 1787 /** 1788 * The server understands the request from the requesting client, but refuses to execute it. 1789 * @syscap SystemCapability.Communication.NetStack 1790 * @crossplatform 1791 * @since 10 1792 */ 1793 /** 1794 * The server understands the request from the requesting client, but refuses to execute it. 1795 * @syscap SystemCapability.Communication.NetStack 1796 * @crossplatform 1797 * @atomicservice 1798 * @since 11 1799 */ 1800 FORBIDDEN, 1801 1802 /** 1803 * The server was unable to find resources (web pages) based on the client's request. 1804 * @syscap SystemCapability.Communication.NetStack 1805 * @since 6 1806 */ 1807 /** 1808 * The server was unable to find resources (web pages) based on the client's request. 1809 * @syscap SystemCapability.Communication.NetStack 1810 * @crossplatform 1811 * @since 10 1812 */ 1813 /** 1814 * The server was unable to find resources (web pages) based on the client's request. 1815 * @syscap SystemCapability.Communication.NetStack 1816 * @crossplatform 1817 * @atomicservice 1818 * @since 11 1819 */ 1820 NOT_FOUND, 1821 1822 /** 1823 * The method in the client request is prohibited. 1824 * @syscap SystemCapability.Communication.NetStack 1825 * @since 6 1826 */ 1827 /** 1828 * The method in the client request is prohibited. 1829 * @syscap SystemCapability.Communication.NetStack 1830 * @crossplatform 1831 * @since 10 1832 */ 1833 /** 1834 * The method in the client request is prohibited. 1835 * @syscap SystemCapability.Communication.NetStack 1836 * @crossplatform 1837 * @atomicservice 1838 * @since 11 1839 */ 1840 BAD_METHOD, 1841 1842 /** 1843 * The server is unable to complete the request based on the content characteristics requested by the client. 1844 * @syscap SystemCapability.Communication.NetStack 1845 * @since 6 1846 */ 1847 /** 1848 * The server is unable to complete the request based on the content characteristics requested by the client. 1849 * @syscap SystemCapability.Communication.NetStack 1850 * @crossplatform 1851 * @since 10 1852 */ 1853 /** 1854 * The server is unable to complete the request based on the content characteristics requested by the client. 1855 * @syscap SystemCapability.Communication.NetStack 1856 * @crossplatform 1857 * @atomicservice 1858 * @since 11 1859 */ 1860 NOT_ACCEPTABLE, 1861 1862 /** 1863 * Request authentication of the proxy's identity. 1864 * @syscap SystemCapability.Communication.NetStack 1865 * @since 6 1866 */ 1867 /** 1868 * Request authentication of the proxy's identity. 1869 * @syscap SystemCapability.Communication.NetStack 1870 * @crossplatform 1871 * @since 10 1872 */ 1873 /** 1874 * Request authentication of the proxy's identity. 1875 * @syscap SystemCapability.Communication.NetStack 1876 * @crossplatform 1877 * @atomicservice 1878 * @since 11 1879 */ 1880 PROXY_AUTH, 1881 1882 /** 1883 * The request took too long and timed out. 1884 * @syscap SystemCapability.Communication.NetStack 1885 * @since 6 1886 */ 1887 /** 1888 * The request took too long and timed out. 1889 * @syscap SystemCapability.Communication.NetStack 1890 * @crossplatform 1891 * @since 10 1892 */ 1893 /** 1894 * The request took too long and timed out. 1895 * @syscap SystemCapability.Communication.NetStack 1896 * @crossplatform 1897 * @atomicservice 1898 * @since 11 1899 */ 1900 CLIENT_TIMEOUT, 1901 1902 /** 1903 * <p>The server may have returned this code when completing the client's PUT request, 1904 * as there was a conflict when the server was processing the request.</p> 1905 * @syscap SystemCapability.Communication.NetStack 1906 * @since 6 1907 */ 1908 /** 1909 * <p>The server may have returned this code when completing the client's PUT request, 1910 * as there was a conflict when the server was processing the request.</p> 1911 * @syscap SystemCapability.Communication.NetStack 1912 * @crossplatform 1913 * @since 10 1914 */ 1915 /** 1916 * <p>The server may have returned this code when completing the client's PUT request, 1917 * as there was a conflict when the server was processing the request.</p> 1918 * @syscap SystemCapability.Communication.NetStack 1919 * @crossplatform 1920 * @atomicservice 1921 * @since 11 1922 */ 1923 CONFLICT, 1924 1925 /** 1926 * The resource requested by the client no longer exists. 1927 * @syscap SystemCapability.Communication.NetStack 1928 * @since 6 1929 */ 1930 /** 1931 * The resource requested by the client no longer exists. 1932 * @syscap SystemCapability.Communication.NetStack 1933 * @crossplatform 1934 * @since 10 1935 */ 1936 /** 1937 * The resource requested by the client no longer exists. 1938 * @syscap SystemCapability.Communication.NetStack 1939 * @crossplatform 1940 * @atomicservice 1941 * @since 11 1942 */ 1943 GONE, 1944 1945 /** 1946 * The server is unable to process request information sent by the client without Content Length. 1947 * @syscap SystemCapability.Communication.NetStack 1948 * @since 6 1949 */ 1950 /** 1951 * The server is unable to process request information sent by the client without Content Length. 1952 * @syscap SystemCapability.Communication.NetStack 1953 * @crossplatform 1954 * @since 10 1955 */ 1956 /** 1957 * The server is unable to process request information sent by the client without Content Length. 1958 * @syscap SystemCapability.Communication.NetStack 1959 * @crossplatform 1960 * @atomicservice 1961 * @since 11 1962 */ 1963 LENGTH_REQUIRED, 1964 1965 /** 1966 * The prerequisite for requesting information from the client is incorrect. 1967 * @syscap SystemCapability.Communication.NetStack 1968 * @since 6 1969 */ 1970 /** 1971 * The prerequisite for requesting information from the client is incorrect. 1972 * @syscap SystemCapability.Communication.NetStack 1973 * @crossplatform 1974 * @since 10 1975 */ 1976 /** 1977 * The prerequisite for requesting information from the client is incorrect. 1978 * @syscap SystemCapability.Communication.NetStack 1979 * @crossplatform 1980 * @atomicservice 1981 * @since 11 1982 */ 1983 PRECON_FAILED, 1984 1985 /** 1986 * The request was rejected because the requested entity was too large for the server to process. 1987 * @syscap SystemCapability.Communication.NetStack 1988 * @since 6 1989 */ 1990 /** 1991 * The request was rejected because the requested entity was too large for the server to process. 1992 * @syscap SystemCapability.Communication.NetStack 1993 * @crossplatform 1994 * @since 10 1995 */ 1996 /** 1997 * The request was rejected because the requested entity was too large for the server to process. 1998 * @syscap SystemCapability.Communication.NetStack 1999 * @crossplatform 2000 * @atomicservice 2001 * @since 11 2002 */ 2003 ENTITY_TOO_LARGE, 2004 2005 /** 2006 * The requested URI is too long (usually a URL) and the server cannot process it. 2007 * @syscap SystemCapability.Communication.NetStack 2008 * @since 6 2009 */ 2010 /** 2011 * The requested URI is too long (usually a URL) and the server cannot process it. 2012 * @syscap SystemCapability.Communication.NetStack 2013 * @crossplatform 2014 * @since 10 2015 */ 2016 /** 2017 * The requested URI is too long (usually a URL) and the server cannot process it. 2018 * @syscap SystemCapability.Communication.NetStack 2019 * @crossplatform 2020 * @atomicservice 2021 * @since 11 2022 */ 2023 REQ_TOO_LONG, 2024 2025 /** 2026 * The server is unable to process the requested format. 2027 * @syscap SystemCapability.Communication.NetStack 2028 * @since 6 2029 */ 2030 /** 2031 * The server is unable to process the requested format. 2032 * @syscap SystemCapability.Communication.NetStack 2033 * @crossplatform 2034 * @since 10 2035 */ 2036 /** 2037 * The server is unable to process the requested format. 2038 * @syscap SystemCapability.Communication.NetStack 2039 * @crossplatform 2040 * @atomicservice 2041 * @since 11 2042 */ 2043 UNSUPPORTED_TYPE, 2044 2045 /** 2046 * The server cannot process the requested data range. 2047 * @syscap SystemCapability.Communication.NetStack 2048 * @crossplatform 2049 * @atomicservice 2050 * @since 12 2051 */ 2052 RANGE_NOT_SATISFIABLE, 2053 2054 /** 2055 * Internal server error, unable to complete the request. 2056 * @syscap SystemCapability.Communication.NetStack 2057 * @since 6 2058 */ 2059 /** 2060 * Internal server error, unable to complete the request. 2061 * @syscap SystemCapability.Communication.NetStack 2062 * @crossplatform 2063 * @since 10 2064 */ 2065 /** 2066 * Internal server error, unable to complete the request. 2067 * @syscap SystemCapability.Communication.NetStack 2068 * @crossplatform 2069 * @atomicservice 2070 * @since 11 2071 */ 2072 INTERNAL_ERROR = 500, 2073 2074 /** 2075 * The server does not support the requested functionality and cannot complete the request. 2076 * @syscap SystemCapability.Communication.NetStack 2077 * @since 6 2078 */ 2079 /** 2080 * The server does not support the requested functionality and cannot complete the request. 2081 * @syscap SystemCapability.Communication.NetStack 2082 * @crossplatform 2083 * @since 10 2084 */ 2085 /** 2086 * The server does not support the requested functionality and cannot complete the request. 2087 * @syscap SystemCapability.Communication.NetStack 2088 * @crossplatform 2089 * @atomicservice 2090 * @since 11 2091 */ 2092 NOT_IMPLEMENTED, 2093 2094 /** 2095 * The server acting as a gateway or proxy received an invalid request from the remote server. 2096 * @syscap SystemCapability.Communication.NetStack 2097 * @since 6 2098 */ 2099 /** 2100 * The server acting as a gateway or proxy received an invalid request from the remote server. 2101 * @syscap SystemCapability.Communication.NetStack 2102 * @crossplatform 2103 * @since 10 2104 */ 2105 /** 2106 * The server acting as a gateway or proxy received an invalid request from the remote server. 2107 * @syscap SystemCapability.Communication.NetStack 2108 * @crossplatform 2109 * @atomicservice 2110 * @since 11 2111 */ 2112 BAD_GATEWAY, 2113 2114 /** 2115 * Due to overload or system maintenance, the server is temporarily unable to process client requests. 2116 * @syscap SystemCapability.Communication.NetStack 2117 * @since 6 2118 */ 2119 /** 2120 * Due to overload or system maintenance, the server is temporarily unable to process client requests. 2121 * @syscap SystemCapability.Communication.NetStack 2122 * @crossplatform 2123 * @since 10 2124 */ 2125 /** 2126 * Due to overload or system maintenance, the server is temporarily unable to process client requests. 2127 * @syscap SystemCapability.Communication.NetStack 2128 * @crossplatform 2129 * @atomicservice 2130 * @since 11 2131 */ 2132 UNAVAILABLE, 2133 2134 /** 2135 * The server acting as a gateway or proxy did not obtain requests from the remote server in a timely manner. 2136 * @syscap SystemCapability.Communication.NetStack 2137 * @since 6 2138 */ 2139 /** 2140 * The server acting as a gateway or proxy did not obtain requests from the remote server in a timely manner. 2141 * @syscap SystemCapability.Communication.NetStack 2142 * @crossplatform 2143 * @since 10 2144 */ 2145 /** 2146 * The server acting as a gateway or proxy did not obtain requests from the remote server in a timely manner. 2147 * @syscap SystemCapability.Communication.NetStack 2148 * @crossplatform 2149 * @atomicservice 2150 * @since 11 2151 */ 2152 GATEWAY_TIMEOUT, 2153 2154 /** 2155 * The version of the HTTP protocol requested by the server. 2156 * @syscap SystemCapability.Communication.NetStack 2157 * @since 6 2158 */ 2159 /** 2160 * The version of the HTTP protocol requested by the server. 2161 * @syscap SystemCapability.Communication.NetStack 2162 * @crossplatform 2163 * @since 10 2164 */ 2165 /** 2166 * The version of the HTTP protocol requested by the server. 2167 * @syscap SystemCapability.Communication.NetStack 2168 * @crossplatform 2169 * @atomicservice 2170 * @since 11 2171 */ 2172 VERSION 2173 } 2174 2175 /** 2176 * Supported protocols. 2177 * @enum {string} 2178 * @syscap SystemCapability.Communication.NetStack 2179 * @since 9 2180 */ 2181 /** 2182 * Supported protocols. 2183 * @enum {string} 2184 * @syscap SystemCapability.Communication.NetStack 2185 * @crossplatform 2186 * @since 10 2187 */ 2188 /** 2189 * Supported protocols. 2190 * @enum {string} 2191 * @syscap SystemCapability.Communication.NetStack 2192 * @crossplatform 2193 * @atomicservice 2194 * @since 11 2195 */ 2196 2197 export enum HttpProtocol { 2198 /** 2199 * Protocol http1.1 2200 * @syscap SystemCapability.Communication.NetStack 2201 * @since 9 2202 */ 2203 /** 2204 * Protocol http1.1 2205 * @syscap SystemCapability.Communication.NetStack 2206 * @crossplatform 2207 * @since 10 2208 */ 2209 /** 2210 * Protocol http1.1 2211 * @syscap SystemCapability.Communication.NetStack 2212 * @crossplatform 2213 * @atomicservice 2214 * @since 11 2215 */ 2216 HTTP1_1, 2217 2218 /** 2219 * Protocol http2 2220 * @syscap SystemCapability.Communication.NetStack 2221 * @since 9 2222 */ 2223 /** 2224 * Protocol http2 2225 * @syscap SystemCapability.Communication.NetStack 2226 * @crossplatform 2227 * @since 10 2228 */ 2229 /** 2230 * Protocol http2 2231 * @syscap SystemCapability.Communication.NetStack 2232 * @crossplatform 2233 * @atomicservice 2234 * @since 11 2235 */ 2236 HTTP2, 2237 2238 /** 2239 * Protocol http3 for https only. 2240 * Cause error if using http only or not supporting http3 on this device. 2241 * Fallback to http2 or http1.1 if needed. 2242 * @syscap SystemCapability.Communication.NetStack 2243 * @since 11 2244 */ 2245 HTTP3 2246 } 2247 2248 /** 2249 * Indicates the type of the returned data. 2250 * @enum {number} 2251 * @syscap SystemCapability.Communication.NetStack 2252 * @since 9 2253 */ 2254 /** 2255 * Indicates the type of the returned data. 2256 * @enum {number} 2257 * @syscap SystemCapability.Communication.NetStack 2258 * @crossplatform 2259 * @since 10 2260 */ 2261 /** 2262 * Indicates the type of the returned data. 2263 * @enum {number} 2264 * @syscap SystemCapability.Communication.NetStack 2265 * @crossplatform 2266 * @atomicservice 2267 * @since 11 2268 */ 2269 export enum HttpDataType { 2270 /** 2271 * The returned type is string. 2272 * @syscap SystemCapability.Communication.NetStack 2273 * @since 9 2274 */ 2275 /** 2276 * The returned type is string. 2277 * @syscap SystemCapability.Communication.NetStack 2278 * @crossplatform 2279 * @since 10 2280 */ 2281 /** 2282 * The returned type is string. 2283 * @syscap SystemCapability.Communication.NetStack 2284 * @crossplatform 2285 * @atomicservice 2286 * @since 11 2287 */ 2288 STRING, 2289 2290 /** 2291 * The returned type is Object. 2292 * @syscap SystemCapability.Communication.NetStack 2293 * @since 9 2294 */ 2295 /** 2296 * The returned type is Object. 2297 * @syscap SystemCapability.Communication.NetStack 2298 * @crossplatform 2299 * @since 10 2300 */ 2301 /** 2302 * The returned type is Object. 2303 * @syscap SystemCapability.Communication.NetStack 2304 * @crossplatform 2305 * @atomicservice 2306 * @since 11 2307 */ 2308 OBJECT = 1, 2309 2310 /** 2311 * The returned type is ArrayBuffer. 2312 * @syscap SystemCapability.Communication.NetStack 2313 * @since 9 2314 */ 2315 /** 2316 * The returned type is ArrayBuffer. 2317 * @syscap SystemCapability.Communication.NetStack 2318 * @crossplatform 2319 * @since 10 2320 */ 2321 /** 2322 * The returned type is ArrayBuffer. 2323 * @syscap SystemCapability.Communication.NetStack 2324 * @crossplatform 2325 * @atomicservice 2326 * @since 11 2327 */ 2328 ARRAY_BUFFER = 2 2329 } 2330 2331 /** 2332 * Defines the response to an HTTP request. 2333 * @interface HttpResponse 2334 * @syscap SystemCapability.Communication.NetStack 2335 * @since 6 2336 */ 2337 /** 2338 * Defines the response to an HTTP request. 2339 * @interface HttpResponse 2340 * @syscap SystemCapability.Communication.NetStack 2341 * @crossplatform 2342 * @since 10 2343 */ 2344 /** 2345 * Defines the response to an HTTP request. 2346 * @interface HttpResponse 2347 * @syscap SystemCapability.Communication.NetStack 2348 * @crossplatform 2349 * @atomicservice 2350 * @since 11 2351 */ 2352 export interface HttpResponse { 2353 /** 2354 * result can be a string (API 6) or an ArrayBuffer(API 8). Object is deprecated from API 8. 2355 * If {@link HttpRequestOptions#expectDataType} is set, the system preferentially returns this parameter. 2356 * @type {string | Object | ArrayBuffer} 2357 * @syscap SystemCapability.Communication.NetStack 2358 * @since 6 2359 */ 2360 /** 2361 * result can be a string (API 6) or an ArrayBuffer(API 8). Object is deprecated from API 8. 2362 * If {@link HttpRequestOptions#expectDataType} is set, the system preferentially returns this parameter. 2363 * @type {string | Object | ArrayBuffer} 2364 * @syscap SystemCapability.Communication.NetStack 2365 * @crossplatform 2366 * @since 10 2367 */ 2368 /** 2369 * result can be a string (API 6) or an ArrayBuffer(API 8). Object is deprecated from API 8. 2370 * If {@link HttpRequestOptions#expectDataType} is set, the system preferentially returns this parameter. 2371 * @type {string | Object | ArrayBuffer} 2372 * @syscap SystemCapability.Communication.NetStack 2373 * @crossplatform 2374 * @atomicservice 2375 * @since 11 2376 */ 2377 result: string | Object | ArrayBuffer; 2378 2379 /** 2380 * If the resultType is string, you can get result directly. 2381 * If the resultType is Object, you can get result such as this: result['key']. 2382 * If the resultType is ArrayBuffer, you can use ArrayBuffer to create the binary objects. 2383 * @type {HttpDataType} 2384 * @syscap SystemCapability.Communication.NetStack 2385 * @since 9 2386 */ 2387 /** 2388 * If the resultType is string, you can get result directly. 2389 * If the resultType is Object, you can get result such as this: result['key']. 2390 * If the resultType is ArrayBuffer, you can use ArrayBuffer to create the binary objects. 2391 * @type {HttpDataType} 2392 * @syscap SystemCapability.Communication.NetStack 2393 * @crossplatform 2394 * @since 10 2395 */ 2396 /** 2397 * If the resultType is string, you can get result directly. 2398 * If the resultType is Object, you can get result such as this: result['key']. 2399 * If the resultType is ArrayBuffer, you can use ArrayBuffer to create the binary objects. 2400 * @type {HttpDataType} 2401 * @syscap SystemCapability.Communication.NetStack 2402 * @crossplatform 2403 * @atomicservice 2404 * @since 11 2405 */ 2406 resultType: HttpDataType; 2407 2408 /** 2409 * Server status code. 2410 * @type {ResponseCode | number} 2411 * @syscap SystemCapability.Communication.NetStack 2412 * @since 6 2413 */ 2414 /** 2415 * Server status code. 2416 * @type {ResponseCode | number} 2417 * @syscap SystemCapability.Communication.NetStack 2418 * @crossplatform 2419 * @since 10 2420 */ 2421 /** 2422 * Server status code. 2423 * @type {ResponseCode | number} 2424 * @syscap SystemCapability.Communication.NetStack 2425 * @crossplatform 2426 * @atomicservice 2427 * @since 11 2428 */ 2429 responseCode: ResponseCode | number; 2430 2431 /** 2432 * All headers in the response from the server. 2433 * @type {Object} 2434 * @syscap SystemCapability.Communication.NetStack 2435 * @since 6 2436 */ 2437 /** 2438 * All headers in the response from the server. 2439 * @type {Object} 2440 * @syscap SystemCapability.Communication.NetStack 2441 * @crossplatform 2442 * @since 10 2443 */ 2444 /** 2445 * All headers in the response from the server. 2446 * @type {Object} 2447 * @syscap SystemCapability.Communication.NetStack 2448 * @crossplatform 2449 * @atomicservice 2450 * @since 11 2451 */ 2452 header: Object; 2453 2454 /** 2455 * Cookies returned by the server. 2456 * @type {string} 2457 * @syscap SystemCapability.Communication.NetStack 2458 * @since 8 2459 */ 2460 /** 2461 * Cookies returned by the server. 2462 * @type {string} 2463 * @syscap SystemCapability.Communication.NetStack 2464 * @crossplatform 2465 * @since 10 2466 */ 2467 /** 2468 * Cookies returned by the server. 2469 * @type {string} 2470 * @syscap SystemCapability.Communication.NetStack 2471 * @crossplatform 2472 * @atomicservice 2473 * @since 11 2474 */ 2475 cookies: string; 2476 2477 /** 2478 * The time taken of various stages of HTTP request. 2479 * @type {PerformanceTiming} 2480 * @syscap SystemCapability.Communication.NetStack 2481 * @since 11 2482 */ 2483 performanceTiming: PerformanceTiming; 2484 } 2485 2486 /** 2487 * Counting the time taken of various stages of HTTP request. 2488 * @interface PerformanceTiming 2489 * @syscap SystemCapability.Communication.NetStack 2490 * @since 11 2491 */ 2492 export interface PerformanceTiming { 2493 /** 2494 * Time taken from startup to DNS resolution completion, in milliseconds. 2495 * @type {number} 2496 * @syscap SystemCapability.Communication.NetStack 2497 * @since 11 2498 */ 2499 dnsTiming: number; 2500 2501 /** 2502 * Time taken from startup to TCP connection completion, in milliseconds. 2503 * @type {number} 2504 * @syscap SystemCapability.Communication.NetStack 2505 * @since 11 2506 */ 2507 tcpTiming: number; 2508 2509 /** 2510 * Time taken from startup to TLS connection completion, in milliseconds. 2511 * @type {number} 2512 * @syscap SystemCapability.Communication.NetStack 2513 * @since 11 2514 */ 2515 tlsTiming: number; 2516 2517 /** 2518 * Time taken from startup to start sending the first byte, in milliseconds. 2519 * @type {number} 2520 * @syscap SystemCapability.Communication.NetStack 2521 * @since 11 2522 */ 2523 firstSendTiming: number; 2524 2525 /** 2526 * Time taken from startup to receiving the first byte, in milliseconds. 2527 * @type {number} 2528 * @syscap SystemCapability.Communication.NetStack 2529 * @since 11 2530 */ 2531 firstReceiveTiming: number; 2532 2533 /** 2534 * Time taken from startup to the completion of the request, in milliseconds. 2535 * @type {number} 2536 * @syscap SystemCapability.Communication.NetStack 2537 * @since 11 2538 */ 2539 totalFinishTiming: number; 2540 2541 /** 2542 * Time taken from startup to completion of all redirection steps, in milliseconds. 2543 * @type {number} 2544 * @syscap SystemCapability.Communication.NetStack 2545 * @since 11 2546 */ 2547 redirectTiming: number; 2548 2549 /** 2550 * Time taken from HTTP request to header completion, in milliseconds. 2551 * @type {number} 2552 * @syscap SystemCapability.Communication.NetStack 2553 * @since 11 2554 */ 2555 responseHeaderTiming: number; 2556 2557 /** 2558 * Time taken from HTTP Request to body completion, in milliseconds. 2559 * @type {number} 2560 * @syscap SystemCapability.Communication.NetStack 2561 * @since 11 2562 */ 2563 responseBodyTiming: number; 2564 2565 /** 2566 * Time taken from HTTP Request to callback to the application, in milliseconds. 2567 * @type {number} 2568 * @syscap SystemCapability.Communication.NetStack 2569 * @since 11 2570 */ 2571 totalTiming: number; 2572 } 2573 2574 /** 2575 * This interface is used to obtain the progress information of file upload or download. 2576 * @interface DataReceiveProgressInfo 2577 * @syscap SystemCapability.Communication.NetStack 2578 * @since 11 2579 */ 2580 export interface DataReceiveProgressInfo { 2581 /** 2582 * Number of data bytes received. 2583 * @type { number } 2584 * @syscap SystemCapability.Communication.NetStack 2585 * @since 11 2586 */ 2587 receiveSize: number; 2588 /** 2589 * Total number of bytes to receive. 2590 * @type { number } 2591 * @syscap SystemCapability.Communication.NetStack 2592 * @since 11 2593 */ 2594 totalSize: number; 2595 } 2596 2597 /** 2598 * This interface is used to monitor the progress of sending data. 2599 * @interface DataSendProgressInfo 2600 * @syscap SystemCapability.Communication.NetStack 2601 * @since 11 2602 */ 2603 export interface DataSendProgressInfo { 2604 /** 2605 * Used to specify the data size to be sent. 2606 * @type { number } 2607 * @syscap SystemCapability.Communication.NetStack 2608 * @since 11 2609 */ 2610 sendSize: number; 2611 /** 2612 * Total number of bytes to receive. 2613 * @type { number } 2614 * @syscap SystemCapability.Communication.NetStack 2615 * @since 11 2616 */ 2617 totalSize: number; 2618 } 2619 2620 /** 2621 * Creates a default {@code HttpResponseCache} object to store the responses of HTTP access requests. 2622 * @param { number } cacheSize - the size of cache(max value is 10MB), default is 10*1024*1024(10MB). 2623 * @returns { HttpResponseCache } the HttpResponseCache of the createHttpResponseCache. 2624 * @syscap SystemCapability.Communication.NetStack 2625 * @since 9 2626 */ 2627 /** 2628 * Creates a default {@code HttpResponseCache} object to store the responses of HTTP access requests. 2629 * @param { number } cacheSize - the size of cache(max value is 10MB), default is 10*1024*1024(10MB). 2630 * @returns { HttpResponseCache } the HttpResponseCache of the createHttpResponseCache. 2631 * @syscap SystemCapability.Communication.NetStack 2632 * @crossplatform 2633 * @since 10 2634 */ 2635 /** 2636 * Creates a default {@code HttpResponseCache} object to store the responses of HTTP access requests. 2637 * @param { number } cacheSize - the size of cache(max value is 10MB), default is 10*1024*1024(10MB). 2638 * @returns { HttpResponseCache } the HttpResponseCache of the createHttpResponseCache. 2639 * @syscap SystemCapability.Communication.NetStack 2640 * @crossplatform 2641 * @atomicservice 2642 * @since 11 2643 */ 2644 function createHttpResponseCache(cacheSize?: number): HttpResponseCache; 2645 2646 /** 2647 * Defines an object that stores the response to an HTTP request. 2648 * @interface HttpResponseCache 2649 * @syscap SystemCapability.Communication.NetStack 2650 * @since 9 2651 */ 2652 /** 2653 * Defines an object that stores the response to an HTTP request. 2654 * @interface HttpResponseCache 2655 * @syscap SystemCapability.Communication.NetStack 2656 * @crossplatform 2657 * @since 10 2658 */ 2659 /** 2660 * Defines an object that stores the response to an HTTP request. 2661 * @interface HttpResponseCache 2662 * @syscap SystemCapability.Communication.NetStack 2663 * @crossplatform 2664 * @atomicservice 2665 * @since 11 2666 */ 2667 export interface HttpResponseCache { 2668 /** 2669 * Writes data in the cache to the file system so that all the cached data can be accessed in the next HTTP request. 2670 * @param { AsyncCallback<void> } callback - the callback of flush. 2671 * @syscap SystemCapability.Communication.NetStack 2672 * @since 9 2673 */ 2674 /** 2675 * Writes data in the cache to the file system so that all the cached data can be accessed in the next HTTP request. 2676 * @param { AsyncCallback<void> } callback - the callback of flush. 2677 * @syscap SystemCapability.Communication.NetStack 2678 * @crossplatform 2679 * @since 10 2680 */ 2681 /** 2682 * Writes data in the cache to the file system so that all the cached data can be accessed in the next HTTP request. 2683 * @param { AsyncCallback<void> } callback - the callback of flush. 2684 * @syscap SystemCapability.Communication.NetStack 2685 * @crossplatform 2686 * @atomicservice 2687 * @since 11 2688 */ 2689 flush(callback: AsyncCallback<void>): void; 2690 2691 /** 2692 * Writes data in the cache to the file system so that all the cached data can be accessed in the next HTTP request. 2693 * @returns { Promise<void> } The promise returned by the flush. 2694 * @syscap SystemCapability.Communication.NetStack 2695 * @since 9 2696 */ 2697 /** 2698 * Writes data in the cache to the file system so that all the cached data can be accessed in the next HTTP request. 2699 * @returns { Promise<void> } The promise returned by the flush. 2700 * @syscap SystemCapability.Communication.NetStack 2701 * @crossplatform 2702 * @since 10 2703 */ 2704 /** 2705 * Writes data in the cache to the file system so that all the cached data can be accessed in the next HTTP request. 2706 * @returns { Promise<void> } The promise returned by the flush. 2707 * @syscap SystemCapability.Communication.NetStack 2708 * @crossplatform 2709 * @atomicservice 2710 * @since 11 2711 */ 2712 flush(): Promise<void>; 2713 2714 /** 2715 * Disables a cache and deletes the data in it. 2716 * @param { AsyncCallback<void> } callback - the callback of delete. 2717 * @syscap SystemCapability.Communication.NetStack 2718 * @since 9 2719 */ 2720 /** 2721 * Disables a cache and deletes the data in it. 2722 * @param { AsyncCallback<void> } callback - the callback of delete. 2723 * @syscap SystemCapability.Communication.NetStack 2724 * @crossplatform 2725 * @since 10 2726 */ 2727 /** 2728 * Disables a cache and deletes the data in it. 2729 * @param { AsyncCallback<void> } callback - the callback of delete. 2730 * @syscap SystemCapability.Communication.NetStack 2731 * @crossplatform 2732 * @atomicservice 2733 * @since 11 2734 */ 2735 delete(callback: AsyncCallback<void>): void; 2736 2737 /** 2738 * Disables a cache and deletes the data in it. 2739 * @returns { Promise<void> } The promise returned by the delete. 2740 * @syscap SystemCapability.Communication.NetStack 2741 * @since 9 2742 */ 2743 /** 2744 * Disables a cache and deletes the data in it. 2745 * @returns { Promise<void> } The promise returned by the delete. 2746 * @syscap SystemCapability.Communication.NetStack 2747 * @crossplatform 2748 * @since 10 2749 */ 2750 /** 2751 * Disables a cache and deletes the data in it. 2752 * @returns { Promise<void> } The promise returned by the delete. 2753 * @syscap SystemCapability.Communication.NetStack 2754 * @crossplatform 2755 * @atomicservice 2756 * @since 11 2757 */ 2758 delete(): Promise<void>; 2759 } 2760} 2761 2762export default http; 2763