@@ -16,24 +16,6 @@ import request from '@ohos.request';
...
@@ -16,24 +16,6 @@ import request from '@ohos.request';
## Constraints
## Constraints
HTTPS is supported by default in the FA model. To support HTTP, add **network** to the **config.json** file and set the **cleartextTraffic** attribute to **true**.
```js
varconfig={
"deviceConfig":{
"default":{
"network":{
"cleartextTraffic":true
}
//...
}
}
}
```
The **cleartextTraffic** attribute is not involved during application development in the stage model.
The download server must support the HTTP HEAD method so that the size of the data to download can be obtained through **Content-length**. Otherwise, the download task fails. If this is the case, you can check the failure cause through [on('fail')<sup>7+</sup>](#onfail7).
The download server must support the HTTP HEAD method so that the size of the data to download can be obtained through **Content-length**. Otherwise, the download task fails. If this is the case, you can check the failure cause through [on('fail')<sup>7+</sup>](#onfail7).
Only HTTP requests are supported. HTTPS requests are not supported.
Only HTTP requests are supported. HTTPS requests are not supported.
...
@@ -105,24 +87,24 @@ Uploads files. This API uses a promise to return the result.
...
@@ -105,24 +87,24 @@ Uploads files. This API uses a promise to return the result.
| callback | AsyncCallback<[UploadTask](#uploadtask)> | Yes| Callback used to return the **UploadTask** object.|
| callback | AsyncCallback<[UploadTask](#uploadtask)> | Yes| Callback used to return the **UploadTask** object.|
**Example**
**Example**
...
@@ -304,10 +286,10 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
...
@@ -304,10 +286,10 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (upload progress).|
| type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (upload progress).|
| callback | function | Yes| Callback for the upload progress event.|
| callback | function | Yes| Callback for the upload progress event.|
Parameters of the callback function
Parameters of the callback function
...
@@ -338,10 +320,10 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
...
@@ -338,10 +320,10 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to subscribe to. The value is **'headerReceive'** (response header).|
| type | string | Yes| Type of the event to subscribe to. The value is **'headerReceive'** (response header).|
| callback | function | Yes| Callback for the HTTP Response Header event.|
| callback | function | Yes| Callback for the HTTP Response Header event.|
Parameters of the callback function
Parameters of the callback function
...
@@ -371,10 +353,10 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
...
@@ -371,10 +353,10 @@ Subscribes to an upload event. This API uses an asynchronous callback to return
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.|
| type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.|
| callback | Callback<Array<TaskState>> | Yes| Callback used to return the result.|
| callback | Callback<Array<TaskState>> | Yes| Callback used to return the result.|
Parameters of the callback function
Parameters of the callback function
...
@@ -413,10 +395,10 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
...
@@ -413,10 +395,10 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (upload progress).|
| type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (upload progress).|
| callback | function | No| Callback for the upload progress event.|
| callback | function | No| Callback for the upload progress event.|
Parameters of the callback function
Parameters of the callback function
...
@@ -447,10 +429,10 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
...
@@ -447,10 +429,10 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to unsubscribe from. The value is **'headerReceive'** (response header).|
| type | string | Yes| Type of the event to unsubscribe from. The value is **'headerReceive'** (response header).|
| callback | function | No| Callback for the HTTP Response Header event.|
| callback | function | No| Callback for the HTTP Response Header event.|
Parameters of the callback function
Parameters of the callback function
...
@@ -479,10 +461,10 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
...
@@ -479,10 +461,10 @@ Unsubscribes from an upload event. This API uses an asynchronous callback to ret
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.|
| type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.|
| callback | Callback<Array<TaskState>> | No| Callback used to return the result.|
| callback | Callback<Array<TaskState>> | No| Callback used to return the result.|
Parameters of the callback function
Parameters of the callback function
...
@@ -519,9 +501,9 @@ Deletes this upload task. This API uses a promise to return the result.
...
@@ -519,9 +501,9 @@ Deletes this upload task. This API uses a promise to return the result.
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<boolean> | Promise used to return the task removal result. It returns **true** if the operation is successful and returns **false** otherwise.|
| Promise<boolean> | Promise used to return the task removal result. It returns **true** if the operation is successful and returns **false** otherwise.|
**Example**
**Example**
...
@@ -550,9 +532,9 @@ Deletes this upload task. This API uses an asynchronous callback to return the r
...
@@ -550,9 +532,9 @@ Deletes this upload task. This API uses an asynchronous callback to return the r
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.|
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.|
**Example**
**Example**
...
@@ -587,9 +569,9 @@ Removes this upload task. This API uses a promise to return the result.
...
@@ -587,9 +569,9 @@ Removes this upload task. This API uses a promise to return the result.
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<boolean> | Promise used to return the task removal result. It returns **true** if the operation is successful and returns **false** otherwise.|
| Promise<boolean> | Promise used to return the task removal result. It returns **true** if the operation is successful and returns **false** otherwise.|
**Example**
**Example**
...
@@ -622,9 +604,9 @@ Removes this upload task. This API uses an asynchronous callback to return the r
...
@@ -622,9 +604,9 @@ Removes this upload task. This API uses an asynchronous callback to return the r
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.|
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.|
**Example**
**Example**
...
@@ -705,25 +687,25 @@ Downloads files. This API uses a promise to return the result.
...
@@ -705,25 +687,25 @@ Downloads files. This API uses a promise to return the result.