Remote Communication Kit provides the following network data request functions:
HTTP request capability: Remote Communication Kit offers a scenario-based HTTP communication capability. Compared with the HTTP request capability of Network Kit, Remote Communication Kit provides scenario-based APIs that are easier to employ, as described in Supported HTTP Network Request Scenarios. You can select the kit that better suits your needs.
Unified Remote Procedure Call (URPC): a high-performance RPC communication library. It is designed for implementing robust remote function calls and features resilience against weak network conditions and support for multi-path transmission (cellular network and Wi-Fi). You can complete remote procedure calls through the URPC with greater ease.
HTTP is short for Hypertext Transfer Protocol, which is a protocol used to transmit data between a client and a server. It operates on a client-server model where the client initiates requests and the server returns responses.
An HTTP request is a client-initiated message to a server, involving the following basic parts:
Request method: method used by the client to send a request to the server, such as GET, POST, PUT, DELETE, OPTIONS, HEAD, and PATCH.
Uniform Resource Locator (URL): specifies the address of the resource to be accessed.
Request header: contains additional information, such as the request source, client browser type, language, and character set.
Request body: contains data sent from the client to the server, such as form data.
HTTP version: version number of the HTTP protocol, for example, HTTP/1.1 and HTTP/2.
Status code: code returned by the server in response to a request. For example, 200 indicates success and 404 indicates that the requested resource does not exist.
Response header: contains additional information, such as the server type, response date, and content type.
Response body: contains the data returned by the server to the client, such as HTML and JSON data.
| Request Method | Description |
|---|---|
| GET | Requests specific resources. Common scenario: obtaining resources such as webpages, images, and videos. |
| POST | Submits resources, which are usually forms. Common scenario: submitting data, such as form data and files. |
| OPTIONS | Obtains HTTP methods that a resource supports. Common scenario: obtaining the HTTP methods supported by a resource, for example, the request methods of an API. |
| HEAD | Obtains the resource metadata, which functions similarly as the GET request, except that this method returns only metadata such as the response header. Common scenario: obtaining resource header information, such as the file size and modification time. |
| PUT | Updates a resource that already exists on the server by completely replacing the resource at the specified path. Common scenario: updating a resource, such as modifying a file or database record. |
| DELETE | Deletes a specified resource. Common scenario: deleting resources such as users and articles. |
| PATCH | Updates a part of a resource. Common scenario: updating only a part of a specified resource on the server, for example, updating only some attributes and fields of a resource. This method does not replace the entire resource. |
| Scenario | Description | Remarks |
|---|---|---|
| Sending PATCH requests | Sends requests in PATCH mode. | - |
| Setting the base URL of a session | Prepends the base URL to the URL automatically in a session, unless the URL is an absolute one. | - |
| Canceling automatic redirection | Cancels automatic redirection of HTTP requests. | - |
| Intercepting requests/responses | Intercepts outgoing requests or incoming responses. | - |
| Canceling requests | Cancels a request before it is sent, when it is being sent, or after it is received. | - |
| Caching responses | Caches responses and preferentially reads from the cache during a request. | The cache function takes effect when the corresponding process is started. The new cached data will replace the existing cached data. |
| Setting the response data type | Sets the type in which data is returned, including string, object, and ArrayBuffer. | By default, the response body type is ArrayBuffer. The caller can retrieve data as an object or string by using the toJSON or toString methods of Response. |
| Customizing certificate verification | Customizes the logic of verifying client and server certificates for connection. | - |
| Skipping SSL verification | Skips SSL certificate verification for the server during SSL connection setup. | - |
| Customizing DNS resolution | Customizes a DNS server or configures static DNS rules. | - |
| Capturing detailed tracing information | Captures detailed tracing information in HTTP requests. This helps perform debugging, analyze performance, and gain insight into data flows during communication. | - |
| Obtaining time-related information of HTTP requests | Obtains the time-related information in each phase of an HTTP request. | - |
This kit supports phones, 2-in-1 devices, tablets, and wearables. Starting from version 5.1.1(19), it is also supported on TVs, while it is temporarily unavailable for lite wearables.
This kit supports the Emulator, but there are some differences in feature support between real devices and the Emulator:
General differences: For details, please refer to Differences Between the Emulator and the Real Device.
The Emulator does not support URPC.