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