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 * Http Proxy Configuration Information. 48 * @syscap SystemCapability.Communication.NetStack 49 * @since 10 50 */ 51 /** 52 * Http Proxy Configuration Information. 53 * @syscap SystemCapability.Communication.NetStack 54 * @atomicservice 55 * @since 11 56 */ 57 /** 58 * Http Proxy Configuration Information. 59 * @typedef { connection.HttpProxy } 60 * @syscap SystemCapability.Communication.NetStack 61 * @crossplatform 62 * @atomicservice 63 * @since 12 64 */ 65 type HttpProxy = connection.HttpProxy; 66 67 /** 68 * Creates an HTTP request task. 69 * @returns { HttpRequest } the HttpRequest of the createHttp. 70 * @syscap SystemCapability.Communication.NetStack 71 * @since 6 72 */ 73 /** 74 * Creates an HTTP request task. 75 * @returns { HttpRequest } the HttpRequest of the createHttp. 76 * @syscap SystemCapability.Communication.NetStack 77 * @crossplatform 78 * @since 10 79 */ 80 /** 81 * Creates an HTTP request task. 82 * @returns { HttpRequest } the HttpRequest of the createHttp. 83 * @syscap SystemCapability.Communication.NetStack 84 * @crossplatform 85 * @atomicservice 86 * @since 11 87 */ 88 function createHttp(): HttpRequest; 89 90 /** 91 * Enum for Address Family 92 * @enum {string} 93 * @syscap SystemCapability.Communication.NetStack 94 * @since 15 95 */ 96 export enum AddressFamily { 97 /** 98 * Default, can use addresses of all IP versions that your system allows. 99 * @syscap SystemCapability.Communication.NetStack 100 * @since 15 101 */ 102 DEFAULT = 'CURL_IPRESOLVE_WHATEVER', 103 104 /** 105 * ONLYV4 Uses only IPv4 addresses. 106 * @syscap SystemCapability.Communication.NetStack 107 * @since 15 108 */ 109 ONLY_V4 = 'CURL_IPRESOLVE_V4', 110 111 /** 112 * ONLYV6 Uses only IPv6 addresses. 113 * @syscap SystemCapability.Communication.NetStack 114 * @since 15 115 */ 116 ONLY_V6 = 'CURL_IPRESOLVE_V6' 117 } 118 119 /** 120 * Specifies the type and value range of the optional parameters in the HTTP request. 121 * @interface HttpRequestOptions 122 * @syscap SystemCapability.Communication.NetStack 123 * @since 6 124 */ 125 /** 126 * Specifies the type and value range of the optional parameters in the HTTP request. 127 * @interface HttpRequestOptions 128 * @syscap SystemCapability.Communication.NetStack 129 * @crossplatform 130 * @since 10 131 */ 132 /** 133 * Specifies the type and value range of the optional parameters in the HTTP request. 134 * @interface HttpRequestOptions 135 * @syscap SystemCapability.Communication.NetStack 136 * @crossplatform 137 * @atomicservice 138 * @since 11 139 */ 140 export interface HttpRequestOptions { 141 /** 142 * Request method,default is GET. 143 * @type {?RequestMethod} 144 * @syscap SystemCapability.Communication.NetStack 145 * @since 6 146 */ 147 /** 148 * Request method,default is GET. 149 * @type {?RequestMethod} 150 * @syscap SystemCapability.Communication.NetStack 151 * @crossplatform 152 * @since 10 153 */ 154 /** 155 * Request method,default is GET. 156 * @type {?RequestMethod} 157 * @syscap SystemCapability.Communication.NetStack 158 * @crossplatform 159 * @atomicservice 160 * @since 11 161 */ 162 method?: RequestMethod; 163 164 /** 165 * Additional data of the request. 166 * extraData can be a string or an Object (API 6) or an ArrayBuffer(API 8). 167 * @type {?string | Object | ArrayBuffer} 168 * @syscap SystemCapability.Communication.NetStack 169 * @since 6 170 */ 171 /** 172 * Additional data of the request. 173 * extraData can be a string or an Object (API 6) or an ArrayBuffer(API 8). 174 * @type {?string | Object | ArrayBuffer} 175 * @syscap SystemCapability.Communication.NetStack 176 * @crossplatform 177 * @since 10 178 */ 179 /** 180 * Additional data of the request. 181 * extraData can be a string or an Object (API 6) or an ArrayBuffer(API 8). 182 * @type { ?(string | Object | ArrayBuffer) } 183 * @syscap SystemCapability.Communication.NetStack 184 * @crossplatform 185 * @atomicservice 186 * @since 11 187 */ 188 extraData?: string | Object | ArrayBuffer; 189 190 /** 191 * Data type to be returned. If this parameter is set, the system preferentially returns the specified type. 192 * @type {?HttpDataType} 193 * @syscap SystemCapability.Communication.NetStack 194 * @since 9 195 */ 196 /** 197 * Data type to be returned. If this parameter is set, the system preferentially returns the specified type. 198 * @type {?HttpDataType} 199 * @syscap SystemCapability.Communication.NetStack 200 * @crossplatform 201 * @since 10 202 */ 203 /** 204 * Data type to be returned. If this parameter is set, the system preferentially returns the specified type. 205 * @type {?HttpDataType} 206 * @syscap SystemCapability.Communication.NetStack 207 * @crossplatform 208 * @atomicservice 209 * @since 11 210 */ 211 expectDataType?: HttpDataType; 212 213 /** 214 * default is true 215 * @type {?boolean} 216 * @syscap SystemCapability.Communication.NetStack 217 * @since 9 218 */ 219 /** 220 * default is true 221 * @type {?boolean} 222 * @syscap SystemCapability.Communication.NetStack 223 * @crossplatform 224 * @since 10 225 */ 226 /** 227 * default is true 228 * @type {?boolean} 229 * @syscap SystemCapability.Communication.NetStack 230 * @crossplatform 231 * @atomicservice 232 * @since 11 233 */ 234 usingCache?: boolean; 235 236 /** 237 * [1, 1000], default is 1. 238 * @type {?number} 239 * @syscap SystemCapability.Communication.NetStack 240 * @since 9 241 */ 242 /** 243 * [1, 1000], default is 1. 244 * @type {?number} 245 * @syscap SystemCapability.Communication.NetStack 246 * @crossplatform 247 * @since 10 248 */ 249 /** 250 * [1, 1000], default is 1. 251 * @type {?number} 252 * @syscap SystemCapability.Communication.NetStack 253 * @crossplatform 254 * @atomicservice 255 * @since 11 256 */ 257 priority?: number; 258 259 /** 260 * HTTP request header. default is 'content-type': 'application/json' 261 * @type {?Object} 262 * @syscap SystemCapability.Communication.NetStack 263 * @since 6 264 */ 265 /** 266 * HTTP request header. default is 'content-type': 'application/json' 267 * @type {?Object} 268 * @syscap SystemCapability.Communication.NetStack 269 * @crossplatform 270 * @since 10 271 */ 272 /** 273 * HTTP request header. default is 'content-type': 'application/json' 274 * @type {?Object} 275 * @syscap SystemCapability.Communication.NetStack 276 * @crossplatform 277 * @atomicservice 278 * @since 11 279 */ 280 header?: Object; 281 282 /** 283 * Read timeout period. The default value is 60,000, in ms. 284 * @type {?number} 285 * @syscap SystemCapability.Communication.NetStack 286 * @since 6 287 */ 288 /** 289 * Read timeout period. The default value is 60,000, in ms. 290 * @type {?number} 291 * @syscap SystemCapability.Communication.NetStack 292 * @crossplatform 293 * @since 10 294 */ 295 /** 296 * Read timeout period. The default value is 60,000, in ms. 297 * @type {?number} 298 * @syscap SystemCapability.Communication.NetStack 299 * @crossplatform 300 * @atomicservice 301 * @since 11 302 */ 303 readTimeout?: number; 304 305 /** 306 * Connection timeout interval. The default value is 60,000, in ms. 307 * @type {?number} 308 * @syscap SystemCapability.Communication.NetStack 309 * @since 6 310 */ 311 /** 312 * Connection timeout interval. The default value is 60,000, in ms. 313 * @type {?number} 314 * @syscap SystemCapability.Communication.NetStack 315 * @crossplatform 316 * @since 10 317 */ 318 /** 319 * Connection timeout interval. The default value is 60,000, in ms. 320 * @type {?number} 321 * @syscap SystemCapability.Communication.NetStack 322 * @crossplatform 323 * @atomicservice 324 * @since 11 325 */ 326 connectTimeout?: number; 327 328 /** 329 * default is automatically specified by the system. 330 * @type {?HttpProtocol} 331 * @syscap SystemCapability.Communication.NetStack 332 * @since 9 333 */ 334 /** 335 * default is automatically specified by the system. 336 * @type {?HttpProtocol} 337 * @syscap SystemCapability.Communication.NetStack 338 * @crossplatform 339 * @since 10 340 */ 341 /** 342 * default is automatically specified by the system. 343 * @type {?HttpProtocol} 344 * @syscap SystemCapability.Communication.NetStack 345 * @crossplatform 346 * @atomicservice 347 * @since 11 348 */ 349 usingProtocol?: HttpProtocol; 350 351 /** 352 * If this parameter is set as type of boolean, the system will use default proxy or not use proxy. 353 * If this parameter is set as type of HttpProxy, the system will use the specified HttpProxy. 354 * @type {?boolean | HttpProxy} 355 * @syscap SystemCapability.Communication.NetStack 356 * @since 10 357 */ 358 /** 359 * If this parameter is set as type of boolean, the system will use default proxy or not use proxy. 360 * If this parameter is set as type of HttpProxy, the system will use the specified HttpProxy. 361 * @type { ?(boolean | HttpProxy) } 362 * @syscap SystemCapability.Communication.NetStack 363 * @atomicservice 364 * @since 11 365 */ 366 /** 367 * If this parameter is set as type of boolean, the system will use default proxy or not use proxy. 368 * If this parameter is set as type of HttpProxy, the system will use the specified HttpProxy. 369 * @type { ?(boolean | HttpProxy) } 370 * @syscap SystemCapability.Communication.NetStack 371 * @crossplatform 372 * @atomicservice 373 * @since 12 374 */ 375 usingProxy?: boolean | HttpProxy; 376 377 /** 378 * If this parameter is set, the system will use ca path specified by user, or else use preset ca by the system. 379 * @type {?string} 380 * @syscap SystemCapability.Communication.NetStack 381 * @since 10 382 */ 383 /** 384 * If this parameter is set, the system will use ca path specified by user, or else use preset ca by the system. 385 * @type {?string} 386 * @syscap SystemCapability.Communication.NetStack 387 * @atomicservice 388 * @since 11 389 */ 390 /** 391 * If this parameter is set, the system will use ca path specified by user, or else use preset ca by the system. 392 * @type {?string} 393 * @syscap SystemCapability.Communication.NetStack 394 * @crossplatform 395 * @atomicservice 396 * @since 12 397 */ 398 caPath?: string; 399 400 /** 401 * A PEM representation of a certificate. The system will create an X.509 certificate object in the SSL process. 402 * If the caPath option is set, the caData option will be ignored. 403 * Certificate chain is not supported. 404 * Maxium length is 8000 Bytes. 405 * @type { ?string } 406 * @syscap SystemCapability.Communication.NetStack 407 * @crossplatform 408 * @atomicservice 409 * @since 20 410 */ 411 caData?: string; 412 413 /** 414 * Which secure communication protocol is used, TLS (by defaul) or TLCP. 415 * If TLCP is used, all TLS related options, such as caPath, caData and clientCert, are ignored. 416 * @type { ?SslType } 417 * @syscap SystemCapability.Communication.NetStack 418 * @atomicservice 419 * @since 20 420 */ 421 sslType?: SslType; 422 423 /** 424 * Support the application to pass in client certificates, allowing the server to verify the 425 * client's encryption identity. 426 * @type { ?ClientCert } 427 * @syscap SystemCapability.Communication.NetStack 428 * @atomicservice 429 * @since 20 430 */ 431 clientEncCert?: ClientCert; 432 433 /** 434 * Used to set to uploading or downloading the start bytes. The default value is 0. 435 * HTTP standard (RFC 7233 section 3.1) allows servers to ignore range requests. 436 * For HTTP PUT uploads this option should not be used, since it may conflict with other options. 437 * @type {?number} 438 * @syscap SystemCapability.Communication.NetStack 439 * @since 11 440 */ 441 /** 442 * Used to set to uploading or downloading the start bytes. The default value is 0. 443 * HTTP standard (RFC 7233 section 3.1) allows servers to ignore range requests. 444 * For HTTP PUT uploads this option should not be used, since it may conflict with other options. 445 * @type {?number} 446 * @syscap SystemCapability.Communication.NetStack 447 * @crossplatform 448 * @since 12 449 */ 450 resumeFrom?: number; 451 452 /** 453 * Used to set to uploading or downloading the end bytes. Translate to the end if not set. 454 * HTTP standard (RFC 7233 section 3.1) allows servers to ignore range requests. 455 * For HTTP PUT uploads this option should not be used, since it may conflict with other options. 456 * @type {?number} 457 * @syscap SystemCapability.Communication.NetStack 458 * @since 11 459 */ 460 /** 461 * Used to set to uploading or downloading the end bytes. Translate to the end if not set. 462 * HTTP standard (RFC 7233 section 3.1) allows servers to ignore range requests. 463 * For HTTP PUT uploads this option should not be used, since it may conflict with other options. 464 * @type {?number} 465 * @syscap SystemCapability.Communication.NetStack 466 * @crossplatform 467 * @since 12 468 */ 469 resumeTo?: number; 470 471 /** 472 * Support the application to pass in client certificates, allowing the server to verify the client's identity. 473 * @type {?ClientCert} 474 * @syscap SystemCapability.Communication.NetStack 475 * @since 11 476 */ 477 /** 478 * Support the application to pass in client certificates, allowing the server to verify the client's identity. 479 * @type {?ClientCert} 480 * @syscap SystemCapability.Communication.NetStack 481 * @crossplatform 482 * @since 12 483 */ 484 clientCert?: ClientCert; 485 486 /** 487 * If this parameter is set, incoming DNS resolution server URL for the DoH server to use for name resolving. 488 * The parameter must be URL-encoded in the following format: "https://host:port/path". 489 * It MUST specify an HTTPS URL. 490 * @type {?string} 491 * @syscap SystemCapability.Communication.NetStack 492 * @since 11 493 */ 494 /** 495 * If this parameter is set, incoming DNS resolution server URL for the DoH server to use for name resolving. 496 * The parameter must be URL-encoded in the following format: "https://host:port/path". 497 * It MUST specify an HTTPS URL. 498 * @type {?string} 499 * @syscap SystemCapability.Communication.NetStack 500 * @crossplatform 501 * @since 12 502 */ 503 dnsOverHttps?: string; 504 505 /** 506 * If this parameter is set, use the specified DNS server for DNS resolution. 507 * Multiple DNS resolution servers can be set up, with a maximum of 3 servers. 508 * Only take the first three if there are more than three. 509 * @type {?Array<string>} 510 * @syscap SystemCapability.Communication.NetStack 511 * @since 11 512 */ 513 /** 514 * If this parameter is set, use the specified DNS server for DNS resolution. 515 * Multiple DNS resolution servers can be set up, with a maximum of 3 servers. 516 * Only take the first three if there are more than three. 517 * @type {?Array<string>} 518 * @syscap SystemCapability.Communication.NetStack 519 * @crossplatform 520 * @since 12 521 */ 522 dnsServers?: Array<string>; 523 524 /** 525 * The maximum limit of the response body. The default value is 5 * 1024 * 1024, in Byte. 526 * The maximum value is 100 * 1024 *1024, in Byte. 527 * @type {?number} 528 * @syscap SystemCapability.Communication.NetStack 529 * @since 11 530 */ 531 /** 532 * The maximum limit of the response body. The default value is 5 * 1024 * 1024, in Byte. 533 * The maximum value is 100 * 1024 *1024, in Byte. 534 * @type {?number} 535 * @syscap SystemCapability.Communication.NetStack 536 * @crossplatform 537 * @since 12 538 */ 539 maxLimit?: number; 540 541 /** 542 * The data fields which is supported by the HTTP protocol to post 543 * forms and by the SMTP and IMAP protocols to provide 544 * the email data to send/upload. 545 * @type {?Array<MultiFormData>} 546 * @syscap SystemCapability.Communication.NetStack 547 * @since 11 548 */ 549 /** 550 * The data fields which is supported by the HTTP protocol to post 551 * forms and by the SMTP and IMAP protocols to provide 552 * the email data to send/upload. 553 * @type {?Array<MultiFormData>} 554 * @syscap SystemCapability.Communication.NetStack 555 * @crossplatform 556 * @since 12 557 */ 558 multiFormDataList?: Array<MultiFormData>; 559 560 /** 561 * Certificate pinning option. If server certificate's digest does not match 562 * {@link CertificatePinning.publicKeyHash}, request will fail. 563 * @type {?(CertificatePinning | CertificatePinning[])} 564 * @syscap SystemCapability.Communication.NetStack 565 * @since 12 566 */ 567 certificatePinning?: CertificatePinning | CertificatePinning[]; 568 569 /** 570 * Certificate authority(CA) which is used to verify the remote server's identification. 571 * @type {?RemoteValidation} 572 * @syscap SystemCapability.Communication.NetStack 573 * @atomicservice 574 * @since 18 575 */ 576 remoteValidation?: RemoteValidation; 577 578 /** 579 * TLS option. 580 * @type {?TlsOptions} 581 * @syscap SystemCapability.Communication.NetStack 582 * @atomicservice 583 * @since 18 584 */ 585 tlsOptions?: TlsOptions; 586 587 /** 588 * HTTP server authentication settings. No authentication by default. 589 * @type {?ServerAuthentication} 590 * @syscap SystemCapability.Communication.NetStack 591 * @atomicservice 592 * @since 18 593 */ 594 serverAuthentication?: ServerAuthentication; 595 596 /** 597 * Address family option. 598 * @type {?AddressFamily} 599 * @syscap SystemCapability.Communication.NetStack 600 * @since 15 601 */ 602 addressFamily?: AddressFamily; 603 } 604 605 /** 606 * HTTP server authentication. 607 * @typedef ServerAuthentication 608 * @syscap SystemCapability.Communication.NetStack 609 * @atomicservice 610 * @since 18 611 */ 612 export interface ServerAuthentication { 613 /** 614 * Credential of server. 615 * @type {Credential} 616 * @syscap SystemCapability.Communication.NetStack 617 * @atomicservice 618 * @since 18 619 */ 620 credential: Credential; 621 /** 622 * Authentication type of server. If not set, negotiate with the server. 623 * @type {?AuthenticationType} 624 * @syscap SystemCapability.Communication.NetStack 625 * @atomicservice 626 * @since 18 627 */ 628 authenticationType?: AuthenticationType; 629 } 630 631 /** 632 * TlsOptions. 633 * 'system': use system tls configuration. 634 * TlsOption: tls version range, and specify cipher suite. 635 * @typedef {'system' | TlsConfig} 636 * @syscap SystemCapability.Communication.NetStack 637 * @atomicservice 638 * @since 18 639 */ 640 export type TlsOptions = 'system' | TlsConfig; 641 642 /** 643 * Remote Validation Type. 644 * @typedef {'system' | 'skip'} 645 * @syscap SystemCapability.Communication.NetStack 646 * @atomicservice 647 * @since 18 648 */ 649 export type RemoteValidation = 'system' | 'skip'; 650 651 /** 652 * The server's authentication type. 653 * @typedef {'basic' | 'ntlm' | 'digest'} 654 * @syscap SystemCapability.Communication.NetStack 655 * @atomicservice 656 * @since 18 657 */ 658 export type AuthenticationType = 'basic' | 'ntlm' | 'digest'; 659 660 /** 661 * The secure communication protocol. 662 * @typedef { 'TLS' | 'TLCP'} 663 * @syscap SystemCapability.Communication.NetStack 664 * @atomicservice 665 * @since 20 666 */ 667 export type SslType = 'TLS' | 'TLCP'; 668 669 /** 670 * HTTP credential. Some server or proxy server need this. 671 * @typedef Credential 672 * @syscap SystemCapability.Communication.NetStack 673 * @atomicservice 674 * @since 18 675 */ 676 export interface Credential { 677 /** 678 * Username of credential. Default is ''. 679 * @type {string} 680 * @syscap SystemCapability.Communication.NetStack 681 * @atomicservice 682 * @since 18 683 */ 684 username: string; 685 /** 686 * Password of credential. Default is ''. 687 * @type {string} 688 * @syscap SystemCapability.Communication.NetStack 689 * @atomicservice 690 * @since 18 691 */ 692 password: string; 693 } 694 695 /** 696 * TLS config. 697 * @typedef TlsConfig 698 * @syscap SystemCapability.Communication.NetStack 699 * @atomicservice 700 * @since 18 701 */ 702 export interface TlsConfig { 703 /** 704 * Minimum version num of Tls protocol. 705 * @type {TlsVersion} 706 * @syscap SystemCapability.Communication.NetStack 707 * @atomicservice 708 * @since 18 709 */ 710 tlsVersionMin: TlsVersion; 711 /** 712 * Maximum version num of Tls protocol. 713 * @type {TlsVersion} 714 * @syscap SystemCapability.Communication.NetStack 715 * @atomicservice 716 * @since 18 717 */ 718 tlsVersionMax: TlsVersion; 719 /** 720 * CipherSuites, cipherSuits must match tsl version, otherswise will set all system-supported cipherSuits. 721 * @type {?CipherSuite[]} 722 * @syscap SystemCapability.Communication.NetStack 723 * @atomicservice 724 * @since 18 725 */ 726 cipherSuites?: CipherSuite[]; 727 } 728 729 /** 730 * Cipher suite which TLS1.3+ support. 731 * The framework has a built-in preference order, but your choice will be recorded. 732 * @typedef {'TLS_AES_128_GCM_SHA256' | 'TLS_AES_256_GCM_SHA384' | 'TLS_CHACHA20_POLY1305_SHA256'} 733 * @syscap SystemCapability.Communication.NetStack 734 * @atomicservice 735 * @since 18 736 */ 737 export type TlsV13SpecificCipherSuite = 'TLS_AES_128_GCM_SHA256' | 'TLS_AES_256_GCM_SHA384' | 'TLS_CHACHA20_POLY1305_SHA256'; 738 739 /** 740 * Cipher suite which TLS1.2+ support. 741 * @typedef {'TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256' | 'TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256' | 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384' | 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384' | 'TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256' | 'TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256' | 'TLS_RSA_WITH_AES_128_GCM_SHA256' | 'TLS_RSA_WITH_AES_256_GCM_SHA384'} 742 * @syscap SystemCapability.Communication.NetStack 743 * @atomicservice 744 * @since 18 745 */ 746 export type TlsV12SpecificCipherSuite = 'TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256' | 'TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256' | 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384' | 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384' | 'TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256' | 'TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256' | 'TLS_RSA_WITH_AES_128_GCM_SHA256' | 'TLS_RSA_WITH_AES_256_GCM_SHA384'; 747 748 /** 749 * Cipher suite which TLS1.0+ support. 750 * @typedef {'TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA' | 'TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA' | 'TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA' | 'TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA' | 'TLS_RSA_WITH_AES_128_CBC_SHA' | 'TLS_RSA_WITH_AES_256_CBC_SHA' | 'TLS_RSA_WITH_3DES_EDE_CBC_SHA'} 751 * @syscap SystemCapability.Communication.NetStack 752 * @atomicservice 753 * @since 18 754 */ 755 export type TlsV10SpecificCipherSuite = 'TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA' | 'TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA' | 'TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA' | 'TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA' | 'TLS_RSA_WITH_AES_128_CBC_SHA' | 'TLS_RSA_WITH_AES_256_CBC_SHA' | 'TLS_RSA_WITH_3DES_EDE_CBC_SHA'; 756 757 /** 758 * Include all cipher suite. 759 * @typedef {TlsV13CipherSuite} 760 * @syscap SystemCapability.Communication.NetStack 761 * @atomicservice 762 * @since 18 763 */ 764 export type CipherSuite = TlsV13CipherSuite; 765 766 /** 767 * TLS1.3 cipher suite should include TLS1.2 cipher suite. 768 * @typedef {TlsV12CipherSuite | TlsV13SpecificCipherSuite} 769 * @syscap SystemCapability.Communication.NetStack 770 * @atomicservice 771 * @since 18 772 */ 773 export type TlsV13CipherSuite = TlsV12CipherSuite | TlsV13SpecificCipherSuite; 774 775 /** 776 * TLS1.2 cipher suite should include TLS1.1 cipher suite. 777 * @typedef {TlsV11CipherSuite | TlsV12SpecificCipherSuite} 778 * @syscap SystemCapability.Communication.NetStack 779 * @atomicservice 780 * @since 18 781 */ 782 export type TlsV12CipherSuite = TlsV11CipherSuite | TlsV12SpecificCipherSuite; 783 784 /** 785 * TLS1.1 cipher suite is same as TLS1.0 cipher suite. 786 * @typedef {TlsV10CipherSuite} 787 * @syscap SystemCapability.Communication.NetStack 788 * @atomicservice 789 * @since 18 790 */ 791 export type TlsV11CipherSuite = TlsV10CipherSuite; 792 793 /** 794 * TLS1.0 cipher suite. 795 * @typedef {TlsV10SpecificCipherSuite} 796 * @syscap SystemCapability.Communication.NetStack 797 * @atomicservice 798 * @since 18 799 */ 800 export type TlsV10CipherSuite = TlsV10SpecificCipherSuite; 801 802 /** 803 * Enum for Tls version 804 * @enum {number} 805 * @syscap SystemCapability.Communication.NetStack 806 * @atomicservice 807 * @since 18 808 */ 809 export enum TlsVersion { 810 /** 811 * Tls version 1.0 812 * @syscap SystemCapability.Communication.NetStack 813 * @atomicservice 814 * @since 18 815 */ 816 TLS_V_1_0 = 4, 817 818 /** 819 * Tls version 1.1 820 * @syscap SystemCapability.Communication.NetStack 821 * @atomicservice 822 * @since 18 823 */ 824 TLS_V_1_1 = 5, 825 826 /** 827 * Tls version 1.2 828 * @syscap SystemCapability.Communication.NetStack 829 * @atomicservice 830 * @since 18 831 */ 832 TLS_V_1_2 = 6, 833 834 /** 835 * Tls version 1.3 836 * @syscap SystemCapability.Communication.NetStack 837 * @atomicservice 838 * @since 18 839 */ 840 TLS_V_1_3 = 7 841 } 842 843 /** 844 * Represents the properties of a form object. 845 * @interface MultiFormData 846 * @syscap SystemCapability.Communication.NetStack 847 * @since 11 848 */ 849 /** 850 * Represents the properties of a form object. 851 * @interface MultiFormData 852 * @syscap SystemCapability.Communication.NetStack 853 * @crossplatform 854 * @since 12 855 */ 856 export interface MultiFormData { 857 /** 858 * MIME name for the data field. 859 * @type {string} 860 * @syscap SystemCapability.Communication.NetStack 861 * @since 11 862 */ 863 /** 864 * MIME name for the data field. 865 * @type {string} 866 * @syscap SystemCapability.Communication.NetStack 867 * @crossplatform 868 * @since 12 869 */ 870 name: string; 871 872 /** 873 * Content type of the data field. 874 * @type {string} 875 * @syscap SystemCapability.Communication.NetStack 876 * @since 11 877 */ 878 /** 879 * Content type of the data field. 880 * @type {string} 881 * @syscap SystemCapability.Communication.NetStack 882 * @crossplatform 883 * @since 12 884 */ 885 contentType: string; 886 887 /** 888 * Remote file name for the data field. 889 * @type {?string} 890 * @syscap SystemCapability.Communication.NetStack 891 * @since 11 892 */ 893 /** 894 * Remote file name for the data field. 895 * @type {?string} 896 * @syscap SystemCapability.Communication.NetStack 897 * @crossplatform 898 * @since 12 899 */ 900 remoteFileName?: string; 901 902 /** 903 * This parameter sets a mime part's body content from memory data. 904 * @type {?(string | Object | ArrayBuffer)} 905 * @syscap SystemCapability.Communication.NetStack 906 * @since 11 907 */ 908 /** 909 * This parameter sets a mime part's body content from memory data. 910 * @type {?(string | Object | ArrayBuffer)} 911 * @syscap SystemCapability.Communication.NetStack 912 * @crossplatform 913 * @since 12 914 */ 915 data?: string | Object | ArrayBuffer; 916 917 /** 918 * This parameter sets a mime part's body content from the file's contents. 919 * This is an alternative to curl_mime_data for setting data to a mime part. 920 * If data is empty, filePath must be set. 921 * If data has a value, filePath does not take effect. 922 * @type {?string} 923 * @syscap SystemCapability.Communication.NetStack 924 * @since 11 925 */ 926 /** 927 * This parameter sets a mime part's body content from the file's contents. 928 * This is an alternative to curl_mime_data for setting data to a mime part. 929 * If data is empty, filePath must be set. 930 * If data has a value, filePath does not take effect. 931 * @type {?string} 932 * @syscap SystemCapability.Communication.NetStack 933 * @crossplatform 934 * @since 12 935 */ 936 filePath?: string; 937 } 938 939 /** 940 * Enum for certificate types 941 * @enum {string} 942 * @syscap SystemCapability.Communication.NetStack 943 * @since 11 944 */ 945 /** 946 * Enum for certificate types 947 * @enum {string} 948 * @syscap SystemCapability.Communication.NetStack 949 * @crossplatform 950 * @since 12 951 */ 952 export enum CertType { 953 /** 954 * PEM format certificate 955 * @syscap SystemCapability.Communication.NetStack 956 * @since 11 957 */ 958 /** 959 * PEM format certificate 960 * @syscap SystemCapability.Communication.NetStack 961 * @crossplatform 962 * @since 12 963 */ 964 PEM = 'PEM', 965 966 /** 967 * DER format certificate 968 * @syscap SystemCapability.Communication.NetStack 969 * @since 11 970 */ 971 /** 972 * DER format certificate 973 * @syscap SystemCapability.Communication.NetStack 974 * @crossplatform 975 * @since 12 976 */ 977 DER = 'DER', 978 979 /** 980 * P12 format certificate 981 * @syscap SystemCapability.Communication.NetStack 982 * @since 11 983 */ 984 /** 985 * P12 format certificate 986 * @syscap SystemCapability.Communication.NetStack 987 * @crossplatform 988 * @since 12 989 */ 990 P12 = 'P12' 991 } 992 993 /** 994 * The clientCert field of the client certificate, which includes 4 attributes: 995 * client certificate (cert), client certificate type (certType), certificate private key (key), and passphrase (keyPassword). 996 * @interface ClientCert 997 * @syscap SystemCapability.Communication.NetStack 998 * @since 11 999 */ 1000 /** 1001 * The clientCert field of the client certificate, which includes 4 attributes: 1002 * client certificate (cert), client certificate type (certType), certificate private key (key), and passphrase (keyPassword). 1003 * @interface ClientCert 1004 * @syscap SystemCapability.Communication.NetStack 1005 * @crossplatform 1006 * @since 12 1007 */ 1008 export interface ClientCert { 1009 /** 1010 * The path to the client certificate file. 1011 * @type {string} 1012 * @syscap SystemCapability.Communication.NetStack 1013 * @since 11 1014 */ 1015 /** 1016 * The path to the client certificate file. 1017 * @type {string} 1018 * @syscap SystemCapability.Communication.NetStack 1019 * @crossplatform 1020 * @since 12 1021 */ 1022 certPath: string; 1023 1024 /** 1025 * The type of the client certificate. 1026 * @type {?CertType} 1027 * @syscap SystemCapability.Communication.NetStack 1028 * @since 11 1029 */ 1030 /** 1031 * The type of the client certificate. 1032 * @type {?CertType} 1033 * @syscap SystemCapability.Communication.NetStack 1034 * @crossplatform 1035 * @since 12 1036 */ 1037 certType?: CertType; 1038 1039 /** 1040 * The path of the client certificate private key file. 1041 * @type {string} 1042 * @syscap SystemCapability.Communication.NetStack 1043 * @since 11 1044 */ 1045 /** 1046 * The path of the client certificate private key file. 1047 * @type {string} 1048 * @syscap SystemCapability.Communication.NetStack 1049 * @crossplatform 1050 * @since 12 1051 */ 1052 keyPath: string; 1053 1054 /** 1055 * Password required to use the client certificate private key. 1056 * @type {?string} 1057 * @syscap SystemCapability.Communication.NetStack 1058 * @since 11 1059 */ 1060 /** 1061 * Password required to use the client certificate private key. 1062 * @type {?string} 1063 * @syscap SystemCapability.Communication.NetStack 1064 * @crossplatform 1065 * @since 12 1066 */ 1067 keyPassword?: string; 1068 } 1069 1070 /** 1071 * Certificate pinning option. 1072 * @interface CertificatePinning 1073 * @syscap SystemCapability.Communication.NetStack 1074 * @since 12 1075 */ 1076 interface CertificatePinning { 1077 /** 1078 * Public key hash. 1079 * @type {string} 1080 * @syscap SystemCapability.Communication.NetStack 1081 * @since 12 1082 */ 1083 publicKeyHash: string; 1084 /** 1085 * Certificate public key hash algorithm. 1086 * @type {'SHA-256'} 1087 * @syscap SystemCapability.Communication.NetStack 1088 * @since 12 1089 */ 1090 hashAlgorithm: 'SHA-256'; 1091 } 1092 1093 /** 1094 * <p>Defines an HTTP request task. Before invoking APIs provided by HttpRequest, 1095 * you must call createHttp() to create an HttpRequestTask object.</p> 1096 * @interface HttpRequest 1097 * @syscap SystemCapability.Communication.NetStack 1098 * @since 6 1099 */ 1100 /** 1101 * <p>Defines an HTTP request task. Before invoking APIs provided by HttpRequest, 1102 * you must call createHttp() to create an HttpRequestTask object.</p> 1103 * @interface HttpRequest 1104 * @syscap SystemCapability.Communication.NetStack 1105 * @crossplatform 1106 * @since 10 1107 */ 1108 /** 1109 * <p>Defines an HTTP request task. Before invoking APIs provided by HttpRequest, 1110 * you must call createHttp() to create an HttpRequestTask object.</p> 1111 * @interface HttpRequest 1112 * @syscap SystemCapability.Communication.NetStack 1113 * @crossplatform 1114 * @atomicservice 1115 * @since 11 1116 */ 1117 export interface HttpRequest { 1118 /** 1119 * Initiates an HTTP request to a given URL. 1120 * @permission ohos.permission.INTERNET 1121 * @param { string } url - URL for initiating an HTTP request. 1122 * @param { AsyncCallback<HttpResponse> } callback - the callback of request. 1123 * @throws { BusinessError } 401 - Parameter error. 1124 * @throws { BusinessError } 201 - Permission denied. 1125 * @throws { BusinessError } 2300001 - Unsupported protocol. 1126 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1127 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1128 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1129 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1130 * @throws { BusinessError } 2300008 - Invalid server response. 1131 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1132 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1133 * @throws { BusinessError } 2300018 - Transferred a partial file. 1134 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1135 * @throws { BusinessError } 2300025 - Upload failed. 1136 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1137 * @throws { BusinessError } 2300027 - Out of memory. 1138 * @throws { BusinessError } 2300028 - Operation timeout. 1139 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1140 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1141 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1142 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1143 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1144 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1145 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1146 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1147 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1148 * @throws { BusinessError } 2300070 - Remote disk full. 1149 * @throws { BusinessError } 2300073 - Remote file already exists. 1150 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1151 * @throws { BusinessError } 2300078 - Remote file not found. 1152 * @throws { BusinessError } 2300094 - Authentication error. 1153 * @throws { BusinessError } 2300999 - Internal error. 1154 * @syscap SystemCapability.Communication.NetStack 1155 * @since 6 1156 */ 1157 /** 1158 * Initiates an HTTP request to a given URL. 1159 * @permission ohos.permission.INTERNET 1160 * @param { string } url - URL for initiating an HTTP request. 1161 * @param { AsyncCallback<HttpResponse> } callback - the callback of request. 1162 * @throws { BusinessError } 401 - Parameter error. 1163 * @throws { BusinessError } 201 - Permission denied. 1164 * @throws { BusinessError } 2300001 - Unsupported protocol. 1165 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1166 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1167 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1168 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1169 * @throws { BusinessError } 2300008 - Invalid server response. 1170 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1171 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1172 * @throws { BusinessError } 2300018 - Transferred a partial file. 1173 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1174 * @throws { BusinessError } 2300025 - Upload failed. 1175 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1176 * @throws { BusinessError } 2300027 - Out of memory. 1177 * @throws { BusinessError } 2300028 - Operation timeout. 1178 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1179 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1180 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1181 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1182 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1183 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1184 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1185 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1186 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1187 * @throws { BusinessError } 2300070 - Remote disk full. 1188 * @throws { BusinessError } 2300073 - Remote file already exists. 1189 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1190 * @throws { BusinessError } 2300078 - Remote file not found. 1191 * @throws { BusinessError } 2300094 - Authentication error. 1192 * @throws { BusinessError } 2300999 - Internal error. 1193 * @syscap SystemCapability.Communication.NetStack 1194 * @crossplatform 1195 * @since 10 1196 */ 1197 /** 1198 * Initiates an HTTP request to a given URL. 1199 * @permission ohos.permission.INTERNET 1200 * @param { string } url - URL for initiating an HTTP request. 1201 * @param { AsyncCallback<HttpResponse> } callback - the callback of request. 1202 * @throws { BusinessError } 401 - Parameter error. 1203 * @throws { BusinessError } 201 - Permission denied. 1204 * @throws { BusinessError } 2300001 - Unsupported protocol. 1205 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1206 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1207 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1208 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1209 * @throws { BusinessError } 2300008 - Invalid server response. 1210 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1211 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1212 * @throws { BusinessError } 2300018 - Transferred a partial file. 1213 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1214 * @throws { BusinessError } 2300025 - Upload failed. 1215 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1216 * @throws { BusinessError } 2300027 - Out of memory. 1217 * @throws { BusinessError } 2300028 - Operation timeout. 1218 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1219 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1220 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1221 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1222 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1223 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1224 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1225 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1226 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1227 * @throws { BusinessError } 2300070 - Remote disk full. 1228 * @throws { BusinessError } 2300073 - Remote file already exists. 1229 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1230 * @throws { BusinessError } 2300078 - Remote file not found. 1231 * @throws { BusinessError } 2300094 - Authentication error. 1232 * @throws { BusinessError } 2300999 - Internal error. 1233 * @syscap SystemCapability.Communication.NetStack 1234 * @crossplatform 1235 * @atomicservice 1236 * @since 11 1237 */ 1238 /** 1239 * Initiates an HTTP request to a given URL. 1240 * @permission ohos.permission.INTERNET 1241 * @param { string } url - URL for initiating an HTTP request. 1242 * @param { AsyncCallback<HttpResponse> } callback - the callback of request. 1243 * @throws { BusinessError } 401 - Parameter error. 1244 * @throws { BusinessError } 201 - Permission denied. 1245 * @throws { BusinessError } 2300001 - Unsupported protocol. 1246 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1247 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1248 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1249 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1250 * @throws { BusinessError } 2300008 - Invalid server response. 1251 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1252 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1253 * @throws { BusinessError } 2300018 - Transferred a partial file. 1254 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1255 * @throws { BusinessError } 2300025 - Upload failed. 1256 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1257 * @throws { BusinessError } 2300027 - Out of memory. 1258 * @throws { BusinessError } 2300028 - Operation timeout. 1259 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1260 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1261 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1262 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1263 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1264 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1265 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1266 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1267 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1268 * @throws { BusinessError } 2300070 - Remote disk full. 1269 * @throws { BusinessError } 2300073 - Remote file already exists. 1270 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1271 * @throws { BusinessError } 2300078 - Remote file not found. 1272 * @throws { BusinessError } 2300094 - Authentication error. 1273 * @throws { BusinessError } 2300998 - It is not allowed to access this domain. 1274 * @throws { BusinessError } 2300999 - Internal error. 1275 * @syscap SystemCapability.Communication.NetStack 1276 * @crossplatform 1277 * @atomicservice 1278 * @since 12 1279 */ 1280 /** 1281 * Initiates an HTTP request to a given URL. 1282 * @permission ohos.permission.INTERNET 1283 * @param { string } url - URL for initiating an HTTP request. 1284 * @param { AsyncCallback<HttpResponse> } callback - the callback of request. 1285 * @throws { BusinessError } 401 - Parameter error. 1286 * @throws { BusinessError } 201 - Permission denied. 1287 * @throws { BusinessError } 2300001 - Unsupported protocol. 1288 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1289 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1290 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1291 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1292 * @throws { BusinessError } 2300008 - Invalid server response. 1293 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1294 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1295 * @throws { BusinessError } 2300018 - Transferred a partial file. 1296 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1297 * @throws { BusinessError } 2300025 - Upload failed. 1298 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1299 * @throws { BusinessError } 2300027 - Out of memory. 1300 * @throws { BusinessError } 2300028 - Operation timeout. 1301 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1302 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1303 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1304 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1305 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1306 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1307 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1308 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1309 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1310 * @throws { BusinessError } 2300070 - Remote disk full. 1311 * @throws { BusinessError } 2300073 - Remote file already exists. 1312 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1313 * @throws { BusinessError } 2300078 - Remote file not found. 1314 * @throws { BusinessError } 2300094 - Authentication error. 1315 * @throws { BusinessError } 2300997 - Cleartext traffic not permitted. 1316 * @throws { BusinessError } 2300998 - It is not allowed to access this domain. 1317 * @throws { BusinessError } 2300999 - Internal error. 1318 * @syscap SystemCapability.Communication.NetStack 1319 * @crossplatform 1320 * @atomicservice 1321 * @since 18 1322 */ 1323 request(url: string, callback: AsyncCallback<HttpResponse>): void; 1324 1325 /** 1326 * Initiates an HTTP request to a given URL. 1327 * @permission ohos.permission.INTERNET 1328 * @param { string } url - URL for initiating an HTTP request. 1329 * @param { HttpRequestOptions } options - Optional parameters {@link HttpRequestOptions}. 1330 * @param { AsyncCallback<HttpResponse> } callback - the callback of request.. 1331 * @throws { BusinessError } 401 - Parameter error. 1332 * @throws { BusinessError } 201 - Permission denied. 1333 * @throws { BusinessError } 2300001 - Unsupported protocol. 1334 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1335 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1336 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1337 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1338 * @throws { BusinessError } 2300008 - Invalid server response. 1339 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1340 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1341 * @throws { BusinessError } 2300018 - Transferred a partial file. 1342 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1343 * @throws { BusinessError } 2300025 - Upload failed. 1344 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1345 * @throws { BusinessError } 2300027 - Out of memory. 1346 * @throws { BusinessError } 2300028 - Operation timeout. 1347 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1348 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1349 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1350 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1351 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1352 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1353 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1354 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1355 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1356 * @throws { BusinessError } 2300070 - Remote disk full. 1357 * @throws { BusinessError } 2300073 - Remote file already exists. 1358 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1359 * @throws { BusinessError } 2300078 - Remote file not found. 1360 * @throws { BusinessError } 2300094 - Authentication error. 1361 * @throws { BusinessError } 2300999 - Internal error. 1362 * @syscap SystemCapability.Communication.NetStack 1363 * @since 6 1364 */ 1365 /** 1366 * Initiates an HTTP request to a given URL. 1367 * @permission ohos.permission.INTERNET 1368 * @param { string } url - URL for initiating an HTTP request. 1369 * @param { HttpRequestOptions } options - Optional parameters {@link HttpRequestOptions}. 1370 * @param { AsyncCallback<HttpResponse> } callback - the callback of request. 1371 * @throws { BusinessError } 401 - Parameter error. 1372 * @throws { BusinessError } 201 - Permission denied. 1373 * @throws { BusinessError } 2300001 - Unsupported protocol. 1374 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1375 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1376 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1377 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1378 * @throws { BusinessError } 2300008 - Invalid server response. 1379 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1380 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1381 * @throws { BusinessError } 2300018 - Transferred a partial file. 1382 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1383 * @throws { BusinessError } 2300025 - Upload failed. 1384 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1385 * @throws { BusinessError } 2300027 - Out of memory. 1386 * @throws { BusinessError } 2300028 - Operation timeout. 1387 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1388 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1389 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1390 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1391 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1392 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1393 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1394 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1395 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1396 * @throws { BusinessError } 2300070 - Remote disk full. 1397 * @throws { BusinessError } 2300073 - Remote file already exists. 1398 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1399 * @throws { BusinessError } 2300078 - Remote file not found. 1400 * @throws { BusinessError } 2300094 - Authentication error. 1401 * @throws { BusinessError } 2300999 - Internal error. 1402 * @syscap SystemCapability.Communication.NetStack 1403 * @crossplatform 1404 * @since 10 1405 */ 1406 /** 1407 * Initiates an HTTP request to a given URL. 1408 * @permission ohos.permission.INTERNET 1409 * @param { string } url - URL for initiating an HTTP request. 1410 * @param { HttpRequestOptions } options - Optional parameters {@link HttpRequestOptions}. 1411 * @param { AsyncCallback<HttpResponse> } callback - the callback of request. 1412 * @throws { BusinessError } 401 - Parameter error. 1413 * @throws { BusinessError } 201 - Permission denied. 1414 * @throws { BusinessError } 2300001 - Unsupported protocol. 1415 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1416 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1417 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1418 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1419 * @throws { BusinessError } 2300008 - Invalid server response. 1420 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1421 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1422 * @throws { BusinessError } 2300018 - Transferred a partial file. 1423 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1424 * @throws { BusinessError } 2300025 - Upload failed. 1425 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1426 * @throws { BusinessError } 2300027 - Out of memory. 1427 * @throws { BusinessError } 2300028 - Operation timeout. 1428 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1429 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1430 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1431 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1432 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1433 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1434 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1435 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1436 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1437 * @throws { BusinessError } 2300070 - Remote disk full. 1438 * @throws { BusinessError } 2300073 - Remote file already exists. 1439 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1440 * @throws { BusinessError } 2300078 - Remote file not found. 1441 * @throws { BusinessError } 2300094 - Authentication error. 1442 * @throws { BusinessError } 2300999 - Internal error. 1443 * @syscap SystemCapability.Communication.NetStack 1444 * @crossplatform 1445 * @atomicservice 1446 * @since 11 1447 */ 1448 /** 1449 * Initiates an HTTP request to a given URL. 1450 * @permission ohos.permission.INTERNET 1451 * @param { string } url - URL for initiating an HTTP request. 1452 * @param { HttpRequestOptions } options - Optional parameters {@link HttpRequestOptions}. 1453 * @param { AsyncCallback<HttpResponse> } callback - the callback of request. 1454 * @throws { BusinessError } 401 - Parameter error. 1455 * @throws { BusinessError } 201 - Permission denied. 1456 * @throws { BusinessError } 2300001 - Unsupported protocol. 1457 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1458 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1459 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1460 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1461 * @throws { BusinessError } 2300008 - Invalid server response. 1462 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1463 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1464 * @throws { BusinessError } 2300018 - Transferred a partial file. 1465 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1466 * @throws { BusinessError } 2300025 - Upload failed. 1467 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1468 * @throws { BusinessError } 2300027 - Out of memory. 1469 * @throws { BusinessError } 2300028 - Operation timeout. 1470 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1471 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1472 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1473 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1474 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1475 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1476 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1477 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1478 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1479 * @throws { BusinessError } 2300070 - Remote disk full. 1480 * @throws { BusinessError } 2300073 - Remote file already exists. 1481 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1482 * @throws { BusinessError } 2300078 - Remote file not found. 1483 * @throws { BusinessError } 2300094 - Authentication error. 1484 * @throws { BusinessError } 2300998 - It is not allowed to access this domain. 1485 * @throws { BusinessError } 2300999 - Internal error. 1486 * @syscap SystemCapability.Communication.NetStack 1487 * @crossplatform 1488 * @atomicservice 1489 * @since 12 1490 */ 1491 /** 1492 * Initiates an HTTP request to a given URL. 1493 * @permission ohos.permission.INTERNET 1494 * @param { string } url - URL for initiating an HTTP request. 1495 * @param { HttpRequestOptions } options - Optional parameters {@link HttpRequestOptions}. 1496 * @param { AsyncCallback<HttpResponse> } callback - the callback of request. 1497 * @throws { BusinessError } 401 - Parameter error. 1498 * @throws { BusinessError } 201 - Permission denied. 1499 * @throws { BusinessError } 2300001 - Unsupported protocol. 1500 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1501 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1502 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1503 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1504 * @throws { BusinessError } 2300008 - Invalid server response. 1505 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1506 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1507 * @throws { BusinessError } 2300018 - Transferred a partial file. 1508 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1509 * @throws { BusinessError } 2300025 - Upload failed. 1510 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1511 * @throws { BusinessError } 2300027 - Out of memory. 1512 * @throws { BusinessError } 2300028 - Operation timeout. 1513 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1514 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1515 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1516 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1517 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1518 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1519 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1520 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1521 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1522 * @throws { BusinessError } 2300070 - Remote disk full. 1523 * @throws { BusinessError } 2300073 - Remote file already exists. 1524 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1525 * @throws { BusinessError } 2300078 - Remote file not found. 1526 * @throws { BusinessError } 2300094 - Authentication error. 1527 * @throws { BusinessError } 2300997 - Cleartext traffic not permitted. 1528 * @throws { BusinessError } 2300998 - It is not allowed to access this domain. 1529 * @throws { BusinessError } 2300999 - Internal error. 1530 * @syscap SystemCapability.Communication.NetStack 1531 * @crossplatform 1532 * @atomicservice 1533 * @since 18 1534 */ 1535 request(url: string, options: HttpRequestOptions, callback: AsyncCallback<HttpResponse>): void; 1536 1537 /** 1538 * Initiates an HTTP request to a given URL. 1539 * @permission ohos.permission.INTERNET 1540 * @param { string } url - URL for initiating an HTTP request. 1541 * @param { HttpRequestOptions } [options] - Optional parameters {@link HttpRequestOptions}. 1542 * @returns { Promise<HttpResponse> } The promise returned by the function. 1543 * @throws { BusinessError } 401 - Parameter error. 1544 * @throws { BusinessError } 201 - Permission denied. 1545 * @throws { BusinessError } 2300001 - Unsupported protocol. 1546 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1547 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1548 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1549 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1550 * @throws { BusinessError } 2300008 - Invalid server response. 1551 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1552 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1553 * @throws { BusinessError } 2300018 - Transferred a partial file. 1554 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1555 * @throws { BusinessError } 2300025 - Upload failed. 1556 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1557 * @throws { BusinessError } 2300027 - Out of memory. 1558 * @throws { BusinessError } 2300028 - Operation timeout. 1559 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1560 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1561 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1562 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1563 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1564 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1565 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1566 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1567 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1568 * @throws { BusinessError } 2300070 - Remote disk full. 1569 * @throws { BusinessError } 2300073 - Remote file already exists. 1570 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1571 * @throws { BusinessError } 2300078 - Remote file not found. 1572 * @throws { BusinessError } 2300094 - Authentication error. 1573 * @throws { BusinessError } 2300999 - Internal error. 1574 * @syscap SystemCapability.Communication.NetStack 1575 * @since 6 1576 */ 1577 /** 1578 * Initiates an HTTP request to a given URL. 1579 * @permission ohos.permission.INTERNET 1580 * @param { string } url - URL for initiating an HTTP request. 1581 * @param { HttpRequestOptions } [options] - Optional parameters {@link HttpRequestOptions}. 1582 * @returns { Promise<HttpResponse> } The promise returned by the function. 1583 * @throws { BusinessError } 401 - Parameter error. 1584 * @throws { BusinessError } 201 - Permission denied. 1585 * @throws { BusinessError } 2300001 - Unsupported protocol. 1586 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1587 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1588 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1589 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1590 * @throws { BusinessError } 2300008 - Invalid server response. 1591 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1592 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1593 * @throws { BusinessError } 2300018 - Transferred a partial file. 1594 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1595 * @throws { BusinessError } 2300025 - Upload failed. 1596 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1597 * @throws { BusinessError } 2300027 - Out of memory. 1598 * @throws { BusinessError } 2300028 - Operation timeout. 1599 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1600 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1601 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1602 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1603 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1604 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1605 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1606 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1607 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1608 * @throws { BusinessError } 2300070 - Remote disk full. 1609 * @throws { BusinessError } 2300073 - Remote file already exists. 1610 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1611 * @throws { BusinessError } 2300078 - Remote file not found. 1612 * @throws { BusinessError } 2300094 - Authentication error. 1613 * @throws { BusinessError } 2300999 - Internal error. 1614 * @syscap SystemCapability.Communication.NetStack 1615 * @crossplatform 1616 * @since 10 1617 */ 1618 /** 1619 * Initiates an HTTP request to a given URL. 1620 * @permission ohos.permission.INTERNET 1621 * @param { string } url - URL for initiating an HTTP request. 1622 * @param { HttpRequestOptions } [options] - Optional parameters {@link HttpRequestOptions}. 1623 * @returns { Promise<HttpResponse> } The promise returned by the function. 1624 * @throws { BusinessError } 401 - Parameter error. 1625 * @throws { BusinessError } 201 - Permission denied. 1626 * @throws { BusinessError } 2300001 - Unsupported protocol. 1627 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1628 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1629 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1630 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1631 * @throws { BusinessError } 2300008 - Invalid server response. 1632 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1633 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1634 * @throws { BusinessError } 2300018 - Transferred a partial file. 1635 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1636 * @throws { BusinessError } 2300025 - Upload failed. 1637 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1638 * @throws { BusinessError } 2300027 - Out of memory. 1639 * @throws { BusinessError } 2300028 - Operation timeout. 1640 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1641 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1642 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1643 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1644 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1645 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1646 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1647 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1648 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1649 * @throws { BusinessError } 2300070 - Remote disk full. 1650 * @throws { BusinessError } 2300073 - Remote file already exists. 1651 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1652 * @throws { BusinessError } 2300078 - Remote file not found. 1653 * @throws { BusinessError } 2300094 - Authentication error. 1654 * @throws { BusinessError } 2300999 - Internal error. 1655 * @syscap SystemCapability.Communication.NetStack 1656 * @crossplatform 1657 * @atomicservice 1658 * @since 11 1659 */ 1660 /** 1661 * Initiates an HTTP request to a given URL. 1662 * @permission ohos.permission.INTERNET 1663 * @param { string } url - URL for initiating an HTTP request. 1664 * @param { HttpRequestOptions } [options] - Optional parameters {@link HttpRequestOptions}. 1665 * @returns { Promise<HttpResponse> } The promise returned by the function. 1666 * @throws { BusinessError } 401 - Parameter error. 1667 * @throws { BusinessError } 201 - Permission denied. 1668 * @throws { BusinessError } 2300001 - Unsupported protocol. 1669 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1670 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1671 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1672 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1673 * @throws { BusinessError } 2300008 - Invalid server response. 1674 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1675 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1676 * @throws { BusinessError } 2300018 - Transferred a partial file. 1677 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1678 * @throws { BusinessError } 2300025 - Upload failed. 1679 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1680 * @throws { BusinessError } 2300027 - Out of memory. 1681 * @throws { BusinessError } 2300028 - Operation timeout. 1682 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1683 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1684 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1685 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1686 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1687 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1688 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1689 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1690 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1691 * @throws { BusinessError } 2300070 - Remote disk full. 1692 * @throws { BusinessError } 2300073 - Remote file already exists. 1693 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1694 * @throws { BusinessError } 2300078 - Remote file not found. 1695 * @throws { BusinessError } 2300094 - Authentication error. 1696 * @throws { BusinessError } 2300998 - It is not allowed to access this domain. 1697 * @throws { BusinessError } 2300999 - Internal error. 1698 * @syscap SystemCapability.Communication.NetStack 1699 * @crossplatform 1700 * @atomicservice 1701 * @since 12 1702 */ 1703 /** 1704 * Initiates an HTTP request to a given URL. 1705 * @permission ohos.permission.INTERNET 1706 * @param { string } url - URL for initiating an HTTP request. 1707 * @param { HttpRequestOptions } [options] - Optional parameters {@link HttpRequestOptions}. 1708 * @returns { Promise<HttpResponse> } The promise returned by the function. 1709 * @throws { BusinessError } 401 - Parameter error. 1710 * @throws { BusinessError } 201 - Permission denied. 1711 * @throws { BusinessError } 2300001 - Unsupported protocol. 1712 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1713 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1714 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1715 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1716 * @throws { BusinessError } 2300008 - Invalid server response. 1717 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1718 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1719 * @throws { BusinessError } 2300018 - Transferred a partial file. 1720 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1721 * @throws { BusinessError } 2300025 - Upload failed. 1722 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1723 * @throws { BusinessError } 2300027 - Out of memory. 1724 * @throws { BusinessError } 2300028 - Operation timeout. 1725 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1726 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1727 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1728 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1729 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1730 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1731 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1732 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1733 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1734 * @throws { BusinessError } 2300070 - Remote disk full. 1735 * @throws { BusinessError } 2300073 - Remote file already exists. 1736 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1737 * @throws { BusinessError } 2300078 - Remote file not found. 1738 * @throws { BusinessError } 2300094 - Authentication error. 1739 * @throws { BusinessError } 2300997 - Cleartext traffic not permitted. 1740 * @throws { BusinessError } 2300998 - It is not allowed to access this domain. 1741 * @throws { BusinessError } 2300999 - Internal error. 1742 * @syscap SystemCapability.Communication.NetStack 1743 * @crossplatform 1744 * @atomicservice 1745 * @since 18 1746 */ 1747 request(url: string, options?: HttpRequestOptions): Promise<HttpResponse>; 1748 1749 /** 1750 * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. 1751 * @permission ohos.permission.INTERNET 1752 * @param { string } url - URL for initiating an HTTP request. 1753 * @param { AsyncCallback<number> } callback - Returns the callback of requestInStream {@link ResponseCode}, 1754 * should use on_headersReceive and on_dataReceive to get http response. 1755 * @throws { BusinessError } 401 - Parameter error. 1756 * @throws { BusinessError } 201 - Permission denied. 1757 * @throws { BusinessError } 2300001 - Unsupported protocol. 1758 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1759 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1760 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1761 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1762 * @throws { BusinessError } 2300008 - Invalid server response. 1763 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1764 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1765 * @throws { BusinessError } 2300018 - Transferred a partial file. 1766 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1767 * @throws { BusinessError } 2300025 - Upload failed. 1768 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1769 * @throws { BusinessError } 2300027 - Out of memory. 1770 * @throws { BusinessError } 2300028 - Operation timeout. 1771 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1772 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1773 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1774 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1775 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1776 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1777 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1778 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1779 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1780 * @throws { BusinessError } 2300070 - Remote disk full. 1781 * @throws { BusinessError } 2300073 - Remote file already exists. 1782 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1783 * @throws { BusinessError } 2300078 - Remote file not found. 1784 * @throws { BusinessError } 2300094 - Authentication error. 1785 * @throws { BusinessError } 2300999 - Internal error. 1786 * @syscap SystemCapability.Communication.NetStack 1787 * @since 10 1788 */ 1789 /** 1790 * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. 1791 * @permission ohos.permission.INTERNET 1792 * @param { string } url - URL for initiating an HTTP request. 1793 * @param { AsyncCallback<number> } callback - Returns the callback of requestInStream {@link ResponseCode}, 1794 * should use on_headersReceive and on_dataReceive to get http response. 1795 * @throws { BusinessError } 401 - Parameter error. 1796 * @throws { BusinessError } 201 - Permission denied. 1797 * @throws { BusinessError } 2300001 - Unsupported protocol. 1798 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1799 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1800 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1801 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1802 * @throws { BusinessError } 2300008 - Invalid server response. 1803 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1804 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1805 * @throws { BusinessError } 2300018 - Transferred a partial file. 1806 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1807 * @throws { BusinessError } 2300025 - Upload failed. 1808 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1809 * @throws { BusinessError } 2300027 - Out of memory. 1810 * @throws { BusinessError } 2300028 - Operation timeout. 1811 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1812 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1813 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1814 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1815 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1816 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1817 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1818 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1819 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1820 * @throws { BusinessError } 2300070 - Remote disk full. 1821 * @throws { BusinessError } 2300073 - Remote file already exists. 1822 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1823 * @throws { BusinessError } 2300078 - Remote file not found. 1824 * @throws { BusinessError } 2300094 - Authentication error. 1825 * @throws { BusinessError } 2300998 - It is not allowed to access this domain. 1826 * @throws { BusinessError } 2300999 - Internal error. 1827 * @syscap SystemCapability.Communication.NetStack 1828 * @since 12 1829 */ 1830 /** 1831 * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. 1832 * @permission ohos.permission.INTERNET 1833 * @param { string } url - URL for initiating an HTTP request. 1834 * @param { AsyncCallback<number> } callback - Returns the callback of requestInStream {@link ResponseCode}, 1835 * should use on_headersReceive and on_dataReceive to get http response. 1836 * @throws { BusinessError } 401 - Parameter error. 1837 * @throws { BusinessError } 201 - Permission denied. 1838 * @throws { BusinessError } 2300001 - Unsupported protocol. 1839 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1840 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1841 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1842 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1843 * @throws { BusinessError } 2300008 - Invalid server response. 1844 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1845 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1846 * @throws { BusinessError } 2300018 - Transferred a partial file. 1847 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1848 * @throws { BusinessError } 2300025 - Upload failed. 1849 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1850 * @throws { BusinessError } 2300027 - Out of memory. 1851 * @throws { BusinessError } 2300028 - Operation timeout. 1852 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1853 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1854 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1855 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1856 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1857 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1858 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1859 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1860 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1861 * @throws { BusinessError } 2300070 - Remote disk full. 1862 * @throws { BusinessError } 2300073 - Remote file already exists. 1863 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1864 * @throws { BusinessError } 2300078 - Remote file not found. 1865 * @throws { BusinessError } 2300094 - Authentication error. 1866 * @throws { BusinessError } 2300998 - It is not allowed to access this domain. 1867 * @throws { BusinessError } 2300999 - Internal error. 1868 * @syscap SystemCapability.Communication.NetStack 1869 * @atomicservice 1870 * @since 15 1871 */ 1872 /** 1873 * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. 1874 * @permission ohos.permission.INTERNET 1875 * @param { string } url - URL for initiating an HTTP request. 1876 * @param { AsyncCallback<number> } callback - Returns the callback of requestInStream {@link ResponseCode}, 1877 * should use on_headersReceive and on_dataReceive to get http response. 1878 * @throws { BusinessError } 401 - Parameter error. 1879 * @throws { BusinessError } 201 - Permission denied. 1880 * @throws { BusinessError } 2300001 - Unsupported protocol. 1881 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1882 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1883 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1884 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1885 * @throws { BusinessError } 2300008 - Invalid server response. 1886 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1887 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1888 * @throws { BusinessError } 2300018 - Transferred a partial file. 1889 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1890 * @throws { BusinessError } 2300025 - Upload failed. 1891 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1892 * @throws { BusinessError } 2300027 - Out of memory. 1893 * @throws { BusinessError } 2300028 - Operation timeout. 1894 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1895 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1896 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1897 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1898 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1899 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1900 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1901 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1902 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1903 * @throws { BusinessError } 2300070 - Remote disk full. 1904 * @throws { BusinessError } 2300073 - Remote file already exists. 1905 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1906 * @throws { BusinessError } 2300078 - Remote file not found. 1907 * @throws { BusinessError } 2300094 - Authentication error. 1908 * @throws { BusinessError } 2300997 - Cleartext traffic not permitted. 1909 * @throws { BusinessError } 2300998 - It is not allowed to access this domain. 1910 * @throws { BusinessError } 2300999 - Internal error. 1911 * @syscap SystemCapability.Communication.NetStack 1912 * @crossplatform 1913 * @atomicservice 1914 * @since 18 1915 */ 1916 requestInStream(url: string, callback: AsyncCallback<number>): void; 1917 1918 /** 1919 * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. 1920 * @permission ohos.permission.INTERNET 1921 * @param { string } url - URL for initiating an HTTP request. 1922 * @param { HttpRequestOptions } options - Optional parameters {@link HttpRequestOptions}. 1923 * @param { AsyncCallback<number> } callback - the callback of requestInStream. 1924 * @throws { BusinessError } 401 - Parameter error. 1925 * @throws { BusinessError } 201 - Permission denied. 1926 * @throws { BusinessError } 2300001 - Unsupported protocol. 1927 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1928 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1929 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1930 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1931 * @throws { BusinessError } 2300008 - Invalid server response. 1932 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1933 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1934 * @throws { BusinessError } 2300018 - Transferred a partial file. 1935 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1936 * @throws { BusinessError } 2300025 - Upload failed. 1937 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1938 * @throws { BusinessError } 2300027 - Out of memory. 1939 * @throws { BusinessError } 2300028 - Operation timeout. 1940 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1941 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1942 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1943 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1944 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1945 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1946 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1947 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1948 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1949 * @throws { BusinessError } 2300070 - Remote disk full. 1950 * @throws { BusinessError } 2300073 - Remote file already exists. 1951 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1952 * @throws { BusinessError } 2300078 - Remote file not found. 1953 * @throws { BusinessError } 2300094 - Authentication error. 1954 * @throws { BusinessError } 2300999 - Internal error. 1955 * @syscap SystemCapability.Communication.NetStack 1956 * @since 10 1957 */ 1958 /** 1959 * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. 1960 * @permission ohos.permission.INTERNET 1961 * @param { string } url - URL for initiating an HTTP request. 1962 * @param { HttpRequestOptions } options - Optional parameters {@link HttpRequestOptions}. 1963 * @param { AsyncCallback<number> } callback - the callback of requestInStream. 1964 * @throws { BusinessError } 401 - Parameter error. 1965 * @throws { BusinessError } 201 - Permission denied. 1966 * @throws { BusinessError } 2300001 - Unsupported protocol. 1967 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 1968 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 1969 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 1970 * @throws { BusinessError } 2300007 - Failed to connect to the server. 1971 * @throws { BusinessError } 2300008 - Invalid server response. 1972 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 1973 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 1974 * @throws { BusinessError } 2300018 - Transferred a partial file. 1975 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 1976 * @throws { BusinessError } 2300025 - Upload failed. 1977 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 1978 * @throws { BusinessError } 2300027 - Out of memory. 1979 * @throws { BusinessError } 2300028 - Operation timeout. 1980 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 1981 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 1982 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 1983 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 1984 * @throws { BusinessError } 2300058 - Local SSL certificate error. 1985 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 1986 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 1987 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 1988 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 1989 * @throws { BusinessError } 2300070 - Remote disk full. 1990 * @throws { BusinessError } 2300073 - Remote file already exists. 1991 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 1992 * @throws { BusinessError } 2300078 - Remote file not found. 1993 * @throws { BusinessError } 2300094 - Authentication error. 1994 * @throws { BusinessError } 2300998 - It is not allowed to access this domain. 1995 * @throws { BusinessError } 2300999 - Internal error. 1996 * @syscap SystemCapability.Communication.NetStack 1997 * @since 12 1998 */ 1999 /** 2000 * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. 2001 * @permission ohos.permission.INTERNET 2002 * @param { string } url - URL for initiating an HTTP request. 2003 * @param { HttpRequestOptions } options - Optional parameters {@link HttpRequestOptions}. 2004 * @param { AsyncCallback<number> } callback - the callback of requestInStream. 2005 * @throws { BusinessError } 401 - Parameter error. 2006 * @throws { BusinessError } 201 - Permission denied. 2007 * @throws { BusinessError } 2300001 - Unsupported protocol. 2008 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 2009 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 2010 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 2011 * @throws { BusinessError } 2300007 - Failed to connect to the server. 2012 * @throws { BusinessError } 2300008 - Invalid server response. 2013 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 2014 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 2015 * @throws { BusinessError } 2300018 - Transferred a partial file. 2016 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 2017 * @throws { BusinessError } 2300025 - Upload failed. 2018 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 2019 * @throws { BusinessError } 2300027 - Out of memory. 2020 * @throws { BusinessError } 2300028 - Operation timeout. 2021 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 2022 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 2023 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 2024 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 2025 * @throws { BusinessError } 2300058 - Local SSL certificate error. 2026 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 2027 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 2028 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 2029 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 2030 * @throws { BusinessError } 2300070 - Remote disk full. 2031 * @throws { BusinessError } 2300073 - Remote file already exists. 2032 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 2033 * @throws { BusinessError } 2300078 - Remote file not found. 2034 * @throws { BusinessError } 2300094 - Authentication error. 2035 * @throws { BusinessError } 2300998 - It is not allowed to access this domain. 2036 * @throws { BusinessError } 2300999 - Internal error. 2037 * @syscap SystemCapability.Communication.NetStack 2038 * @atomicservice 2039 * @since 15 2040 */ 2041 /** 2042 * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. 2043 * @permission ohos.permission.INTERNET 2044 * @param { string } url - URL for initiating an HTTP request. 2045 * @param { HttpRequestOptions } options - Optional parameters {@link HttpRequestOptions}. 2046 * @param { AsyncCallback<number> } callback - the callback of requestInStream. 2047 * @throws { BusinessError } 401 - Parameter error. 2048 * @throws { BusinessError } 201 - Permission denied. 2049 * @throws { BusinessError } 2300001 - Unsupported protocol. 2050 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 2051 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 2052 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 2053 * @throws { BusinessError } 2300007 - Failed to connect to the server. 2054 * @throws { BusinessError } 2300008 - Invalid server response. 2055 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 2056 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 2057 * @throws { BusinessError } 2300018 - Transferred a partial file. 2058 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 2059 * @throws { BusinessError } 2300025 - Upload failed. 2060 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 2061 * @throws { BusinessError } 2300027 - Out of memory. 2062 * @throws { BusinessError } 2300028 - Operation timeout. 2063 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 2064 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 2065 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 2066 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 2067 * @throws { BusinessError } 2300058 - Local SSL certificate error. 2068 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 2069 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 2070 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 2071 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 2072 * @throws { BusinessError } 2300070 - Remote disk full. 2073 * @throws { BusinessError } 2300073 - Remote file already exists. 2074 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 2075 * @throws { BusinessError } 2300078 - Remote file not found. 2076 * @throws { BusinessError } 2300094 - Authentication error. 2077 * @throws { BusinessError } 2300997 - Cleartext traffic not permitted. 2078 * @throws { BusinessError } 2300998 - It is not allowed to access this domain. 2079 * @throws { BusinessError } 2300999 - Internal error. 2080 * @syscap SystemCapability.Communication.NetStack 2081 * @crossplatform 2082 * @atomicservice 2083 * @since 18 2084 */ 2085 requestInStream(url: string, options: HttpRequestOptions, callback: AsyncCallback<number>): void; 2086 2087 /** 2088 * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. 2089 * @permission ohos.permission.INTERNET 2090 * @param { string } url - URL for initiating an HTTP request. 2091 * @param { HttpRequestOptions } [options] - Optional parameters {@link HttpRequestOptions}. 2092 * @returns { Promise<number> } the promise returned by the function. 2093 * @throws { BusinessError } 401 - Parameter error. 2094 * @throws { BusinessError } 201 - Permission denied. 2095 * @throws { BusinessError } 2300001 - Unsupported protocol. 2096 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 2097 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 2098 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 2099 * @throws { BusinessError } 2300007 - Failed to connect to the server. 2100 * @throws { BusinessError } 2300008 - Invalid server response. 2101 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 2102 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 2103 * @throws { BusinessError } 2300018 - Transferred a partial file. 2104 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 2105 * @throws { BusinessError } 2300025 - Upload failed. 2106 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 2107 * @throws { BusinessError } 2300027 - Out of memory. 2108 * @throws { BusinessError } 2300028 - Operation timeout. 2109 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 2110 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 2111 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 2112 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 2113 * @throws { BusinessError } 2300058 - Local SSL certificate error. 2114 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 2115 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 2116 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 2117 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 2118 * @throws { BusinessError } 2300070 - Remote disk full. 2119 * @throws { BusinessError } 2300073 - Remote file already exists. 2120 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 2121 * @throws { BusinessError } 2300078 - Remote file not found. 2122 * @throws { BusinessError } 2300094 - Authentication error. 2123 * @throws { BusinessError } 2300999 - Internal error. 2124 * @syscap SystemCapability.Communication.NetStack 2125 * @since 10 2126 */ 2127 /** 2128 * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. 2129 * @permission ohos.permission.INTERNET 2130 * @param { string } url - URL for initiating an HTTP request. 2131 * @param { HttpRequestOptions } [options] - Optional parameters {@link HttpRequestOptions}. 2132 * @returns { Promise<number> } the promise returned by the function. 2133 * @throws { BusinessError } 401 - Parameter error. 2134 * @throws { BusinessError } 201 - Permission denied. 2135 * @throws { BusinessError } 2300001 - Unsupported protocol. 2136 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 2137 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 2138 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 2139 * @throws { BusinessError } 2300007 - Failed to connect to the server. 2140 * @throws { BusinessError } 2300008 - Invalid server response. 2141 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 2142 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 2143 * @throws { BusinessError } 2300018 - Transferred a partial file. 2144 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 2145 * @throws { BusinessError } 2300025 - Upload failed. 2146 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 2147 * @throws { BusinessError } 2300027 - Out of memory. 2148 * @throws { BusinessError } 2300028 - Operation timeout. 2149 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 2150 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 2151 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 2152 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 2153 * @throws { BusinessError } 2300058 - Local SSL certificate error. 2154 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 2155 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 2156 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 2157 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 2158 * @throws { BusinessError } 2300070 - Remote disk full. 2159 * @throws { BusinessError } 2300073 - Remote file already exists. 2160 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 2161 * @throws { BusinessError } 2300078 - Remote file not found. 2162 * @throws { BusinessError } 2300094 - Authentication error. 2163 * @throws { BusinessError } 2300998 - It is not allowed to access this domain. 2164 * @throws { BusinessError } 2300999 - Internal error. 2165 * @syscap SystemCapability.Communication.NetStack 2166 * @since 12 2167 */ 2168 /** 2169 * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. 2170 * @permission ohos.permission.INTERNET 2171 * @param { string } url - URL for initiating an HTTP request. 2172 * @param { HttpRequestOptions } [options] - Optional parameters {@link HttpRequestOptions}. 2173 * @returns { Promise<number> } the promise returned by the function. 2174 * @throws { BusinessError } 401 - Parameter error. 2175 * @throws { BusinessError } 201 - Permission denied. 2176 * @throws { BusinessError } 2300001 - Unsupported protocol. 2177 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 2178 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 2179 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 2180 * @throws { BusinessError } 2300007 - Failed to connect to the server. 2181 * @throws { BusinessError } 2300008 - Invalid server response. 2182 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 2183 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 2184 * @throws { BusinessError } 2300018 - Transferred a partial file. 2185 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 2186 * @throws { BusinessError } 2300025 - Upload failed. 2187 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 2188 * @throws { BusinessError } 2300027 - Out of memory. 2189 * @throws { BusinessError } 2300028 - Operation timeout. 2190 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 2191 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 2192 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 2193 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 2194 * @throws { BusinessError } 2300058 - Local SSL certificate error. 2195 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 2196 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 2197 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 2198 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 2199 * @throws { BusinessError } 2300070 - Remote disk full. 2200 * @throws { BusinessError } 2300073 - Remote file already exists. 2201 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 2202 * @throws { BusinessError } 2300078 - Remote file not found. 2203 * @throws { BusinessError } 2300094 - Authentication error. 2204 * @throws { BusinessError } 2300998 - It is not allowed to access this domain. 2205 * @throws { BusinessError } 2300999 - Internal error. 2206 * @syscap SystemCapability.Communication.NetStack 2207 * @atomicservice 2208 * @since 15 2209 */ 2210 /** 2211 * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. 2212 * @permission ohos.permission.INTERNET 2213 * @param { string } url - URL for initiating an HTTP request. 2214 * @param { HttpRequestOptions } [options] - Optional parameters {@link HttpRequestOptions}. 2215 * @returns { Promise<number> } the promise returned by the function. 2216 * @throws { BusinessError } 401 - Parameter error. 2217 * @throws { BusinessError } 201 - Permission denied. 2218 * @throws { BusinessError } 2300001 - Unsupported protocol. 2219 * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. 2220 * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. 2221 * @throws { BusinessError } 2300006 - Failed to resolve the host name. 2222 * @throws { BusinessError } 2300007 - Failed to connect to the server. 2223 * @throws { BusinessError } 2300008 - Invalid server response. 2224 * @throws { BusinessError } 2300009 - Access to the remote resource denied. 2225 * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. 2226 * @throws { BusinessError } 2300018 - Transferred a partial file. 2227 * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. 2228 * @throws { BusinessError } 2300025 - Upload failed. 2229 * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. 2230 * @throws { BusinessError } 2300027 - Out of memory. 2231 * @throws { BusinessError } 2300028 - Operation timeout. 2232 * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. 2233 * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). 2234 * @throws { BusinessError } 2300055 - Failed to send data to the peer. 2235 * @throws { BusinessError } 2300056 - Failed to receive data from the peer. 2236 * @throws { BusinessError } 2300058 - Local SSL certificate error. 2237 * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. 2238 * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. 2239 * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. 2240 * @throws { BusinessError } 2300063 - Maximum file size exceeded. 2241 * @throws { BusinessError } 2300070 - Remote disk full. 2242 * @throws { BusinessError } 2300073 - Remote file already exists. 2243 * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. 2244 * @throws { BusinessError } 2300078 - Remote file not found. 2245 * @throws { BusinessError } 2300094 - Authentication error. 2246 * @throws { BusinessError } 2300997 - Cleartext traffic not permitted. 2247 * @throws { BusinessError } 2300998 - It is not allowed to access this domain. 2248 * @throws { BusinessError } 2300999 - Internal error. 2249 * @syscap SystemCapability.Communication.NetStack 2250 * @crossplatform 2251 * @atomicservice 2252 * @since 18 2253 */ 2254 requestInStream(url: string, options?: HttpRequestOptions): Promise<number>; 2255 2256 /** 2257 * Destroys an HTTP request. 2258 * @syscap SystemCapability.Communication.NetStack 2259 * @since 6 2260 */ 2261 /** 2262 * Destroys an HTTP request. 2263 * @syscap SystemCapability.Communication.NetStack 2264 * @crossplatform 2265 * @since 10 2266 */ 2267 /** 2268 * Destroys an HTTP request. 2269 * @syscap SystemCapability.Communication.NetStack 2270 * @crossplatform 2271 * @atomicservice 2272 * @since 11 2273 */ 2274 destroy(): void; 2275 2276 /** 2277 * Registers an observer for HTTP Response Header events. 2278 * @param { "headerReceive" } type - Indicates Event name. 2279 * @param { AsyncCallback<Object> } callback - the callback used to return the result. 2280 * @syscap SystemCapability.Communication.NetStack 2281 * @since 6 2282 * @deprecated since 8 2283 * @useinstead on_headersReceive 2284 */ 2285 on(type: "headerReceive", callback: AsyncCallback<Object>): void; 2286 2287 /** 2288 * Unregisters the observer for HTTP Response Header events. 2289 * @param { "headerReceive" } type - Indicates Event name. 2290 * @param { AsyncCallback<Object> } [callback] - the callback used to return the result. 2291 * @syscap SystemCapability.Communication.NetStack 2292 * @since 6 2293 * @deprecated since 8 2294 * @useinstead off_headersReceive 2295 */ 2296 off(type: "headerReceive", callback?: AsyncCallback<Object>): void; 2297 2298 /** 2299 * Registers an observer for HTTP Response Header events. 2300 * @param { "headersReceive" } type - Indicates Event name. 2301 * @param { Callback<Object> } callback - the callback used to return the result. 2302 * @syscap SystemCapability.Communication.NetStack 2303 * @since 8 2304 */ 2305 /** 2306 * Registers an observer for HTTP Response Header events. 2307 * @param { "headersReceive" } type - Indicates Event name. 2308 * @param { Callback<Object> } callback - the callback used to return the result. 2309 * @syscap SystemCapability.Communication.NetStack 2310 * @crossplatform 2311 * @since 10 2312 */ 2313 /** 2314 * Registers an observer for HTTP Response Header events. 2315 * @param { "headersReceive" } type - Indicates Event name. 2316 * @param { Callback<Object> } callback - the callback used to return the result. 2317 * @syscap SystemCapability.Communication.NetStack 2318 * @crossplatform 2319 * @atomicservice 2320 * @since 11 2321 */ 2322 on(type: "headersReceive", callback: Callback<Object>): void; 2323 2324 /** 2325 * Unregisters the observer for HTTP Response Header events. 2326 * @param { "headersReceive" } type - Indicates Event name. 2327 * @param { Callback<Object> } callback - the callback used to return the result. 2328 * @syscap SystemCapability.Communication.NetStack 2329 * @since 8 2330 */ 2331 /** 2332 * Unregisters the observer for HTTP Response Header events. 2333 * @param { "headersReceive" } type - Indicates Event name. 2334 * @param { Callback<Object> } callback - the callback used to return the result. 2335 * @syscap SystemCapability.Communication.NetStack 2336 * @crossplatform 2337 * @since 10 2338 */ 2339 /** 2340 * Unregisters the observer for HTTP Response Header events. 2341 * @param { "headersReceive" } type - Indicates Event name. 2342 * @param { Callback<Object> } [callback] - the callback used to return the result. 2343 * @syscap SystemCapability.Communication.NetStack 2344 * @crossplatform 2345 * @atomicservice 2346 * @since 11 2347 */ 2348 off(type: "headersReceive", callback?: Callback<Object>): void; 2349 2350 /** 2351 * Registers a one-time observer for HTTP Response Header events. 2352 * @param { "headersReceive" } type - Indicates Event name. 2353 * @param { Callback<Object> } callback - the callback used to return the result. 2354 * @syscap SystemCapability.Communication.NetStack 2355 * @since 8 2356 */ 2357 /** 2358 * Registers a one-time observer for HTTP Response Header events. 2359 * @param { "headersReceive" } type - Indicates Event name. 2360 * @param { Callback<Object> } callback - the callback used to return the result. 2361 * @syscap SystemCapability.Communication.NetStack 2362 * @crossplatform 2363 * @since 10 2364 */ 2365 /** 2366 * Registers a one-time observer for HTTP Response Header events. 2367 * @param { "headersReceive" } type - Indicates Event name. 2368 * @param { Callback<Object> } callback - the callback used to return the result. 2369 * @syscap SystemCapability.Communication.NetStack 2370 * @crossplatform 2371 * @atomicservice 2372 * @since 15 2373 */ 2374 once(type: "headersReceive", callback: Callback<Object>): void; 2375 2376 /** 2377 * Registers an observer for receiving HTTP Response data events continuously. 2378 * @param { "dataReceive" } type - Indicates Event name. 2379 * @param { Callback<ArrayBuffer> } callback - the callback used to return the result. 2380 * @syscap SystemCapability.Communication.NetStack 2381 * @since 10 2382 */ 2383 /** 2384 * Registers an observer for receiving HTTP Response data events continuously. 2385 * @param { "dataReceive" } type - Indicates Event name. 2386 * @param { Callback<ArrayBuffer> } callback - the callback used to return the result. 2387 * @syscap SystemCapability.Communication.NetStack 2388 * @atomicservice 2389 * @since 15 2390 */ 2391 /** 2392 * Registers an observer for receiving HTTP Response data events continuously. 2393 * @param { "dataReceive" } type - Indicates Event name. 2394 * @param { Callback<ArrayBuffer> } callback - the callback used to return the result. 2395 * @syscap SystemCapability.Communication.NetStack 2396 * @crossplatform 2397 * @atomicservice 2398 * @since 18 2399 */ 2400 on(type: "dataReceive", callback: Callback<ArrayBuffer>): void; 2401 2402 /** 2403 * Unregisters an observer for receiving HTTP Response data events continuously. 2404 * @param { "dataReceive" } type - Indicates Event name. 2405 * @param { Callback<ArrayBuffer> } [callback] - the callback used to return the result. 2406 * @syscap SystemCapability.Communication.NetStack 2407 * @since 10 2408 */ 2409 /** 2410 * Unregisters an observer for receiving HTTP Response data events continuously. 2411 * @param { "dataReceive" } type - Indicates Event name. 2412 * @param { Callback<ArrayBuffer> } [callback] - the callback used to return the result. 2413 * @syscap SystemCapability.Communication.NetStack 2414 * @atomicservice 2415 * @since 15 2416 */ 2417 /** 2418 * Unregisters an observer for receiving HTTP Response data events continuously. 2419 * @param { "dataReceive" } type - Indicates Event name. 2420 * @param { Callback<ArrayBuffer> } [callback] - the callback used to return the result. 2421 * @syscap SystemCapability.Communication.NetStack 2422 * @crossplatform 2423 * @atomicservice 2424 * @since 18 2425 */ 2426 off(type: "dataReceive", callback?: Callback<ArrayBuffer>): void; 2427 2428 /** 2429 * Registers an observer for receiving HTTP Response data ends events. 2430 * @param { "dataEnd" } type - Indicates Event name. 2431 * @param { Callback<void> } callback - the callback used to return the result. 2432 * @syscap SystemCapability.Communication.NetStack 2433 * @since 10 2434 */ 2435 /** 2436 * Registers an observer for receiving HTTP Response data ends events. 2437 * @param { "dataEnd" } type - Indicates Event name. 2438 * @param { Callback<void> } callback - the callback used to return the result. 2439 * @syscap SystemCapability.Communication.NetStack 2440 * @atomicservice 2441 * @since 15 2442 */ 2443 /** 2444 * Registers an observer for receiving HTTP Response data ends events. 2445 * @param { "dataEnd" } type - Indicates Event name. 2446 * @param { Callback<void> } callback - the callback used to return the result. 2447 * @syscap SystemCapability.Communication.NetStack 2448 * @crossplatform 2449 * @atomicservice 2450 * @since 18 2451 */ 2452 on(type: "dataEnd", callback: Callback<void>): void; 2453 2454 /** 2455 * Unregisters an observer for receiving HTTP Response data ends events. 2456 * @param { "dataEnd" } type - Indicates Event name. 2457 * @param { Callback<void> } [callback] - the callback used to return the result. 2458 * @syscap SystemCapability.Communication.NetStack 2459 * @since 10 2460 */ 2461 /** 2462 * Unregisters an observer for receiving HTTP Response data ends events. 2463 * @param { "dataEnd" } type - Indicates Event name. 2464 * @param { Callback<void> } [callback] - the callback used to return the result. 2465 * @syscap SystemCapability.Communication.NetStack 2466 * @atomicservice 2467 * @since 15 2468 */ 2469 /** 2470 * Unregisters an observer for receiving HTTP Response data ends events. 2471 * @param { "dataEnd" } type - Indicates Event name. 2472 * @param { Callback<void> } [callback] - the callback used to return the result. 2473 * @syscap SystemCapability.Communication.NetStack 2474 * @crossplatform 2475 * @atomicservice 2476 * @since 18 2477 */ 2478 off(type: "dataEnd", callback?: Callback<void>): void; 2479 2480 /** 2481 * Registers an observer for progress of receiving HTTP Response data events. 2482 * @param { 'dataReceiveProgress' } type - Indicates Event name. 2483 * @param { Callback<{ receiveSize: number, totalSize: number }> } callback - the callback used to return the result. 2484 * @syscap SystemCapability.Communication.NetStack 2485 * @since 10 2486 */ 2487 /** 2488 * Registers an observer for progress of receiving HTTP Response data events. 2489 * @param { 'dataReceiveProgress' } type - Indicates Event name. 2490 * @param { Callback<DataReceiveProgressInfo> } callback - the callback used to return the result. 2491 * @syscap SystemCapability.Communication.NetStack 2492 * @since 11 2493 */ 2494 /** 2495 * Registers an observer for progress of receiving HTTP Response data events. 2496 * @param { 'dataReceiveProgress' } type - Indicates Event name. 2497 * @param { Callback<DataReceiveProgressInfo> } callback - the callback used to return the result. 2498 * @syscap SystemCapability.Communication.NetStack 2499 * @crossplatform 2500 * @since 12 2501 */ 2502 /** 2503 * Registers an observer for progress of receiving HTTP Response data events. 2504 * @param { 'dataReceiveProgress' } type - Indicates Event name. 2505 * @param { Callback<DataReceiveProgressInfo> } callback - the callback used to return the result. 2506 * @syscap SystemCapability.Communication.NetStack 2507 * @crossplatform 2508 * @atomicservice 2509 * @since 15 2510 */ 2511 on(type: 'dataReceiveProgress', callback: Callback<DataReceiveProgressInfo>): void; 2512 2513 /** 2514 * Unregisters an observer for progress of receiving HTTP Response data events. 2515 * @param { 'dataReceiveProgress' } type - Indicates Event name. 2516 * @param { Callback<{ receiveSize: number, totalSize: number }> } [callback] - the callback used to return the result. 2517 * @syscap SystemCapability.Communication.NetStack 2518 * @since 10 2519 */ 2520 /** 2521 * Unregisters an observer for progress of receiving HTTP Response data events. 2522 * @param { 'dataReceiveProgress' } type - Indicates Event name. 2523 * @param { Callback<DataReceiveProgressInfo> } callback - the callback used to return the result. 2524 * @syscap SystemCapability.Communication.NetStack 2525 * @since 11 2526 */ 2527 /** 2528 * Unregisters an observer for progress of receiving HTTP Response data events. 2529 * @param { 'dataReceiveProgress' } type - Indicates Event name. 2530 * @param { Callback<DataReceiveProgressInfo> } callback - the callback used to return the result. 2531 * @syscap SystemCapability.Communication.NetStack 2532 * @crossplatform 2533 * @since 12 2534 */ 2535 /** 2536 * Unregisters an observer for progress of receiving HTTP Response data events. 2537 * @param { 'dataReceiveProgress' } type - Indicates Event name. 2538 * @param { Callback<DataReceiveProgressInfo> } callback - the callback used to return the result. 2539 * @syscap SystemCapability.Communication.NetStack 2540 * @crossplatform 2541 * @atomicservice 2542 * @since 15 2543 */ 2544 off(type: 'dataReceiveProgress', callback?: Callback<DataReceiveProgressInfo>): void; 2545 2546 /** 2547 * Registers an observer for progress of sendSize HTTP Response data events. 2548 * @param { 'dataSendProgress' } type - Indicates Event name. 2549 * @param { Callback<DataSendProgressInfo> } callback - the callback of on. 2550 * @syscap SystemCapability.Communication.NetStack 2551 * @since 11 2552 */ 2553 /** 2554 * Registers an observer for progress of sendSize HTTP Response data events. 2555 * @param { 'dataSendProgress' } type - Indicates Event name. 2556 * @param { Callback<DataSendProgressInfo> } callback - the callback of on. 2557 * @syscap SystemCapability.Communication.NetStack 2558 * @crossplatform 2559 * @since 12 2560 */ 2561 /** 2562 * Registers an observer for progress of sendSize HTTP Response data events. 2563 * @param { 'dataSendProgress' } type - Indicates Event name. 2564 * @param { Callback<DataSendProgressInfo> } callback - the callback of on. 2565 * @syscap SystemCapability.Communication.NetStack 2566 * @crossplatform 2567 * @atomicservice 2568 * @since 15 2569 */ 2570 on(type: 'dataSendProgress', callback: Callback<DataSendProgressInfo>): void 2571 2572 /** 2573 * Unregisters an observer for progress of sendSize HTTP Response data events. 2574 * @param { 'dataSendProgress' } type - Indicates Event name. 2575 * @param { Callback<DataSendProgressInfo> } [callback] - the callback of off. 2576 * @syscap SystemCapability.Communication.NetStack 2577 * @since 11 2578 */ 2579 /** 2580 * Unregisters an observer for progress of sendSize HTTP Response data events. 2581 * @param { 'dataSendProgress' } type - Indicates Event name. 2582 * @param { Callback<DataSendProgressInfo> } [callback] - the callback of off. 2583 * @syscap SystemCapability.Communication.NetStack 2584 * @crossplatform 2585 * @since 12 2586 */ 2587 /** 2588 * Unregisters an observer for progress of sendSize HTTP Response data events. 2589 * @param { 'dataSendProgress' } type - Indicates Event name. 2590 * @param { Callback<DataSendProgressInfo> } [callback] - the callback of off. 2591 * @syscap SystemCapability.Communication.NetStack 2592 * @crossplatform 2593 * @atomicservice 2594 * @since 15 2595 */ 2596 off(type: 'dataSendProgress', callback?: Callback<DataSendProgressInfo>): void 2597 } 2598 2599 /** 2600 * Defines an HTTP request method. 2601 * @enum {string} 2602 * @syscap SystemCapability.Communication.NetStack 2603 * @since 6 2604 */ 2605 /** 2606 * Defines an HTTP request method. 2607 * @enum {string} 2608 * @syscap SystemCapability.Communication.NetStack 2609 * @crossplatform 2610 * @since 10 2611 */ 2612 /** 2613 * Defines an HTTP request method. 2614 * @enum {string} 2615 * @syscap SystemCapability.Communication.NetStack 2616 * @crossplatform 2617 * @atomicservice 2618 * @since 11 2619 */ 2620 export enum RequestMethod { 2621 /** 2622 * OPTIONS method. 2623 * @syscap SystemCapability.Communication.NetStack 2624 * @since 6 2625 */ 2626 /** 2627 * OPTIONS method. 2628 * @syscap SystemCapability.Communication.NetStack 2629 * @crossplatform 2630 * @since 10 2631 */ 2632 /** 2633 * OPTIONS method. 2634 * @syscap SystemCapability.Communication.NetStack 2635 * @crossplatform 2636 * @atomicservice 2637 * @since 11 2638 */ 2639 OPTIONS = "OPTIONS", 2640 2641 /** 2642 * GET method. 2643 * @syscap SystemCapability.Communication.NetStack 2644 * @since 6 2645 */ 2646 /** 2647 * GET method. 2648 * @syscap SystemCapability.Communication.NetStack 2649 * @crossplatform 2650 * @since 10 2651 */ 2652 /** 2653 * GET method. 2654 * @syscap SystemCapability.Communication.NetStack 2655 * @crossplatform 2656 * @atomicservice 2657 * @since 11 2658 */ 2659 GET = "GET", 2660 2661 /** 2662 * HEAD method. 2663 * @syscap SystemCapability.Communication.NetStack 2664 * @since 6 2665 */ 2666 /** 2667 * HEAD method. 2668 * @syscap SystemCapability.Communication.NetStack 2669 * @crossplatform 2670 * @since 10 2671 */ 2672 /** 2673 * HEAD method. 2674 * @syscap SystemCapability.Communication.NetStack 2675 * @crossplatform 2676 * @atomicservice 2677 * @since 11 2678 */ 2679 HEAD = "HEAD", 2680 2681 /** 2682 * POST method. 2683 * @syscap SystemCapability.Communication.NetStack 2684 * @since 6 2685 */ 2686 /** 2687 * POST method. 2688 * @syscap SystemCapability.Communication.NetStack 2689 * @crossplatform 2690 * @since 10 2691 */ 2692 /** 2693 * POST method. 2694 * @syscap SystemCapability.Communication.NetStack 2695 * @crossplatform 2696 * @atomicservice 2697 * @since 11 2698 */ 2699 POST = "POST", 2700 2701 /** 2702 * PUT method. 2703 * @syscap SystemCapability.Communication.NetStack 2704 * @since 6 2705 */ 2706 /** 2707 * PUT method. 2708 * @syscap SystemCapability.Communication.NetStack 2709 * @crossplatform 2710 * @since 10 2711 */ 2712 /** 2713 * PUT method. 2714 * @syscap SystemCapability.Communication.NetStack 2715 * @crossplatform 2716 * @atomicservice 2717 * @since 11 2718 */ 2719 PUT = "PUT", 2720 2721 /** 2722 * DELETE method. 2723 * @syscap SystemCapability.Communication.NetStack 2724 * @since 6 2725 */ 2726 /** 2727 * DELETE method. 2728 * @syscap SystemCapability.Communication.NetStack 2729 * @crossplatform 2730 * @since 10 2731 */ 2732 /** 2733 * DELETE method. 2734 * @syscap SystemCapability.Communication.NetStack 2735 * @crossplatform 2736 * @atomicservice 2737 * @since 11 2738 */ 2739 DELETE = "DELETE", 2740 2741 /** 2742 * TRACE method. 2743 * @syscap SystemCapability.Communication.NetStack 2744 * @since 6 2745 */ 2746 /** 2747 * TRACE method. 2748 * @syscap SystemCapability.Communication.NetStack 2749 * @crossplatform 2750 * @since 10 2751 */ 2752 /** 2753 * TRACE method. 2754 * @syscap SystemCapability.Communication.NetStack 2755 * @crossplatform 2756 * @atomicservice 2757 * @since 11 2758 */ 2759 TRACE = "TRACE", 2760 2761 /** 2762 * CONNECT method. 2763 * @syscap SystemCapability.Communication.NetStack 2764 * @since 6 2765 */ 2766 /** 2767 * CONNECT method. 2768 * @syscap SystemCapability.Communication.NetStack 2769 * @crossplatform 2770 * @since 10 2771 */ 2772 /** 2773 * CONNECT method. 2774 * @syscap SystemCapability.Communication.NetStack 2775 * @crossplatform 2776 * @atomicservice 2777 * @since 11 2778 */ 2779 CONNECT = "CONNECT" 2780 } 2781 2782 /** 2783 * Enumerates the response codes for an HTTP request. 2784 * @enum {number} 2785 * @syscap SystemCapability.Communication.NetStack 2786 * @since 6 2787 */ 2788 /** 2789 * Enumerates the response codes for an HTTP request. 2790 * @enum {number} 2791 * @syscap SystemCapability.Communication.NetStack 2792 * @crossplatform 2793 * @since 10 2794 */ 2795 /** 2796 * Enumerates the response codes for an HTTP request. 2797 * @enum {number} 2798 * @syscap SystemCapability.Communication.NetStack 2799 * @crossplatform 2800 * @atomicservice 2801 * @since 11 2802 */ 2803 export enum ResponseCode { 2804 /** 2805 * The request was successful. Typically used for GET and POST requests. 2806 * @syscap SystemCapability.Communication.NetStack 2807 * @since 6 2808 */ 2809 /** 2810 * The request was successful. Typically used for GET and POST requests. 2811 * @syscap SystemCapability.Communication.NetStack 2812 * @crossplatform 2813 * @since 10 2814 */ 2815 /** 2816 * The request was successful. Typically used for GET and POST requests. 2817 * @syscap SystemCapability.Communication.NetStack 2818 * @crossplatform 2819 * @atomicservice 2820 * @since 11 2821 */ 2822 OK = 200, 2823 2824 /** 2825 * Successfully requested and created a new resource. 2826 * @syscap SystemCapability.Communication.NetStack 2827 * @since 6 2828 */ 2829 /** 2830 * Successfully requested and created a new resource. 2831 * @syscap SystemCapability.Communication.NetStack 2832 * @crossplatform 2833 * @since 10 2834 */ 2835 /** 2836 * Successfully requested and created a new resource. 2837 * @syscap SystemCapability.Communication.NetStack 2838 * @crossplatform 2839 * @atomicservice 2840 * @since 11 2841 */ 2842 CREATED, 2843 2844 /** 2845 * The request has been accepted but has not been processed completely. 2846 * @syscap SystemCapability.Communication.NetStack 2847 * @since 6 2848 */ 2849 /** 2850 * The request has been accepted but has not been processed completely. 2851 * @syscap SystemCapability.Communication.NetStack 2852 * @crossplatform 2853 * @since 10 2854 */ 2855 /** 2856 * The request has been accepted but has not been processed completely. 2857 * @syscap SystemCapability.Communication.NetStack 2858 * @crossplatform 2859 * @atomicservice 2860 * @since 11 2861 */ 2862 ACCEPTED, 2863 2864 /** 2865 * Unauthorized information. The request was successful. 2866 * @syscap SystemCapability.Communication.NetStack 2867 * @since 6 2868 */ 2869 /** 2870 * Unauthorized information. The request was successful. 2871 * @syscap SystemCapability.Communication.NetStack 2872 * @crossplatform 2873 * @since 10 2874 */ 2875 /** 2876 * Unauthorized information. The request was successful. 2877 * @syscap SystemCapability.Communication.NetStack 2878 * @crossplatform 2879 * @atomicservice 2880 * @since 11 2881 */ 2882 NOT_AUTHORITATIVE, 2883 2884 /** 2885 * No content. The server successfully processed, but did not return content. 2886 * @syscap SystemCapability.Communication.NetStack 2887 * @since 6 2888 */ 2889 /** 2890 * No content. The server successfully processed, but did not return content. 2891 * @syscap SystemCapability.Communication.NetStack 2892 * @crossplatform 2893 * @since 10 2894 */ 2895 /** 2896 * No content. The server successfully processed, but did not return content. 2897 * @syscap SystemCapability.Communication.NetStack 2898 * @crossplatform 2899 * @atomicservice 2900 * @since 11 2901 */ 2902 NO_CONTENT, 2903 2904 /** 2905 * Reset the content. 2906 * @syscap SystemCapability.Communication.NetStack 2907 * @since 6 2908 */ 2909 /** 2910 * Reset the content. 2911 * @syscap SystemCapability.Communication.NetStack 2912 * @crossplatform 2913 * @since 10 2914 */ 2915 /** 2916 * Reset the content. 2917 * @syscap SystemCapability.Communication.NetStack 2918 * @crossplatform 2919 * @atomicservice 2920 * @since 11 2921 */ 2922 RESET, 2923 2924 /** 2925 * Partial content. The server successfully processed some GET requests. 2926 * @syscap SystemCapability.Communication.NetStack 2927 * @since 6 2928 */ 2929 /** 2930 * Partial content. The server successfully processed some GET requests. 2931 * @syscap SystemCapability.Communication.NetStack 2932 * @crossplatform 2933 * @since 10 2934 */ 2935 /** 2936 * Partial content. The server successfully processed some GET requests. 2937 * @syscap SystemCapability.Communication.NetStack 2938 * @crossplatform 2939 * @atomicservice 2940 * @since 11 2941 */ 2942 PARTIAL, 2943 2944 /** 2945 * Multiple options. 2946 * @syscap SystemCapability.Communication.NetStack 2947 * @since 6 2948 */ 2949 /** 2950 * Multiple options. 2951 * @syscap SystemCapability.Communication.NetStack 2952 * @crossplatform 2953 * @since 10 2954 */ 2955 /** 2956 * Multiple options. 2957 * @syscap SystemCapability.Communication.NetStack 2958 * @crossplatform 2959 * @atomicservice 2960 * @since 11 2961 */ 2962 MULT_CHOICE = 300, 2963 2964 /** 2965 * <p>Permanently move. The requested resource has been permanently moved to a new URI, 2966 * and the returned information will include the new URI. The browser will automatically redirect to the new URI.</p> 2967 * @syscap SystemCapability.Communication.NetStack 2968 * @since 6 2969 */ 2970 /** 2971 * <p>Permanently move. The requested resource has been permanently moved to a new URI, 2972 * and the returned information will include the new URI. The browser will automatically redirect to the new URI.</p> 2973 * @syscap SystemCapability.Communication.NetStack 2974 * @crossplatform 2975 * @since 10 2976 */ 2977 /** 2978 * <p>Permanently move. The requested resource has been permanently moved to a new URI, 2979 * and the returned information will include the new URI. The browser will automatically redirect to the new URI.</p> 2980 * @syscap SystemCapability.Communication.NetStack 2981 * @crossplatform 2982 * @atomicservice 2983 * @since 11 2984 */ 2985 MOVED_PERM, 2986 2987 /** 2988 * Temporary movement. 2989 * @syscap SystemCapability.Communication.NetStack 2990 * @since 6 2991 */ 2992 /** 2993 * Temporary movement. 2994 * @syscap SystemCapability.Communication.NetStack 2995 * @crossplatform 2996 * @since 10 2997 */ 2998 /** 2999 * Temporary movement. 3000 * @syscap SystemCapability.Communication.NetStack 3001 * @crossplatform 3002 * @atomicservice 3003 * @since 11 3004 */ 3005 MOVED_TEMP, 3006 3007 /** 3008 * View other addresses. 3009 * @syscap SystemCapability.Communication.NetStack 3010 * @since 6 3011 */ 3012 /** 3013 * View other addresses. 3014 * @syscap SystemCapability.Communication.NetStack 3015 * @crossplatform 3016 * @since 10 3017 */ 3018 /** 3019 * View other addresses. 3020 * @syscap SystemCapability.Communication.NetStack 3021 * @crossplatform 3022 * @atomicservice 3023 * @since 11 3024 */ 3025 SEE_OTHER, 3026 3027 /** 3028 * Not modified. 3029 * @syscap SystemCapability.Communication.NetStack 3030 * @since 6 3031 */ 3032 /** 3033 * Not modified. 3034 * @syscap SystemCapability.Communication.NetStack 3035 * @crossplatform 3036 * @since 10 3037 */ 3038 /** 3039 * Not modified. 3040 * @syscap SystemCapability.Communication.NetStack 3041 * @crossplatform 3042 * @atomicservice 3043 * @since 11 3044 */ 3045 NOT_MODIFIED, 3046 3047 /** 3048 * Using proxies. 3049 * @syscap SystemCapability.Communication.NetStack 3050 * @since 6 3051 */ 3052 /** 3053 * Using proxies. 3054 * @syscap SystemCapability.Communication.NetStack 3055 * @crossplatform 3056 * @since 10 3057 */ 3058 /** 3059 * Using proxies. 3060 * @syscap SystemCapability.Communication.NetStack 3061 * @crossplatform 3062 * @atomicservice 3063 * @since 11 3064 */ 3065 USE_PROXY, 3066 3067 /** 3068 * The server cannot understand the syntax error error requested by the client. 3069 * @syscap SystemCapability.Communication.NetStack 3070 * @since 6 3071 */ 3072 /** 3073 * The server cannot understand the syntax error error requested by the client. 3074 * @syscap SystemCapability.Communication.NetStack 3075 * @crossplatform 3076 * @since 10 3077 */ 3078 /** 3079 * The server cannot understand the syntax error error requested by the client. 3080 * @syscap SystemCapability.Communication.NetStack 3081 * @crossplatform 3082 * @atomicservice 3083 * @since 11 3084 */ 3085 BAD_REQUEST = 400, 3086 3087 /** 3088 * Request for user authentication. 3089 * @syscap SystemCapability.Communication.NetStack 3090 * @since 6 3091 */ 3092 /** 3093 * Request for user authentication. 3094 * @syscap SystemCapability.Communication.NetStack 3095 * @crossplatform 3096 * @since 10 3097 */ 3098 /** 3099 * Request for user authentication. 3100 * @syscap SystemCapability.Communication.NetStack 3101 * @crossplatform 3102 * @atomicservice 3103 * @since 11 3104 */ 3105 UNAUTHORIZED, 3106 3107 /** 3108 * Reserved for future use. 3109 * @syscap SystemCapability.Communication.NetStack 3110 * @since 6 3111 */ 3112 /** 3113 * Reserved for future use. 3114 * @syscap SystemCapability.Communication.NetStack 3115 * @crossplatform 3116 * @since 10 3117 */ 3118 /** 3119 * Reserved for future use. 3120 * @syscap SystemCapability.Communication.NetStack 3121 * @crossplatform 3122 * @atomicservice 3123 * @since 11 3124 */ 3125 PAYMENT_REQUIRED, 3126 3127 /** 3128 * The server understands the request from the requesting client, but refuses to execute it. 3129 * @syscap SystemCapability.Communication.NetStack 3130 * @since 6 3131 */ 3132 /** 3133 * The server understands the request from the requesting client, but refuses to execute it. 3134 * @syscap SystemCapability.Communication.NetStack 3135 * @crossplatform 3136 * @since 10 3137 */ 3138 /** 3139 * The server understands the request from the requesting client, but refuses to execute it. 3140 * @syscap SystemCapability.Communication.NetStack 3141 * @crossplatform 3142 * @atomicservice 3143 * @since 11 3144 */ 3145 FORBIDDEN, 3146 3147 /** 3148 * The server was unable to find resources (web pages) based on the client's request. 3149 * @syscap SystemCapability.Communication.NetStack 3150 * @since 6 3151 */ 3152 /** 3153 * The server was unable to find resources (web pages) based on the client's request. 3154 * @syscap SystemCapability.Communication.NetStack 3155 * @crossplatform 3156 * @since 10 3157 */ 3158 /** 3159 * The server was unable to find resources (web pages) based on the client's request. 3160 * @syscap SystemCapability.Communication.NetStack 3161 * @crossplatform 3162 * @atomicservice 3163 * @since 11 3164 */ 3165 NOT_FOUND, 3166 3167 /** 3168 * The method in the client request is prohibited. 3169 * @syscap SystemCapability.Communication.NetStack 3170 * @since 6 3171 */ 3172 /** 3173 * The method in the client request is prohibited. 3174 * @syscap SystemCapability.Communication.NetStack 3175 * @crossplatform 3176 * @since 10 3177 */ 3178 /** 3179 * The method in the client request is prohibited. 3180 * @syscap SystemCapability.Communication.NetStack 3181 * @crossplatform 3182 * @atomicservice 3183 * @since 11 3184 */ 3185 BAD_METHOD, 3186 3187 /** 3188 * The server is unable to complete the request based on the content characteristics requested by the client. 3189 * @syscap SystemCapability.Communication.NetStack 3190 * @since 6 3191 */ 3192 /** 3193 * The server is unable to complete the request based on the content characteristics requested by the client. 3194 * @syscap SystemCapability.Communication.NetStack 3195 * @crossplatform 3196 * @since 10 3197 */ 3198 /** 3199 * The server is unable to complete the request based on the content characteristics requested by the client. 3200 * @syscap SystemCapability.Communication.NetStack 3201 * @crossplatform 3202 * @atomicservice 3203 * @since 11 3204 */ 3205 NOT_ACCEPTABLE, 3206 3207 /** 3208 * Request authentication of the proxy's identity. 3209 * @syscap SystemCapability.Communication.NetStack 3210 * @since 6 3211 */ 3212 /** 3213 * Request authentication of the proxy's identity. 3214 * @syscap SystemCapability.Communication.NetStack 3215 * @crossplatform 3216 * @since 10 3217 */ 3218 /** 3219 * Request authentication of the proxy's identity. 3220 * @syscap SystemCapability.Communication.NetStack 3221 * @crossplatform 3222 * @atomicservice 3223 * @since 11 3224 */ 3225 PROXY_AUTH, 3226 3227 /** 3228 * The request took too long and timed out. 3229 * @syscap SystemCapability.Communication.NetStack 3230 * @since 6 3231 */ 3232 /** 3233 * The request took too long and timed out. 3234 * @syscap SystemCapability.Communication.NetStack 3235 * @crossplatform 3236 * @since 10 3237 */ 3238 /** 3239 * The request took too long and timed out. 3240 * @syscap SystemCapability.Communication.NetStack 3241 * @crossplatform 3242 * @atomicservice 3243 * @since 11 3244 */ 3245 CLIENT_TIMEOUT, 3246 3247 /** 3248 * <p>The server may have returned this code when completing the client's PUT request, 3249 * as there was a conflict when the server was processing the request.</p> 3250 * @syscap SystemCapability.Communication.NetStack 3251 * @since 6 3252 */ 3253 /** 3254 * <p>The server may have returned this code when completing the client's PUT request, 3255 * as there was a conflict when the server was processing the request.</p> 3256 * @syscap SystemCapability.Communication.NetStack 3257 * @crossplatform 3258 * @since 10 3259 */ 3260 /** 3261 * <p>The server may have returned this code when completing the client's PUT request, 3262 * as there was a conflict when the server was processing the request.</p> 3263 * @syscap SystemCapability.Communication.NetStack 3264 * @crossplatform 3265 * @atomicservice 3266 * @since 11 3267 */ 3268 CONFLICT, 3269 3270 /** 3271 * The resource requested by the client no longer exists. 3272 * @syscap SystemCapability.Communication.NetStack 3273 * @since 6 3274 */ 3275 /** 3276 * The resource requested by the client no longer exists. 3277 * @syscap SystemCapability.Communication.NetStack 3278 * @crossplatform 3279 * @since 10 3280 */ 3281 /** 3282 * The resource requested by the client no longer exists. 3283 * @syscap SystemCapability.Communication.NetStack 3284 * @crossplatform 3285 * @atomicservice 3286 * @since 11 3287 */ 3288 GONE, 3289 3290 /** 3291 * The server is unable to process request information sent by the client without Content Length. 3292 * @syscap SystemCapability.Communication.NetStack 3293 * @since 6 3294 */ 3295 /** 3296 * The server is unable to process request information sent by the client without Content Length. 3297 * @syscap SystemCapability.Communication.NetStack 3298 * @crossplatform 3299 * @since 10 3300 */ 3301 /** 3302 * The server is unable to process request information sent by the client without Content Length. 3303 * @syscap SystemCapability.Communication.NetStack 3304 * @crossplatform 3305 * @atomicservice 3306 * @since 11 3307 */ 3308 LENGTH_REQUIRED, 3309 3310 /** 3311 * The prerequisite for requesting information from the client is incorrect. 3312 * @syscap SystemCapability.Communication.NetStack 3313 * @since 6 3314 */ 3315 /** 3316 * The prerequisite for requesting information from the client is incorrect. 3317 * @syscap SystemCapability.Communication.NetStack 3318 * @crossplatform 3319 * @since 10 3320 */ 3321 /** 3322 * The prerequisite for requesting information from the client is incorrect. 3323 * @syscap SystemCapability.Communication.NetStack 3324 * @crossplatform 3325 * @atomicservice 3326 * @since 11 3327 */ 3328 PRECON_FAILED, 3329 3330 /** 3331 * The request was rejected because the requested entity was too large for the server to process. 3332 * @syscap SystemCapability.Communication.NetStack 3333 * @since 6 3334 */ 3335 /** 3336 * The request was rejected because the requested entity was too large for the server to process. 3337 * @syscap SystemCapability.Communication.NetStack 3338 * @crossplatform 3339 * @since 10 3340 */ 3341 /** 3342 * The request was rejected because the requested entity was too large for the server to process. 3343 * @syscap SystemCapability.Communication.NetStack 3344 * @crossplatform 3345 * @atomicservice 3346 * @since 11 3347 */ 3348 ENTITY_TOO_LARGE, 3349 3350 /** 3351 * The requested URI is too long (usually a URL) and the server cannot process it. 3352 * @syscap SystemCapability.Communication.NetStack 3353 * @since 6 3354 */ 3355 /** 3356 * The requested URI is too long (usually a URL) and the server cannot process it. 3357 * @syscap SystemCapability.Communication.NetStack 3358 * @crossplatform 3359 * @since 10 3360 */ 3361 /** 3362 * The requested URI is too long (usually a URL) and the server cannot process it. 3363 * @syscap SystemCapability.Communication.NetStack 3364 * @crossplatform 3365 * @atomicservice 3366 * @since 11 3367 */ 3368 REQ_TOO_LONG, 3369 3370 /** 3371 * The server is unable to process the requested format. 3372 * @syscap SystemCapability.Communication.NetStack 3373 * @since 6 3374 */ 3375 /** 3376 * The server is unable to process the requested format. 3377 * @syscap SystemCapability.Communication.NetStack 3378 * @crossplatform 3379 * @since 10 3380 */ 3381 /** 3382 * The server is unable to process the requested format. 3383 * @syscap SystemCapability.Communication.NetStack 3384 * @crossplatform 3385 * @atomicservice 3386 * @since 11 3387 */ 3388 UNSUPPORTED_TYPE, 3389 3390 /** 3391 * The server cannot process the requested data range. 3392 * @syscap SystemCapability.Communication.NetStack 3393 * @crossplatform 3394 * @atomicservice 3395 * @since 12 3396 */ 3397 RANGE_NOT_SATISFIABLE, 3398 3399 /** 3400 * Internal server error, unable to complete the request. 3401 * @syscap SystemCapability.Communication.NetStack 3402 * @since 6 3403 */ 3404 /** 3405 * Internal server error, unable to complete the request. 3406 * @syscap SystemCapability.Communication.NetStack 3407 * @crossplatform 3408 * @since 10 3409 */ 3410 /** 3411 * Internal server error, unable to complete the request. 3412 * @syscap SystemCapability.Communication.NetStack 3413 * @crossplatform 3414 * @atomicservice 3415 * @since 11 3416 */ 3417 INTERNAL_ERROR = 500, 3418 3419 /** 3420 * The server does not support the requested functionality and cannot complete the request. 3421 * @syscap SystemCapability.Communication.NetStack 3422 * @since 6 3423 */ 3424 /** 3425 * The server does not support the requested functionality and cannot complete the request. 3426 * @syscap SystemCapability.Communication.NetStack 3427 * @crossplatform 3428 * @since 10 3429 */ 3430 /** 3431 * The server does not support the requested functionality and cannot complete the request. 3432 * @syscap SystemCapability.Communication.NetStack 3433 * @crossplatform 3434 * @atomicservice 3435 * @since 11 3436 */ 3437 NOT_IMPLEMENTED, 3438 3439 /** 3440 * The server acting as a gateway or proxy received an invalid request from the remote server. 3441 * @syscap SystemCapability.Communication.NetStack 3442 * @since 6 3443 */ 3444 /** 3445 * The server acting as a gateway or proxy received an invalid request from the remote server. 3446 * @syscap SystemCapability.Communication.NetStack 3447 * @crossplatform 3448 * @since 10 3449 */ 3450 /** 3451 * The server acting as a gateway or proxy received an invalid request from the remote server. 3452 * @syscap SystemCapability.Communication.NetStack 3453 * @crossplatform 3454 * @atomicservice 3455 * @since 11 3456 */ 3457 BAD_GATEWAY, 3458 3459 /** 3460 * Due to overload or system maintenance, the server is temporarily unable to process client requests. 3461 * @syscap SystemCapability.Communication.NetStack 3462 * @since 6 3463 */ 3464 /** 3465 * Due to overload or system maintenance, the server is temporarily unable to process client requests. 3466 * @syscap SystemCapability.Communication.NetStack 3467 * @crossplatform 3468 * @since 10 3469 */ 3470 /** 3471 * Due to overload or system maintenance, the server is temporarily unable to process client requests. 3472 * @syscap SystemCapability.Communication.NetStack 3473 * @crossplatform 3474 * @atomicservice 3475 * @since 11 3476 */ 3477 UNAVAILABLE, 3478 3479 /** 3480 * The server acting as a gateway or proxy did not obtain requests from the remote server in a timely manner. 3481 * @syscap SystemCapability.Communication.NetStack 3482 * @since 6 3483 */ 3484 /** 3485 * The server acting as a gateway or proxy did not obtain requests from the remote server in a timely manner. 3486 * @syscap SystemCapability.Communication.NetStack 3487 * @crossplatform 3488 * @since 10 3489 */ 3490 /** 3491 * The server acting as a gateway or proxy did not obtain requests from the remote server in a timely manner. 3492 * @syscap SystemCapability.Communication.NetStack 3493 * @crossplatform 3494 * @atomicservice 3495 * @since 11 3496 */ 3497 GATEWAY_TIMEOUT, 3498 3499 /** 3500 * The version of the HTTP protocol requested by the server. 3501 * @syscap SystemCapability.Communication.NetStack 3502 * @since 6 3503 */ 3504 /** 3505 * The version of the HTTP protocol requested by the server. 3506 * @syscap SystemCapability.Communication.NetStack 3507 * @crossplatform 3508 * @since 10 3509 */ 3510 /** 3511 * The version of the HTTP protocol requested by the server. 3512 * @syscap SystemCapability.Communication.NetStack 3513 * @crossplatform 3514 * @atomicservice 3515 * @since 11 3516 */ 3517 VERSION 3518 } 3519 3520 /** 3521 * Supported protocols. 3522 * @enum {string} 3523 * @syscap SystemCapability.Communication.NetStack 3524 * @since 9 3525 */ 3526 /** 3527 * Supported protocols. 3528 * @enum {string} 3529 * @syscap SystemCapability.Communication.NetStack 3530 * @crossplatform 3531 * @since 10 3532 */ 3533 /** 3534 * Supported protocols. 3535 * @enum {string} 3536 * @syscap SystemCapability.Communication.NetStack 3537 * @crossplatform 3538 * @atomicservice 3539 * @since 11 3540 */ 3541 3542 export enum HttpProtocol { 3543 /** 3544 * Protocol http1.1 3545 * @syscap SystemCapability.Communication.NetStack 3546 * @since 9 3547 */ 3548 /** 3549 * Protocol http1.1 3550 * @syscap SystemCapability.Communication.NetStack 3551 * @crossplatform 3552 * @since 10 3553 */ 3554 /** 3555 * Protocol http1.1 3556 * @syscap SystemCapability.Communication.NetStack 3557 * @crossplatform 3558 * @atomicservice 3559 * @since 11 3560 */ 3561 HTTP1_1, 3562 3563 /** 3564 * Protocol http2 3565 * @syscap SystemCapability.Communication.NetStack 3566 * @since 9 3567 */ 3568 /** 3569 * Protocol http2 3570 * @syscap SystemCapability.Communication.NetStack 3571 * @crossplatform 3572 * @since 10 3573 */ 3574 /** 3575 * Protocol http2 3576 * @syscap SystemCapability.Communication.NetStack 3577 * @crossplatform 3578 * @atomicservice 3579 * @since 11 3580 */ 3581 HTTP2, 3582 3583 /** 3584 * Protocol http3 for https only. 3585 * Cause error if using http only or not supporting http3 on this device. 3586 * Fallback to http2 or http1.1 if needed. 3587 * @syscap SystemCapability.Communication.NetStack 3588 * @since 11 3589 */ 3590 /** 3591 * Protocol http3 for https only. 3592 * Cause error if using http only or not supporting http3 on this device. 3593 * Fallback to http2 or http1.1 if needed. 3594 * @syscap SystemCapability.Communication.NetStack 3595 * @crossplatform 3596 * @since 12 3597 */ 3598 HTTP3 3599 } 3600 3601 /** 3602 * Indicates the type of the returned data. 3603 * @enum {number} 3604 * @syscap SystemCapability.Communication.NetStack 3605 * @since 9 3606 */ 3607 /** 3608 * Indicates the type of the returned data. 3609 * @enum {number} 3610 * @syscap SystemCapability.Communication.NetStack 3611 * @crossplatform 3612 * @since 10 3613 */ 3614 /** 3615 * Indicates the type of the returned data. 3616 * @enum {number} 3617 * @syscap SystemCapability.Communication.NetStack 3618 * @crossplatform 3619 * @atomicservice 3620 * @since 11 3621 */ 3622 export enum HttpDataType { 3623 /** 3624 * The returned type is string. 3625 * @syscap SystemCapability.Communication.NetStack 3626 * @since 9 3627 */ 3628 /** 3629 * The returned type is string. 3630 * @syscap SystemCapability.Communication.NetStack 3631 * @crossplatform 3632 * @since 10 3633 */ 3634 /** 3635 * The returned type is string. 3636 * @syscap SystemCapability.Communication.NetStack 3637 * @crossplatform 3638 * @atomicservice 3639 * @since 11 3640 */ 3641 STRING, 3642 3643 /** 3644 * The returned type is Object. 3645 * @syscap SystemCapability.Communication.NetStack 3646 * @since 9 3647 */ 3648 /** 3649 * The returned type is Object. 3650 * @syscap SystemCapability.Communication.NetStack 3651 * @crossplatform 3652 * @since 10 3653 */ 3654 /** 3655 * The returned type is Object. 3656 * @syscap SystemCapability.Communication.NetStack 3657 * @crossplatform 3658 * @atomicservice 3659 * @since 11 3660 */ 3661 OBJECT = 1, 3662 3663 /** 3664 * The returned type is ArrayBuffer. 3665 * @syscap SystemCapability.Communication.NetStack 3666 * @since 9 3667 */ 3668 /** 3669 * The returned type is ArrayBuffer. 3670 * @syscap SystemCapability.Communication.NetStack 3671 * @crossplatform 3672 * @since 10 3673 */ 3674 /** 3675 * The returned type is ArrayBuffer. 3676 * @syscap SystemCapability.Communication.NetStack 3677 * @crossplatform 3678 * @atomicservice 3679 * @since 11 3680 */ 3681 ARRAY_BUFFER = 2 3682 } 3683 3684 /** 3685 * Defines the response to an HTTP request. 3686 * @interface HttpResponse 3687 * @syscap SystemCapability.Communication.NetStack 3688 * @since 6 3689 */ 3690 /** 3691 * Defines the response to an HTTP request. 3692 * @interface HttpResponse 3693 * @syscap SystemCapability.Communication.NetStack 3694 * @crossplatform 3695 * @since 10 3696 */ 3697 /** 3698 * Defines the response to an HTTP request. 3699 * @interface HttpResponse 3700 * @syscap SystemCapability.Communication.NetStack 3701 * @crossplatform 3702 * @atomicservice 3703 * @since 11 3704 */ 3705 export interface HttpResponse { 3706 /** 3707 * result can be a string (API 6) or an ArrayBuffer(API 8). Object is deprecated from API 8. 3708 * If {@link HttpRequestOptions#expectDataType} is set, the system preferentially returns this parameter. 3709 * @type {string | Object | ArrayBuffer} 3710 * @syscap SystemCapability.Communication.NetStack 3711 * @since 6 3712 */ 3713 /** 3714 * result can be a string (API 6) or an ArrayBuffer(API 8). Object is deprecated from API 8. 3715 * If {@link HttpRequestOptions#expectDataType} is set, the system preferentially returns this parameter. 3716 * @type {string | Object | ArrayBuffer} 3717 * @syscap SystemCapability.Communication.NetStack 3718 * @crossplatform 3719 * @since 10 3720 */ 3721 /** 3722 * result can be a string (API 6) or an ArrayBuffer(API 8). Object is deprecated from API 8. 3723 * If {@link HttpRequestOptions#expectDataType} is set, the system preferentially returns this parameter. 3724 * @type {string | Object | ArrayBuffer} 3725 * @syscap SystemCapability.Communication.NetStack 3726 * @crossplatform 3727 * @atomicservice 3728 * @since 11 3729 */ 3730 result: string | Object | ArrayBuffer; 3731 3732 /** 3733 * If the resultType is string, you can get result directly. 3734 * If the resultType is Object, you can get result such as this: result['key']. 3735 * If the resultType is ArrayBuffer, you can use ArrayBuffer to create the binary objects. 3736 * @type {HttpDataType} 3737 * @syscap SystemCapability.Communication.NetStack 3738 * @since 9 3739 */ 3740 /** 3741 * If the resultType is string, you can get result directly. 3742 * If the resultType is Object, you can get result such as this: result['key']. 3743 * If the resultType is ArrayBuffer, you can use ArrayBuffer to create the binary objects. 3744 * @type {HttpDataType} 3745 * @syscap SystemCapability.Communication.NetStack 3746 * @crossplatform 3747 * @since 10 3748 */ 3749 /** 3750 * If the resultType is string, you can get result directly. 3751 * If the resultType is Object, you can get result such as this: result['key']. 3752 * If the resultType is ArrayBuffer, you can use ArrayBuffer to create the binary objects. 3753 * @type {HttpDataType} 3754 * @syscap SystemCapability.Communication.NetStack 3755 * @crossplatform 3756 * @atomicservice 3757 * @since 11 3758 */ 3759 resultType: HttpDataType; 3760 3761 /** 3762 * Server status code. 3763 * @type {ResponseCode | number} 3764 * @syscap SystemCapability.Communication.NetStack 3765 * @since 6 3766 */ 3767 /** 3768 * Server status code. 3769 * @type {ResponseCode | number} 3770 * @syscap SystemCapability.Communication.NetStack 3771 * @crossplatform 3772 * @since 10 3773 */ 3774 /** 3775 * Server status code. 3776 * @type {ResponseCode | number} 3777 * @syscap SystemCapability.Communication.NetStack 3778 * @crossplatform 3779 * @atomicservice 3780 * @since 11 3781 */ 3782 responseCode: ResponseCode | number; 3783 3784 /** 3785 * All headers in the response from the server. 3786 * @type {Object} 3787 * @syscap SystemCapability.Communication.NetStack 3788 * @since 6 3789 */ 3790 /** 3791 * All headers in the response from the server. 3792 * @type {Object} 3793 * @syscap SystemCapability.Communication.NetStack 3794 * @crossplatform 3795 * @since 10 3796 */ 3797 /** 3798 * All headers in the response from the server. 3799 * @type {Object} 3800 * @syscap SystemCapability.Communication.NetStack 3801 * @crossplatform 3802 * @atomicservice 3803 * @since 11 3804 */ 3805 header: Object; 3806 3807 /** 3808 * Cookies returned by the server. 3809 * @type {string} 3810 * @syscap SystemCapability.Communication.NetStack 3811 * @since 8 3812 */ 3813 /** 3814 * Cookies returned by the server. 3815 * @type {string} 3816 * @syscap SystemCapability.Communication.NetStack 3817 * @crossplatform 3818 * @since 10 3819 */ 3820 /** 3821 * Cookies returned by the server. 3822 * @type {string} 3823 * @syscap SystemCapability.Communication.NetStack 3824 * @crossplatform 3825 * @atomicservice 3826 * @since 11 3827 */ 3828 cookies: string; 3829 3830 /** 3831 * The time taken of various stages of HTTP request. 3832 * @type {PerformanceTiming} 3833 * @syscap SystemCapability.Communication.NetStack 3834 * @since 11 3835 */ 3836 /** 3837 * The time taken of various stages of HTTP request. 3838 * @type {PerformanceTiming} 3839 * @syscap SystemCapability.Communication.NetStack 3840 * @crossplatform 3841 * @since 12 3842 */ 3843 performanceTiming: PerformanceTiming; 3844 } 3845 3846 /** 3847 * Counting the time taken of various stages of HTTP request. 3848 * @interface PerformanceTiming 3849 * @syscap SystemCapability.Communication.NetStack 3850 * @since 11 3851 */ 3852 /** 3853 * Counting the time taken of various stages of HTTP request. 3854 * @interface PerformanceTiming 3855 * @syscap SystemCapability.Communication.NetStack 3856 * @crossplatform 3857 * @since 12 3858 */ 3859 export interface PerformanceTiming { 3860 /** 3861 * Time taken from startup to DNS resolution completion, in milliseconds. 3862 * @type {number} 3863 * @syscap SystemCapability.Communication.NetStack 3864 * @since 11 3865 */ 3866 /** 3867 * Time taken from startup to DNS resolution completion, in milliseconds. 3868 * @type {number} 3869 * @syscap SystemCapability.Communication.NetStack 3870 * @crossplatform 3871 * @since 12 3872 */ 3873 dnsTiming: number; 3874 3875 /** 3876 * Time taken from startup to TCP connection completion, in milliseconds. 3877 * @type {number} 3878 * @syscap SystemCapability.Communication.NetStack 3879 * @since 11 3880 */ 3881 /** 3882 * Time taken from startup to TCP connection completion, in milliseconds. 3883 * @type {number} 3884 * @syscap SystemCapability.Communication.NetStack 3885 * @crossplatform 3886 * @since 12 3887 */ 3888 tcpTiming: number; 3889 3890 /** 3891 * Time taken from startup to TLS connection completion, in milliseconds. 3892 * @type {number} 3893 * @syscap SystemCapability.Communication.NetStack 3894 * @since 11 3895 */ 3896 /** 3897 * Time taken from startup to TLS connection completion, in milliseconds. 3898 * @type {number} 3899 * @syscap SystemCapability.Communication.NetStack 3900 * @crossplatform 3901 * @since 12 3902 */ 3903 tlsTiming: number; 3904 3905 /** 3906 * Time taken from startup to start sending the first byte, in milliseconds. 3907 * @type {number} 3908 * @syscap SystemCapability.Communication.NetStack 3909 * @since 11 3910 */ 3911 /** 3912 * Time taken from startup to start sending the first byte, in milliseconds. 3913 * @type {number} 3914 * @syscap SystemCapability.Communication.NetStack 3915 * @crossplatform 3916 * @since 12 3917 */ 3918 firstSendTiming: number; 3919 3920 /** 3921 * Time taken from startup to receiving the first byte, in milliseconds. 3922 * @type {number} 3923 * @syscap SystemCapability.Communication.NetStack 3924 * @since 11 3925 */ 3926 /** 3927 * Time taken from startup to receiving the first byte, in milliseconds. 3928 * @type {number} 3929 * @syscap SystemCapability.Communication.NetStack 3930 * @crossplatform 3931 * @since 12 3932 */ 3933 firstReceiveTiming: number; 3934 3935 /** 3936 * Time taken from startup to the completion of the request, in milliseconds. 3937 * @type {number} 3938 * @syscap SystemCapability.Communication.NetStack 3939 * @since 11 3940 */ 3941 /** 3942 * Time taken from startup to the completion of the request, in milliseconds. 3943 * @type {number} 3944 * @syscap SystemCapability.Communication.NetStack 3945 * @crossplatform 3946 * @since 12 3947 */ 3948 totalFinishTiming: number; 3949 3950 /** 3951 * Time taken from startup to completion of all redirection steps, in milliseconds. 3952 * @type {number} 3953 * @syscap SystemCapability.Communication.NetStack 3954 * @since 11 3955 */ 3956 /** 3957 * Time taken from startup to completion of all redirection steps, in milliseconds. 3958 * @type {number} 3959 * @syscap SystemCapability.Communication.NetStack 3960 * @crossplatform 3961 * @since 12 3962 */ 3963 redirectTiming: number; 3964 3965 /** 3966 * Time taken from HTTP request to header completion, in milliseconds. 3967 * @type {number} 3968 * @syscap SystemCapability.Communication.NetStack 3969 * @since 11 3970 */ 3971 /** 3972 * Time taken from HTTP request to header completion, in milliseconds. 3973 * @type {number} 3974 * @syscap SystemCapability.Communication.NetStack 3975 * @crossplatform 3976 * @since 12 3977 */ 3978 responseHeaderTiming: number; 3979 3980 /** 3981 * Time taken from HTTP Request to body completion, in milliseconds. 3982 * @type {number} 3983 * @syscap SystemCapability.Communication.NetStack 3984 * @since 11 3985 */ 3986 /** 3987 * Time taken from HTTP Request to body completion, in milliseconds. 3988 * @type {number} 3989 * @syscap SystemCapability.Communication.NetStack 3990 * @crossplatform 3991 * @since 12 3992 */ 3993 responseBodyTiming: number; 3994 3995 /** 3996 * Time taken from HTTP Request to callback to the application, in milliseconds. 3997 * @type {number} 3998 * @syscap SystemCapability.Communication.NetStack 3999 * @since 11 4000 */ 4001 /** 4002 * Time taken from HTTP Request to callback to the application, in milliseconds. 4003 * @type {number} 4004 * @syscap SystemCapability.Communication.NetStack 4005 * @crossplatform 4006 * @since 12 4007 */ 4008 totalTiming: number; 4009 } 4010 4011 /** 4012 * This interface is used to obtain the progress information of file upload or download. 4013 * @interface DataReceiveProgressInfo 4014 * @syscap SystemCapability.Communication.NetStack 4015 * @since 11 4016 */ 4017 /** 4018 * This interface is used to obtain the progress information of file upload or download. 4019 * @interface DataReceiveProgressInfo 4020 * @syscap SystemCapability.Communication.NetStack 4021 * @crossplatform 4022 * @since 12 4023 */ 4024 /** 4025 * This interface is used to obtain the progress information of file upload or download. 4026 * @interface DataReceiveProgressInfo 4027 * @syscap SystemCapability.Communication.NetStack 4028 * @crossplatform 4029 * @atomicservice 4030 * @since 15 4031 */ 4032 export interface DataReceiveProgressInfo { 4033 /** 4034 * Number of data bytes received. 4035 * @type { number } 4036 * @syscap SystemCapability.Communication.NetStack 4037 * @since 11 4038 */ 4039 /** 4040 * Number of data bytes received. 4041 * @type { number } 4042 * @syscap SystemCapability.Communication.NetStack 4043 * @crossplatform 4044 * @since 12 4045 */ 4046 /** 4047 * Number of data bytes received. 4048 * @type { number } 4049 * @syscap SystemCapability.Communication.NetStack 4050 * @crossplatform 4051 * @atomicservice 4052 * @since 15 4053 */ 4054 receiveSize: number; 4055 /** 4056 * Total number of bytes to receive. 4057 * @type { number } 4058 * @syscap SystemCapability.Communication.NetStack 4059 * @since 11 4060 */ 4061 /** 4062 * Total number of bytes to receive. 4063 * @type { number } 4064 * @syscap SystemCapability.Communication.NetStack 4065 * @crossplatform 4066 * @since 12 4067 */ 4068 /** 4069 * Total number of bytes to receive. 4070 * @type { number } 4071 * @syscap SystemCapability.Communication.NetStack 4072 * @crossplatform 4073 * @atomicservice 4074 * @since 15 4075 */ 4076 totalSize: number; 4077 } 4078 4079 /** 4080 * This interface is used to monitor the progress of sending data. 4081 * @interface DataSendProgressInfo 4082 * @syscap SystemCapability.Communication.NetStack 4083 * @since 11 4084 */ 4085 /** 4086 * This interface is used to monitor the progress of sending data. 4087 * @interface DataSendProgressInfo 4088 * @syscap SystemCapability.Communication.NetStack 4089 * @crossplatform 4090 * @since 12 4091 */ 4092 /** 4093 * This interface is used to monitor the progress of sending data. 4094 * @interface DataSendProgressInfo 4095 * @syscap SystemCapability.Communication.NetStack 4096 * @crossplatform 4097 * @atomicservice 4098 * @since 15 4099 */ 4100 export interface DataSendProgressInfo { 4101 /** 4102 * Used to specify the data size to be sent. 4103 * @type { number } 4104 * @syscap SystemCapability.Communication.NetStack 4105 * @since 11 4106 */ 4107 /** 4108 * Used to specify the data size to be sent. 4109 * @type { number } 4110 * @syscap SystemCapability.Communication.NetStack 4111 * @crossplatform 4112 * @since 12 4113 */ 4114 /** 4115 * Used to specify the data size to be sent. 4116 * @type { number } 4117 * @syscap SystemCapability.Communication.NetStack 4118 * @crossplatform 4119 * @atomicservice 4120 * @since 15 4121 */ 4122 sendSize: number; 4123 /** 4124 * Total number of bytes to receive. 4125 * @type { number } 4126 * @syscap SystemCapability.Communication.NetStack 4127 * @since 11 4128 */ 4129 /** 4130 * Total number of bytes to receive. 4131 * @type { number } 4132 * @syscap SystemCapability.Communication.NetStack 4133 * @crossplatform 4134 * @since 12 4135 */ 4136 /** 4137 * Total number of bytes to receive. 4138 * @type { number } 4139 * @syscap SystemCapability.Communication.NetStack 4140 * @crossplatform 4141 * @atomicservice 4142 * @since 15 4143 */ 4144 totalSize: number; 4145 } 4146 4147 /** 4148 * Creates a default {@code HttpResponseCache} object to store the responses of HTTP access requests. 4149 * @param { number } cacheSize - the size of cache(max value is 10MB), default is 10*1024*1024(10MB). 4150 * @returns { HttpResponseCache } the HttpResponseCache of the createHttpResponseCache. 4151 * @syscap SystemCapability.Communication.NetStack 4152 * @since 9 4153 */ 4154 /** 4155 * Creates a default {@code HttpResponseCache} object to store the responses of HTTP access requests. 4156 * @param { number } cacheSize - the size of cache(max value is 10MB), default is 10*1024*1024(10MB). 4157 * @returns { HttpResponseCache } the HttpResponseCache of the createHttpResponseCache. 4158 * @syscap SystemCapability.Communication.NetStack 4159 * @crossplatform 4160 * @since 10 4161 */ 4162 /** 4163 * Creates a default {@code HttpResponseCache} object to store the responses of HTTP access requests. 4164 * @param { number } cacheSize - the size of cache(max value is 10MB), default is 10*1024*1024(10MB). 4165 * @returns { HttpResponseCache } the HttpResponseCache of the createHttpResponseCache. 4166 * @syscap SystemCapability.Communication.NetStack 4167 * @crossplatform 4168 * @atomicservice 4169 * @since 11 4170 */ 4171 function createHttpResponseCache(cacheSize?: number): HttpResponseCache; 4172 4173 /** 4174 * Defines an object that stores the response to an HTTP request. 4175 * @interface HttpResponseCache 4176 * @syscap SystemCapability.Communication.NetStack 4177 * @since 9 4178 */ 4179 /** 4180 * Defines an object that stores the response to an HTTP request. 4181 * @interface HttpResponseCache 4182 * @syscap SystemCapability.Communication.NetStack 4183 * @crossplatform 4184 * @since 10 4185 */ 4186 /** 4187 * Defines an object that stores the response to an HTTP request. 4188 * @interface HttpResponseCache 4189 * @syscap SystemCapability.Communication.NetStack 4190 * @crossplatform 4191 * @atomicservice 4192 * @since 11 4193 */ 4194 export interface HttpResponseCache { 4195 /** 4196 * Writes data in the cache to the file system so that all the cached data can be accessed in the next HTTP request. 4197 * @param { AsyncCallback<void> } callback - the callback of flush. 4198 * @syscap SystemCapability.Communication.NetStack 4199 * @since 9 4200 */ 4201 /** 4202 * Writes data in the cache to the file system so that all the cached data can be accessed in the next HTTP request. 4203 * @param { AsyncCallback<void> } callback - the callback of flush. 4204 * @syscap SystemCapability.Communication.NetStack 4205 * @crossplatform 4206 * @since 10 4207 */ 4208 /** 4209 * Writes data in the cache to the file system so that all the cached data can be accessed in the next HTTP request. 4210 * @param { AsyncCallback<void> } callback - the callback of flush. 4211 * @syscap SystemCapability.Communication.NetStack 4212 * @crossplatform 4213 * @atomicservice 4214 * @since 11 4215 */ 4216 flush(callback: AsyncCallback<void>): void; 4217 4218 /** 4219 * Writes data in the cache to the file system so that all the cached data can be accessed in the next HTTP request. 4220 * @returns { Promise<void> } The promise returned by the flush. 4221 * @syscap SystemCapability.Communication.NetStack 4222 * @since 9 4223 */ 4224 /** 4225 * Writes data in the cache to the file system so that all the cached data can be accessed in the next HTTP request. 4226 * @returns { Promise<void> } The promise returned by the flush. 4227 * @syscap SystemCapability.Communication.NetStack 4228 * @crossplatform 4229 * @since 10 4230 */ 4231 /** 4232 * Writes data in the cache to the file system so that all the cached data can be accessed in the next HTTP request. 4233 * @returns { Promise<void> } The promise returned by the flush. 4234 * @syscap SystemCapability.Communication.NetStack 4235 * @crossplatform 4236 * @atomicservice 4237 * @since 11 4238 */ 4239 flush(): Promise<void>; 4240 4241 /** 4242 * Disables a cache and deletes the data in it. 4243 * @param { AsyncCallback<void> } callback - the callback of delete. 4244 * @syscap SystemCapability.Communication.NetStack 4245 * @since 9 4246 */ 4247 /** 4248 * Disables a cache and deletes the data in it. 4249 * @param { AsyncCallback<void> } callback - the callback of delete. 4250 * @syscap SystemCapability.Communication.NetStack 4251 * @crossplatform 4252 * @since 10 4253 */ 4254 /** 4255 * Disables a cache and deletes the data in it. 4256 * @param { AsyncCallback<void> } callback - the callback of delete. 4257 * @syscap SystemCapability.Communication.NetStack 4258 * @crossplatform 4259 * @atomicservice 4260 * @since 11 4261 */ 4262 delete(callback: AsyncCallback<void>): void; 4263 4264 /** 4265 * Disables a cache and deletes the data in it. 4266 * @returns { Promise<void> } The promise returned by the delete. 4267 * @syscap SystemCapability.Communication.NetStack 4268 * @since 9 4269 */ 4270 /** 4271 * Disables a cache and deletes the data in it. 4272 * @returns { Promise<void> } The promise returned by the delete. 4273 * @syscap SystemCapability.Communication.NetStack 4274 * @crossplatform 4275 * @since 10 4276 */ 4277 /** 4278 * Disables a cache and deletes the data in it. 4279 * @returns { Promise<void> } The promise returned by the delete. 4280 * @syscap SystemCapability.Communication.NetStack 4281 * @crossplatform 4282 * @atomicservice 4283 * @since 11 4284 */ 4285 delete(): Promise<void>; 4286 } 4287} 4288 4289export default http; 4290