未验证 提交 87d4fdd5 编写于 作者: O openharmony_ci 提交者: Gitee

!16259 翻译已完成14756+15002+14956+15101

Merge pull request !16259 from shawn_he/14756-b
......@@ -67,7 +67,7 @@ httpRequest.request(
## http.createHttp
createHttp\(\): HttpRequest
createHttp(): HttpRequest
Creates an HTTP request. You can use this API to initiate or destroy an HTTP request, or enable or disable listening for HTTP Response Header events. An HttpRequest object corresponds to an HTTP request. To initiate multiple HTTP requests, you must create an **HttpRequest** object for each HTTP request.
......@@ -77,7 +77,7 @@ Creates an HTTP request. You can use this API to initiate or destroy an HTTP req
| Type | Description |
| :---------- | :----------------------------------------------------------- |
| HttpRequest | An **HttpRequest** object, which contains the **request**, **destroy**, **on**, or **off** method.|
| HttpRequest | An **HttpRequest** object, which contains the **request**, **request2**, **destroy**, **on**, or **off** method.|
**Example**
......@@ -88,14 +88,17 @@ let httpRequest = http.createHttp();
## HttpRequest
Defines an HTTP request task. Before invoking APIs provided by **HttpRequest**, you must call [createHttp\(\)](#httpcreatehttp) to create an **HttpRequestTask** object.
Defines an HTTP request task. Before invoking APIs provided by **HttpRequest**, you must call [createHttp()](#httpcreatehttp) to create an **HttpRequestTask** object.
### request
request\(url: string, callback: AsyncCallback\<HttpResponse\>\):void
request(url: string, callback: AsyncCallback\<HttpResponse\>):void
Initiates an HTTP request to a given URL. This API uses an asynchronous callback to return the result.
>**NOTE**
>This API supports only transfer of data not greater than 5 MB.
**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetStack
......@@ -140,10 +143,13 @@ httpRequest.request("EXAMPLE_URL", (err, data) => {
### request
request\(url: string, options: HttpRequestOptions, callback: AsyncCallback\<HttpResponse\>\):void
request(url: string, options: HttpRequestOptions, callback: AsyncCallback\<HttpResponse\>):void
Initiates an HTTP request containing specified options to a given URL. This API uses an asynchronous callback to return the result.
>**NOTE**
>This API supports only transfer of data not greater than 5 MB.
**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetStack
......@@ -223,10 +229,13 @@ httpRequest.request("EXAMPLE_URL",
### request
request\(url: string, options? : HttpRequestOptions\): Promise\<HttpResponse\>
request(url: string, options? : HttpRequestOptions): Promise\<HttpResponse\>
Initiates an HTTP request containing specified options to a given URL. This API uses a promise to return the result.
>**NOTE**
>This API supports only transfer of data not greater than 5 MB.
**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetStack
......@@ -309,7 +318,7 @@ promise.then((data) => {
### destroy
destroy\(\): void
destroy(): void
Destroys an HTTP request.
......@@ -323,7 +332,7 @@ httpRequest.destroy();
### request2<sup>10+</sup>
request2(url: string, callback: AsyncCallback<void>): void
request2(url: string, callback: AsyncCallback\<void\>): void
Initiates an HTTP request to a given URL. This API uses an asynchronous callback to return the result, which is a streaming response.
......@@ -359,7 +368,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback
```js
httpRequest.request2("EXAMPLE_URL", (err) => {
if (!err) {
console.info(request2 OK!);
console.info("request2 OK!");
} else {
console.info("request2 ERROR : err = " + JSON.stringify(err));
}
......@@ -368,9 +377,9 @@ httpRequest.request2("EXAMPLE_URL", (err) => {
### request2<sup>10+</sup>
request2(url: string, options: HttpRequestOptions, callback: AsyncCallback<void>): void
request2(url: string, options: HttpRequestOptions, callback: AsyncCallback\<void\>): void
Initiates an HTTP request containing specified options to a given URL. This API uses an asynchronous callback to return the result, which is a streaming response.
Initiates an HTTP request to a given URL. This API uses an asynchronous callback to return the result, which is a streaming response.
**Required permissions**: ohos.permission.INTERNET
......@@ -437,7 +446,7 @@ httpRequest.request2("EXAMPLE_URL",
connectTimeout: 60000
}, (err) => {
if (!err) {
console.info(request2 OK!);
console.info("request2 OK!");
} else {
console.info("request2 ERROR : err = " + JSON.stringify(err));
}
......@@ -445,7 +454,7 @@ httpRequest.request2("EXAMPLE_URL",
```
### request2<sup>10+</sup>
request2\(url: string, options? : HttpRequestOptions\): Promise\<void\>
request2(url: string, options? : HttpRequestOptions): Promise\<void\>
Initiates an HTTP request containing specified options to a given URL. This API uses a promise to return the result, which is a streaming response.
......@@ -518,20 +527,20 @@ let promise = httpRequest.request("EXAMPLE_URL", {
}
});
promise.then(() => {
console.info(request2 OK!);
console.info("request2 OK!");
}).catch((err) => {
console.info("request2 ERROR : err = " + JSON.stringify(err));
});
```
### on\('headerReceive'\)
### on('headerReceive')
on\(type: 'headerReceive', callback: AsyncCallback<Object\>\): void
on(type: 'headerReceive', callback: AsyncCallback\<Object\>): void
Registers an observer for HTTP Response Header events.
>**NOTE**
>This API has been deprecated. You are advised to use [on\('headersReceive'\)<sup>8+</sup>](#onheadersreceive8) instead.
>This API has been deprecated. You are advised to use [on('headersReceive')<sup>8+</sup>](#onheadersreceive8) instead.
**System capability**: SystemCapability.Communication.NetStack
......@@ -545,24 +554,20 @@ Registers an observer for HTTP Response Header events.
**Example**
```js
httpRequest.on('headerReceive', (err, data) => {
if (!err) {
console.info('header: ' + JSON.stringify(data));
} else {
console.info('error:' + JSON.stringify(err));
}
httpRequest.on('headerReceive', (data) => {
console.info('error:' + JSON.stringify(data));
});
```
### off\('headerReceive'\)
### off('headerReceive')
off\(type: 'headerReceive', callback?: AsyncCallback<Object\>\): void
off(type: 'headerReceive', callback?: AsyncCallback\<Object\>): void
Unregisters the observer for HTTP Response Header events.
>**NOTE**
>
>1. This API has been deprecated. You are advised to use [off\('headersReceive'\)<sup>8+</sup>](#offheadersreceive8) instead.
>1. This API has been deprecated. You are advised to use [off('headersReceive')<sup>8+</sup>](#offheadersreceive8) instead.
>
>2. You can pass the callback of the **on** function if you want to cancel listening for a certain type of event. If you do not pass the callback, you will cancel listening for all events.
......@@ -581,9 +586,9 @@ Unregisters the observer for HTTP Response Header events.
httpRequest.off('headerReceive');
```
### on\('headersReceive'\)<sup>8+</sup>
### on('headersReceive')<sup>8+</sup>
on\(type: 'headersReceive', callback: Callback<Object\>\): void
on(type: 'headersReceive', callback: Callback\<Object\>): void
Registers an observer for HTTP Response Header events.
......@@ -604,9 +609,9 @@ httpRequest.on('headersReceive', (header) => {
});
```
### off\('headersReceive'\)<sup>8+</sup>
### off('headersReceive')<sup>8+</sup>
off\(type: 'headersReceive', callback?: Callback<Object\>\): void
off(type: 'headersReceive', callback?: Callback\<Object\>): void
Unregisters the observer for HTTP Response Header events.
......@@ -628,9 +633,9 @@ Unregisters the observer for HTTP Response Header events.
httpRequest.off('headersReceive');
```
### once\('headersReceive'\)<sup>8+</sup>
### once('headersReceive')<sup>8+</sup>
once\(type: 'headersReceive', callback: Callback<Object\>\): void
once(type: 'headersReceive', callback: Callback\<Object\>): void
Registers a one-time observer for HTTP Response Header events. Once triggered, the observer will be removed. This API uses an asynchronous callback to return the result.
......@@ -650,9 +655,9 @@ httpRequest.once('headersReceive', (header) => {
console.info('header: ' + JSON.stringify(header));
});
```
### on\('dataReceive'\)<sup>10+</sup>
### on('dataReceive')<sup>10+</sup>
on\(type: 'dataReceive', callback: Callback\<ArrayBuffer\>\): void
on(type: 'dataReceive', callback: Callback\<ArrayBuffer\>): void
Registers an observer for events indicating receiving of HTTP streaming responses.
......@@ -673,9 +678,9 @@ httpRequest.on('dataReceive', (data) => {
});
```
### off\('dataReceive'\)<sup>10+</sup>
### off('dataReceive')<sup>10+</sup>
off\(type: 'dataReceive', callback?: Callback\<ArrayBuffer\>\): void
off(type: 'dataReceive', callback?: Callback\<ArrayBuffer\>): void
Unregisters the observer for events indicating receiving of HTTP streaming responses.
......@@ -697,9 +702,9 @@ Unregisters the observer for events indicating receiving of HTTP streaming respo
httpRequest.off('dataReceive');
```
### on\('dataEnd'\)<sup>10+</sup>
### on('dataEnd')<sup>10+</sup>
on\(type: 'dataEnd', callback: Callback\<void\>\): void
on(type: 'dataEnd', callback: Callback\<void\>): void
Registers an observer for events indicating completion of receiving HTTP streaming responses.
......@@ -720,7 +725,7 @@ httpRequest.on('dataReceive', () => {
});
```
### off\('dataEnd'\)<sup>10+</sup>
### off('dataEnd')<sup>10+</sup>
off(type: 'dataEnd', callback?: Callback\<void\>): void
......@@ -744,9 +749,9 @@ Unregisters the observer for events indicating completion of receiving HTTP stre
httpRequest.off('dataEnd');
```
### on\('dataProgress'\)<sup>10+</sup>
### on('dataProgress')<sup>10+</sup>
on\(type: 'dataProgress', callback: Callback\<{ receiveSize: number, totalSize: number }\>\): void
on(type: 'dataProgress', callback: Callback\<{ receiveSize: number, totalSize: number }\>): void
Registers an observer for events indicating progress of receiving HTTP streaming responses.
......@@ -757,19 +762,17 @@ Registers an observer for events indicating progress of receiving HTTP streaming
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | --------------------------------- |
| type | string | Yes | Event type. The value is **dataProgress**.|
| callback | AsyncCallback\<{ receiveSize: number, totalSize: number }\> | Yes | Callback used to return the result. |
| callback | AsyncCallback\<{ receiveSize: number, totalSize: number }\> | Yes | Callback used to return the result.<br>**receiveSize**: number of received bytes.<br>**totalSize**: total number of bytes to be received.|
**Example**
```js
httpRequest.on('dataProgress', (data) => {
if (!err) {
console.info('dataProgress:' + JSON.stringify(data));
}
});
```
### off\('dataProgress'\)<sup>10+</sup>
### off('dataProgress')<sup>10+</sup>
off(type: 'dataProgress', callback?: Callback\<{ receiveSize: number, totalSize: number }\>): void
......@@ -915,11 +918,11 @@ let httpResponseCache = http.createHttpResponseCache();
## HttpResponseCache<sup>9+</sup>
Defines an object that stores the response to an HTTP request.
Defines an object that stores the response to an HTTP request. Before invoking APIs provided by **HttpResponseCache**, you must call [createHttpResponseCache()](#httpcreatehttpresponsecache9) to create an **HttpRequestTask** object.
### flush<sup>9+</sup>
flush(callback: AsyncCallback\<void>): void
flush(callback: AsyncCallback\<void\>): void
Flushes data in the cache to the file system so that the cached data can be accessed in the next HTTP request. This API uses an asynchronous callback to return the result.
......@@ -929,7 +932,7 @@ Flushes data in the cache to the file system so that the cached data can be acce
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ---------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Example**
......@@ -945,7 +948,7 @@ httpResponseCache.flush(err => {
### flush<sup>9+</sup>
flush(): Promise\<void>
flush(): Promise\<void\>
Flushes data in the cache to the file system so that the cached data can be accessed in the next HTTP request. This API uses a promise to return the result.
......@@ -955,7 +958,7 @@ Flushes data in the cache to the file system so that the cached data can be acce
| Type | Description |
| --------------------------------- | ------------------------------------- |
| Promise\<void>> | Promise used to return the result.|
| Promise\<void\> | Promise used to return the result.|
**Example**
......@@ -969,7 +972,7 @@ httpResponseCache.flush().then(() => {
### delete<sup>9+</sup>
delete(callback: AsyncCallback\<void>): void
delete(callback: AsyncCallback\<void\>): void
Disables the cache and deletes the data in it. This API uses an asynchronous callback to return the result.
......@@ -979,7 +982,7 @@ Disables the cache and deletes the data in it. This API uses an asynchronous cal
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ---------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Example**
......@@ -994,7 +997,7 @@ httpResponseCache.delete(err => {
```
### delete<sup>9+</sup>
delete(): Promise\<void>
delete(): Promise\<void\>
Disables the cache and deletes the data in it. This API uses a promise to return the result.
......@@ -1004,7 +1007,7 @@ Disables the cache and deletes the data in it. This API uses a promise to return
| Type | Description |
| --------------------------------- | ------------------------------------- |
| Promise\<void> | Promise used to return the result.|
| Promise\<void\> | Promise used to return the result.|
**Example**
......
......@@ -420,44 +420,44 @@ Enumerates mouse pointer styles.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
| Name | Value | Description |
| -------------------------------- | ---- | ------ |
| DEFAULT | 0 | Default |
| EAST | 1 | East arrow |
| WEST | 2 | West arrow |
| SOUTH | 3 | South arrow |
| NORTH | 4 | North arrow |
| WEST_EAST | 5 | West-east arrow |
| NORTH_SOUTH | 6 | North-south arrow |
| NORTH_EAST | 7 | North-east arrow |
| NORTH_WEST | 8 | North-west arrow |
| SOUTH_EAST | 9 | South-east arrow |
| SOUTH_WEST | 10 | South-west arrow |
| NORTH_EAST_SOUTH_WEST | 11 | North-east and south-west adjustment|
| NORTH_WEST_SOUTH_EAST | 12 | North-west and south-east adjustment|
| CROSS | 13 | Cross (accurate selection) |
| CURSOR_COPY | 14 | Copy cursor |
| CURSOR_FORBID | 15 | Forbid cursor |
| COLOR_SUCKER | 16 | Sucker |
| HAND_GRABBING | 17 | Grabbing hand |
| HAND_OPEN | 18 | Opening hand |
| HAND_POINTING | 19 | Hand-shaped pointer |
| HELP | 20 | Help |
| MOVE | 21 | Move |
| RESIZE_LEFT_RIGHT | 22 | Left and right resizing|
| RESIZE_UP_DOWN | 23 | Up and down resizing|
| SCREENSHOT_CHOOSE | 24 | Screenshot crosshair|
| SCREENSHOT_CURSOR | 25 | Screenshot cursor |
| TEXT_CURSOR | 26 | Text cursor |
| ZOOM_IN | 27 | Zoom in |
| ZOOM_OUT | 28 | Zoom out |
| MIDDLE_BTN_EAST | 29 | Scrolling east |
| MIDDLE_BTN_WEST | 30 | Scrolling west |
| MIDDLE_BTN_SOUTH | 31 | Scrolling south |
| MIDDLE_BTN_NORTH | 32 | Scrolling north |
| MIDDLE_BTN_NORTH_SOUTH | 33 | Scrolling north-south |
| MIDDLE_BTN_NORTH_EAST | 34 | Scrolling north-east |
| MIDDLE_BTN_NORTH_WEST | 35 | Scrolling north-west |
| MIDDLE_BTN_SOUTH_EAST | 36 | Scrolling south-east |
| MIDDLE_BTN_SOUTH_WEST | 37 | Scrolling south-west |
| MIDDLE_BTN_NORTH_SOUTH_WEST_EAST | 38 | Moving as a cone in four directions|
| Name | Value | Description |Legend|
| -------------------------------- | ---- | ------ |------ |
| DEFAULT | 0 | Default |![Default.png](./figures/Default.png)|
| EAST | 1 | East arrow |![East.png](./figures/East.png)|
| WEST | 2 | West arrow |![West.png](./figures/West.png)|
| SOUTH | 3 | South arrow |![South.png](./figures/South.png)|
| NORTH | 4 | North arrow |![North.png](./figures/North.png)|
| WEST_EAST | 5 | West-east arrow |![West_East.png](./figures/West_East.png)|
| NORTH_SOUTH | 6 | North-south arrow |![North_South.png](./figures/North_South.png)|
| NORTH_EAST | 7 | North-east arrow |![North_East.png](./figures/North_East.png)|
| NORTH_WEST | 8 | North-west arrow |![North_West.png](./figures/North_West.png)|
| SOUTH_EAST | 9 | South-east arrow |![South_East.png](./figures/South_East.png)|
| SOUTH_WEST | 10 | South-west arrow |![South_West.png](./figures/South_West.png)|
| NORTH_EAST_SOUTH_WEST | 11 | North-east and south-west adjustment|![North_East_South_West.png](./figures/North_East_South_West.png)|
| NORTH_WEST_SOUTH_EAST | 12 | North-west and south-east adjustment|![North_West_South_East.png](./figures/North_West_South_East.png)|
| CROSS | 13 | Cross (accurate selection) |![Cross.png](./figures/Cross.png)|
| CURSOR_COPY | 14 | Copy cursor |![Copy.png](./figures/Copy.png)|
| CURSOR_FORBID | 15 | Forbid cursor |![Forbid.png](./figures/Forbid.png)|
| COLOR_SUCKER | 16 | Sucker |![Colorsucker.png](./figures/Colorsucker.png)|
| HAND_GRABBING | 17 | Grabbing hand |![Hand_Grabbing.png](./figures/Hand_Grabbing.png)|
| HAND_OPEN | 18 | Opening hand |![Hand_Open.png](./figures/Hand_Open.png)|
| HAND_POINTING | 19 | Hand-shaped pointer |![Hand_Poniting.png](./figures/Hand_Pointing.png)|
| HELP | 20 | Help |![Help.png](./figures/Help.png)|
| MOVE | 21 | Move |![Move.png](./figures/Move.png)|
| RESIZE_LEFT_RIGHT | 22 | Left and right resizing|![Resize_Left_Right.png](./figures/Resize_Left_Right.png)|
| RESIZE_UP_DOWN | 23 | Up and down resizing|![Resize_Up_Down.png](./figures/Resize_Up_Down.png)|
| SCREENSHOT_CHOOSE | 24 | Screenshot crosshair|![Screenshot_Cross.png](./figures/Screenshot_Cross.png)|
| SCREENSHOT_CURSOR | 25 | Screenshot cursor |![Screenshot_Cursor.png](./figures/Screenshot_Cursor.png)|
| TEXT_CURSOR | 26 | Text cursor |![Text_Cursor.png](./figures/Text_Cursor.png)|
| ZOOM_IN | 27 | Zoom in |![Zoom_In.png](./figures/Zoom_In.png)|
| ZOOM_OUT | 28 | Zoom out |![Zoom_Out.png](./figures/Zoom_Out.png)|
| MIDDLE_BTN_EAST | 29 | Scrolling east |![MID_Btn_East.png](./figures/MID_Btn_East.png)|
| MIDDLE_BTN_WEST | 30 | Scrolling west |![MID_Btn_West.png](./figures/MID_Btn_West.png)|
| MIDDLE_BTN_SOUTH | 31 | Scrolling south | ![MID_Btn_South.png](./figures/MID_Btn_South.png) |
| MIDDLE_BTN_NORTH | 32 | Scrolling north |![MID_Btn_North.png](./figures/MID_Btn_North.png)|
| MIDDLE_BTN_NORTH_SOUTH | 33 | Scrolling north-south |![MID_Btn_North_South.png](./figures/MID_Btn_North_South.png)|
| MIDDLE_BTN_NORTH_EAST | 34 | Scrolling north-east |![MID_Btn_North_East.png](./figures/MID_Btn_North_East.png)|
| MIDDLE_BTN_NORTH_WEST | 35 | Scrolling north-west |![MID_Btn_North_West.png](./figures/MID_Btn_North_West.png)|
| MIDDLE_BTN_SOUTH_EAST | 36 | Scrolling south-east |![MID_Btn_South_East.png](./figures/MID_Btn_South_East.png)|
| MIDDLE_BTN_SOUTH_WEST | 37 | Scrolling south-west |![MID_Btn_South_West.png](./figures/MID_Btn_South_West.png)|
| MIDDLE_BTN_NORTH_SOUTH_WEST_EAST | 38 | Moving as a cone in four directions|![MID_Btn_North_South_West_East.png](./figures/MID_Btn_North_South_West_East.png)|
# # @ohos.net.socket (Socket Connection)
The **socket** module implements data transfer over TCPSocket, UDPSocket, WebSocket, and TLSSocket connections.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册