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