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