Client communication network, network request processing method, communication system, electronic device, and medium
By introducing the decoupling of the target underlying library and the third-party network library into the client communication network, the problem of strong dependence between the business layer and the communication network library is solved, maintenance costs are reduced, stability is improved, and business-side independence is achieved. Aware communication network library replacement.
Patent Information
- Application Number
- PCT/CN2023/111656
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-31
- Filing Date
- 2023-08-08
- Publication Date
- 2024-10-03
AI Technical Summary
There is a strong dependency between the business layer and the communication network library in the existing client communication network, which requires a large number of code modifications when replacing the communication network library, increasing maintenance costs and reducing stability.
By introducing the target underlying library, using the third-party network library to obtain custom response data, and having the business layer parse the data, the client communication implementation library and the business layer are decoupled from the third-party network library, avoiding direct dependence on the third-party network library. implementation class.
It reduces the maintenance cost of the client communication network and improves the stability, so that when replacing the third-party network library, there is no need to change the client communication implementation library and business layer, achieving an imperceptible replacement by the business side.
Smart Images

Figure CN2023111656_03102024_PF_FP_ABST
Abstract
Description
Client communication network, network request processing method, communication system, electronic equipment and medium Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a client communication network, a network request processing method, a communication system, an electronic device, and a medium. Background Art
[0002] Currently, communication between clients and servers is implemented using the client-side communication network installed on terminal devices. However, the business layer of the client-side communication network often has a strong dependency on the communication network library. Replacement of the communication network library is not always transparent to the business side. This increases the maintenance cost of the client-side communication network and reduces its stability.
[0003] Summary of the Invention
[0004] In a first aspect of an embodiment of the present disclosure, a client communication network is provided, comprising: a client communication implementation library, configured to initiate a custom network request to a target underlying library; the target underlying library, configured to utilize a third-party network library to obtain custom response data corresponding to the custom network request, wherein the third-party network library is a communication network library corresponding to the target underlying library; and a business layer, configured to parse the custom response data to obtain a data parsing result.
[0005] A second aspect of an embodiment of the present disclosure provides a network request processing method, which is applied to an electronic device, wherein the electronic device is configured with a client communication implementation library, a target underlying library and a business layer; wherein the network request processing method includes: the client communication implementation library initiates a custom network request to the target underlying library; the target underlying library uses a third-party network library to obtain custom response data corresponding to the custom network request, wherein the third-party network library is a communication network library corresponding to the target underlying library; and, the business layer parses the custom response data to obtain a data parsing result.
[0006] A third aspect of the embodiments of the present disclosure provides a communication system, including: a third-party network library and the client communication network provided by the first aspect of the embodiments of the present disclosure.
[0007] According to a fourth aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the network request processing method provided by the second aspect of the embodiment of the present disclosure.
[0008] A fifth aspect of the embodiments of the present disclosure provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the network request processing method provided by the second aspect of the embodiments of the present disclosure.
[0009] A sixth aspect of the embodiments of the present disclosure provides a computer program product, including a computer program, which implements the network request processing method provided by the second aspect of the embodiments of the present disclosure when executed by a processor.
[0010] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0012] FIG1 is a schematic diagram of a network architecture of a client communication network provided by an embodiment of the present disclosure.
[0013] FIG2 is a schematic diagram of an architecture of a target underlying library provided by an embodiment of the present disclosure.
[0014] FIG3 is a schematic diagram of the subject classification of requests provided by an embodiment of the present disclosure.
[0015] FIG4 is a schematic diagram of the expansion of the Post request body provided by an embodiment of the present disclosure.
[0016] FIG5 is a flow chart of a method for processing a network request provided by an embodiment of the present disclosure.
[0017] FIG6 is a schematic diagram of a monitoring process provided by an embodiment of the present disclosure.
[0018] FIG7 is a schematic diagram of custom exception data provided by an embodiment of the present disclosure.
[0019] FIG8 is a schematic diagram of an architecture of multiple candidate underlying libraries provided by an embodiment of the present disclosure.
[0020] FIG9 is a schematic diagram of a customized constraint method for customized network requests provided by an embodiment of the present disclosure.
[0021] FIG10 is a schematic diagram of a custom request process provided by an embodiment of the present disclosure.
[0022] FIG11 is another flowchart of a network request processing method provided by an embodiment of the present disclosure.
[0023] FIG12 is a schematic diagram of an application scenario of the network request processing method provided by an embodiment of the present disclosure.
[0024] FIG13 is a schematic structural block diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0025] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be appreciated by those skilled in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0026] Currently, communication between the client and the server is achieved based on the client communication network installed on the terminal device. The client communication network is the network architecture of the client, for example, the network architecture of the Android client.
[0027] However, there is often a strong dependency between the business layer in the relevant client communication network and the communication network library. Specifically, in the relevant client communication network, the client communication implementation library and the business layer usually interact directly with a first communication network library, so as to directly call the relevant communication interface and request sending method of the first communication network library. Then, when the first communication network library needs to be replaced, for example, when the first communication network library needs to be replaced with the second communication network library, both the client communication implementation library and the business layer need to be replaced accordingly to match the second communication network library, and it is impossible for the business party to be unaware. Since the replacement process involves a large amount of code modification, this will increase the maintenance cost of the client communication network and reduce the stability of the client communication network.
[0028] Based on this, the present disclosure provides a client communication network, which can be installed in an electronic device. The client communication network provided by the present disclosure is described below with reference to the network architecture diagram shown in FIG1 .
[0029] As shown in Figure 1, the client communication network includes: a client communication implementation library, which is configured to initiate a custom network request to a target underlying library; a target underlying library, which is configured to use a third-party network library to obtain custom response data corresponding to the custom network request, wherein the third-party network library is a communication network library corresponding to the target underlying library; and a business layer, which is configured to parse the custom response data to obtain a data parsing result.
[0030] The client communication implementation library can be used to provide an efficient, feature-rich client programming toolkit that supports the Hyper Text Transfer Protocol (Http). In the field of computer technology, it can also be called HttpClient.
[0031] In addition, please refer to Figure 2. In the embodiment of the present disclosure, the custom network request can be an abstract method defined by the business party that needs to be implemented, and can include at least one of the three subject categories. For example, the custom network request can be an asynchronous request (sendRequest), a synchronous request (performRequest), or a cancel request (cancelRequest), and the embodiment of the present disclosure does not limit this. The target underlying library is configured to inherit the implementation class in the third-party network library to process the custom network request. Among them, the third-party network library is a communication network library corresponding to the target underlying library, for example, it can be an Okhttp network library or a Cronet network library. Among them, the Okhttp network library can be implemented through the Java platform, and the Cronet network library can be implemented through the C++ platform. Therefore, the Cronet network library has cross-platform capabilities and supports mobile operating systems such as iOS and Android. In addition, the Cronet network library also supports the third-generation hypertext transfer protocol, that is, Http3.
[0032] Based on the above description, it can be understood that in the embodiments of the present disclosure, after receiving a custom network request initiated by the client communication implementation library, the target underlying library can process the custom network request by inheriting the implementation class in the third-party network library, obtain the custom response data corresponding to the custom network request, and then send the custom response data to the business layer. The business layer then parses the custom response data to obtain a data parsing result. In particular, the target underlying library can send the custom response data to the business layer via the client communication implementation library.
[0033] Using the client communication network provided by the embodiment of the present disclosure, a custom network request can be initiated to the target underlying library through the client communication implementation library therein; the target underlying library uses the third-party network library to obtain the custom response data corresponding to the custom network request and sends the custom response data to the business layer; the business layer parses the custom response data to obtain the data parsing result. In the embodiment of the present disclosure, since the target underlying library is added between the client communication implementation library and the business layer and the third-party network library, and the target underlying library can use the third-party network library to obtain the custom response data corresponding to the custom network request, this means that the client communication implementation library and the business layer do not need to pay attention to the implementation class in the third-party network library, thereby achieving decoupling between the business party and the third-party network library. In this way, even if the third-party network library needs to be replaced with another communication network library, there is no need to perform corresponding replacement processing on both the client communication implementation library and the business layer, which can achieve unawareness to the business party, thereby reducing the maintenance cost of the client communication network and improving the stability of the client communication network.
[0034] In some specific embodiments, the target underlying library can be configured to: convert the custom network request to obtain a standard network request available to the third-party network library; send the standard network request to the third-party network library, wherein the third-party network library initiates a standard network request to the server and obtains standard response data returned by the server based on the standard network request; obtain the standard response data returned by the third-party network library; and encapsulate the standard response data into custom response data corresponding to the custom network request.
[0035] In a specific example, after determining the type of the custom network request, the target underlying library can convert the custom network request according to the type of the custom network request, obtain a standard network request available to the third-party network library, and then send the standard network request to the third-party network library. The third-party network library calls the corresponding request processing logic (implementation class), initiates a standard network request to the server, obtains the standard response data returned by the server based on the standard network request, and returns the standard response data to the target underlying library. The target underlying library encapsulates the standard response data into custom response data corresponding to the custom network request.
[0036] A standard network request is a network request defined in a third-party network library. It has a corresponding implementation class in the third-party network library. The implementation class can process it, thereby realizing the processing of custom network requests.
[0037] Based on the above functions of the target underlying library, in the embodiment of the present disclosure, it is only necessary to perform a simple conversion of the custom network request through the target underlying library to obtain a standard network request available to the third-party network library. After that, the target underlying library sends the standard network request to the third-party network library to initiate a standard network request to the server through the third-party network library, obtain the standard response data returned by the server based on the standard network request, and then encapsulate the standard response data into custom response data corresponding to the custom network request. This process has simple processing logic and short time consumption, which can improve the working efficiency of the client communication network.
[0038] In some specific embodiments, the target underlying library can be specifically configured to implement the following functions to convert the custom network request to obtain a standard network request available to the third-party network library: parsing the custom network request to obtain the type of the custom network request and the data structure of the custom network request; when it is determined that the type of the custom network request belongs to a type supported by the third-party network library, determining a standard request structure in the third-party network library that corresponds to the type of the custom network request; and, based on the standard request structure, converting the data structure of the custom network request to obtain a standard network request available to the third-party network library.
[0039] In the embodiment of the present disclosure, the purpose of parsing the custom network request is to obtain the type of the custom network request and the data structure of the custom network request.
[0040] The type of the custom network request may include a subject classification and a method. In addition, as previously mentioned, in the embodiment of the present disclosure, the custom network request may include at least one of three subject classifications: an asynchronous request (sendRequest), a synchronous request (performRequest), or a cancel request (cancelRequest).
[0041] Referring to Figure 3 , each custom network request under each subject category can include at least one of the Get method (HttpGetRequest), the Post method (HttpPostRequest), or the Head method (HttpHeadRequest), and each method has abstract methods defined by the business party, such as the parameter request method (params) in the Get method (HttpGetRequest). Furthermore, it should be noted that in the disclosed embodiments, other methods can also be expanded based on actual application requirements, which will not be detailed here.
[0042] Referring to FIG. 4 , in the embodiment of the present disclosure, the request body (HttpRequestBody) of the Post method can also be expanded to support network requests with various demands, such as Form requests, file uploads, progress bar displays, etc., as described in detail in 1-3 below.
[0043] 1. The Form request body (HttpRequestFormBody) obtained by expanding the Post request body (HttpRequestBody) is used to request the sending of Key type or Value type network data. It also contains abstract methods defined by the business party, such as the method for encrypting Key type network data (encodedKey) and the method for encrypting Value type network data (encodedValue).
[0044] 2. The file upload request body (HttpRequestMultipartBody) obtained by expanding the Post request body (HttpRequestBody) is used to request file upload. It also has abstract methods defined by the business party, for example, the file upload method (okMultipartBody).
[0045] 3. The progress bar display request body (HttpRequestProgressBody) obtained by expanding the Post request body (HttpRequestBody) is used to request the display of the progress bar. The internal request body (httpRequestBody) is actually a layer-aggregated delegate (Delegate) to expand the progress bar display function. In addition, the progress bar display request body (HttpRequestProgressBody) also has abstract methods defined by the business party, such as the progress listening method (progressListener).
[0046] It is understandable that in the embodiments of the present disclosure, for the above-mentioned customized network requests of different subject categories and different methods, the target underlying library can process them by inheriting the corresponding implementation class in the third-party network library, which will not be elaborated here.
[0047] In addition, in the embodiment of the present disclosure, the data structure of the custom network request is used to represent the data composition structure of the custom network request, which will not be described in detail here.
[0048] In the embodiment of the present disclosure, after the target underlying library parses the custom network request and obtains the type of the custom network request and the data structure of the custom network request, it can determine whether the type of the custom network request belongs to a type supported by the third-party network library. When it is determined that the type of the custom network request belongs to a type supported by the third-party network library, it further determines a standard request structure in the third-party network library that corresponds to the type of the custom network request. Then, based on the standard request structure, it converts the data structure of the custom network request so that it has the same data composition structure as the standard request structure, so as to obtain a standard network request available to the third-party network library.
[0049] Based on the above functions of the target underlying library, in the disclosed embodiments, after parsing a custom network request and obtaining the type and data structure of the custom network request, if it is determined that the type of the custom network request belongs to a type supported by the third-party network library, the standard request structure corresponding to the type of the custom network request in the third-party network library can be determined. Based on the standard request structure, the data structure of the custom network request is converted to obtain a standard network request that can be used by the third-party network library. On the one hand, because this process has simple processing logic and is time-saving, it can improve the efficiency of the client communication network. On the other hand, because the third-party network library supports a large number of types, the custom network request can also have a large number of extensible types, thereby improving the availability of the client communication network.
[0050] Hereinafter, the overall process of a network request processing method applied to a client communication network provided by an embodiment of the present disclosure will be described with reference to FIG5 .
[0051] 1. The client communication implementation library initiates a custom network request to the target underlying library. Here, the custom network request is specifically an asynchronous request (sendRequest).
[0052] 2. The target underlying library uses a third-party network library to asynchronously execute the custom network request. Specifically, the target underlying library invokes the corresponding request processing logic through the third-party network library and initiates a standard network request corresponding to the custom network request to the server. The third-party network library obtains the standard response data returned by the server based on the standard network request and returns the standard response data to the target underlying library. The target underlying library then encapsulates the standard response data into the custom response data corresponding to the custom network request.
[0053] 3. The target underlying library sends the custom response data (Response) to the client communication implementation library.
[0054] 4. The client communication implementation library sends the custom response data (Response) to the business layer.
[0055] 5. The business layer parses the custom response data (Response) and obtains the data parsing result (HttpResponse).
[0056] 6. The business layer sends the data parsing results (HttpResponse) to the client communication implementation library.
[0057] 7. The client communication implementation library then sends the data parsing results (HttpResponse) to the business layer.
[0058] 8. The business layer performs callback processing on the data parsing results (HttpResponse).
[0059] In addition, it should be noted that in the embodiment of the present disclosure, when the custom network request is a synchronous request (performRequest), the above steps 2 to 5 will process the custom network request in a synchronous manner; that is, since the custom network request is specifically a synchronous request (performRequest), the business layer directly obtains the data parsing result (HttpResponse) through step 5, and there is no related process of callback processing described in steps 6, 7 and 8 above.
[0060] It can be understood that in the overall process of the above network request processing method, all classes used by the business party are customized in the client communication network, including customized network requests, customized response data, client communication implementation library, etc., and will not directly rely on classes in third-party network libraries; in addition, the process instructions for network request processing are also encapsulated in the corresponding implementation class in the target underlying library to complete all operations such as initiation, reception, processing, and distribution; finally, the encapsulated data parsing results are returned to the business layer, thereby ensuring that the business party has no perception of the third-party network library.
[0061] In some optional implementations, the target underlying library can also be configured to send a monitoring data packet to the business layer after receiving the monitoring data packet; wherein the monitoring data packet is obtained by the third-party network library by monitoring the processing process of the standard network request and sent to the target underlying library.
[0062] That is, in the disclosed embodiments, the business layer can also monitor the entire process of request processing for standard network requests based on the monitoring and processing logic (implementation class) stored in the third-party network library. For example, the business layer can monitor whether each sub-process in the request processing process is successfully processed and the processing time of each sub-process.
[0063] Each sub-process includes the Domain Name System (DNS) resolution process, the Connect process, the Secure Sockets Layer (SSL) process, and the actual request processing process. Furthermore, referring to Figure 6, after the actual request processing process, including the request start, request completion, and request failure sub-processes, is completed, the target underlying library will also carry the execution results, processing time, and other data in the monitoring data packet and uniformly call back to the business layer. Therefore, based on the monitoring data packet, the business layer can determine the success of each network request and the time taken by each sub-process.
[0064] Based on the above functions of the target underlying library, in the embodiment of the present disclosure, the target underlying library can also be configured to send the monitoring data packet to the business layer after receiving the monitoring data packet obtained by the third-party network library through monitoring the processing process of the standard network request, so that the business layer can trace the entire process of the request processing process, thereby facilitating the maintenance of the client communication network and further reducing the maintenance cost of the client communication network.
[0065] In some optional embodiments, the target underlying library can also be configured to: extract standard exception data from the monitoring data packet when the monitoring data packet carries standard exception data; convert the standard exception data into corresponding custom exception data; and send the custom exception data to the business layer by carrying the custom exception data in the monitoring data packet.
[0066] In an embodiment of the present disclosure, when a monitoring data packet carries standard exception data, the target underlying library can extract the standard exception data from the monitoring data packet and then convert the standard exception data into corresponding custom exception data. In a specific example, the target underlying library can convert the standard exception data into corresponding custom exception data based on the exception correspondence stored in the target underlying library, and the custom exception data can be defined based on a class in a Java Development Kit (JDK) development tool.
[0067] Please refer to FIG7 , in the embodiment of the present disclosure, the following multiple custom exception data are predefined.
[0068] ConnectionError: Indicates a connection error and encapsulates java.net.ConnectionException.
[0069] TimeoutError: Indicates a timeout error, encapsulating java.net.SocketTimeoutException.
[0070] ServerError: indicates a service failure returned by the server, for example, errno≠0.
[0071] CertificateError: Indicates a network request error, for example, an expired certificate. This error is thrown only when certificate monitoring is enabled.
[0072] UnknownHostError: indicates a DNS resolution error. This error is thrown only when DNS resolution monitoring is enabled.
[0073] ParseError: Indicates that an error occurred when the business layer was parsing custom response data (Response).
[0074] ResponseSchemeError: Indicates a response schema validation error. This error is thrown only when response schema validation is enabled.
[0075] The exception codes corresponding to the above-mentioned custom exception data may be shown in Table 1.
[0076] Table 1
[0077] Based on the above functions of the target underlying library, in the embodiment of the present disclosure, when the monitoring data packet carries standard exception data, the standard exception data can be extracted from the monitoring data packet, and then converted into corresponding custom exception data, without relying on the standard exception data defined in the third-party network library, thereby achieving further decoupling of the business party and the third-party network library.
[0078] In some optional embodiments, the client communication implementation library can be configured to: generate a custom network request in response to a request triggering operation; determine a target underlying library for the custom network request from multiple candidate underlying libraries based on an underlying library selection indication; and initiate a custom network request to the target underlying library.
[0079] Please refer to FIG8 . In the embodiment of the present disclosure, the client communication network may actually include multiple candidate underlying libraries, and each candidate underlying library has a corresponding communication network library.
[0080] In a specific example, the plurality of candidate underlying libraries may include a first candidate underlying library and a second candidate underlying library, wherein the communication network library corresponding to the first candidate underlying library may be an Okhttp network library, and the communication network library corresponding to the second candidate underlying library may be a Cronet network library.
[0081] In addition, in an embodiment of the present disclosure, the client communication implementation library can be further configured to determine a target underlying library with excellent processing performance for custom network requests from multiple candidate underlying libraries. Having excellent processing performance for custom network requests can be having a faster processing speed for custom network requests.
[0082] Based on the above functions of the client communication implementation library, in an embodiment of the present disclosure, after the client communication implementation library responds to the request trigger operation and generates a custom network request, it can determine a target underlying library with excellent processing performance for the custom network request from multiple candidate underlying libraries according to the underlying library selection indication, and initiate a custom network request to the target underlying library, thereby improving the working efficiency of the client communication network. Compared with the solution of randomly selecting the target underlying library from multiple candidate underlying libraries, the network request processing efficiency of the client communication network can be improved by more than 20%.
[0083] In the embodiment of the present disclosure, the bottom layer library selection indication can be generated by the business layer. Based on this, in some optional implementations, the business layer can also be configured to: when monitoring the generation of a custom network request, obtain historical request processing records related to the custom network request; based on the historical request processing records, determine a target bottom layer library with excellent (optimal) processing performance for the custom network request from multiple candidate bottom layers; wherein the optimal processing performance includes a processing speed that is not less than a set speed threshold; based on the identification information of the target bottom layer library, generate a bottom layer library selection indication; and send the bottom layer library selection indication to the client communication implementation library.
[0084] The historical request processing records store historical processing data of other network requests of the same type as the custom network request. Based on these historical processing data, the business layer can determine a target underlying library with excellent processing performance for the custom network request from multiple candidate underlying libraries. For example, the historical processing data shows that its processing speed for other network requests of the same type as the custom network request is not less than the set speed threshold and / or is a candidate underlying library that ranks high among all candidate underlying libraries. Then, based on the identification information of the target underlying library, the business layer generates an underlying library selection indication and sends the underlying library selection indication to the client communication implementation library.
[0085] Based on the above functions of the business layer, in the embodiments of the present disclosure, a target underlying library with excellent processing performance for custom network requests can be determined from multiple candidate underlying libraries based on historical request processing records related to the custom network requests. Since the historical request processing records are obtained based on the actual network request processing process within the historical period, determining the target underlying library with excellent processing performance for custom network requests from multiple candidate underlying libraries based on the historical request processing records can improve the reliability of the determined target underlying library, thereby ensuring that the working efficiency of the client communication network can be truly and reliably improved.
[0086] In addition, in the embodiment of the present disclosure, the multiple candidate underlying libraries may include a target candidate underlying library, wherein the communication network library corresponding to the target candidate underlying library supports Http3.
[0087] In a specific example, the target candidate underlying library may be the aforementioned second candidate underlying library, and its corresponding communication network library is the Cronet network library, which can support Http3.
[0088] Since Http3 has the characteristics of high speed, high security, and weak network stability, the target candidate underlying library whose corresponding communication network library supports Http3 is included in multiple candidate underlying libraries, so that the target candidate underlying library that supports Http3 can be selected as the target underlying library, which can further improve the stability of the client communication network.
[0089] 9 , in the embodiment of the present disclosure, a custom network request may be custom constrained by a preset custom specification.
[0090] The preset custom specification can at least set custom constraints on the data structure of custom network requests of the same type, so that the same custom network request can be universally used in multiple candidate underlying libraries. In addition, in the embodiment of the present disclosure, custom constraints can also be set on custom response data, custom exception data, etc. through the preset custom specification.
[0091] Since custom network requests are custom constrained by preset custom specifications, the same type of custom network requests can be universally used in multiple candidate underlying libraries (for example, the first candidate underlying library and the second candidate underlying library in Figure 9), which can facilitate the addition and modification of candidate underlying libraries, thereby increasing the flexibility of the client communication network.
[0092] In addition, please refer to Figure 10. In the embodiment of the present disclosure, when the client starts running or after the client starts running, the client communication implementation library can also be initialized, for example, the client version number, client channel, etc. can be configured. In addition, the network function configuration of the client communication network can also be performed, for example, whether to turn on the monitoring function to monitor the processing of the network request. Thereafter, the client communication implementation library generates a custom network request based on the preset custom specification, and initiates a custom network request to the target underlying library. In addition, the client communication implementation library sends various configuration information to the target underlying library; the target underlying library adjusts the custom network request according to these configuration information, and uses the third-party network library to obtain the custom response data corresponding to the custom network request, and sends the custom response data to the business layer; the business layer parses the custom response data to obtain the data parsing result.
[0093] After obtaining the data parsing results, you can continue to initiate the next custom network request.
[0094] The client may be a web browser used for the World Wide Web, an email client for sending and receiving emails, and / or an instant messaging client software, etc., and the embodiments of the present disclosure do not impose specific limitations on this.
[0095] An embodiment of the present disclosure provides a network request processing method, which can be applied to an electronic device, and the electronic device can be configured with the above-mentioned client communication network. Below, the network request processing method provided by the embodiment of the present disclosure will be described in conjunction with the flow chart shown in Figure 11. It should be noted that although a logical order is shown in the flow chart, in some cases, the steps shown or described can also be performed in other orders. As shown in Figure 11, the network request processing method includes S1101, S1102 and S1103.
[0096] In S1101 , the client communication implementation library initiates a custom network request to the target underlying library.
[0097] In S1102 , the target underlying library uses a third-party network library to obtain custom response data corresponding to the custom network request, wherein the third-party network library is a communication network library corresponding to the target underlying library.
[0098] In S1103 , the business layer parses the custom response data to obtain a data parsing result.
[0099] In some optional implementations, the target underlying library uses a third-party network library to obtain custom response data corresponding to the custom network request, which may include: converting the custom network request to obtain a standard network request available to the third-party network library; sending the standard network request to the third-party network library so that the third-party network library initiates a standard network request to the server and obtains standard response data returned by the server based on the standard network request; obtaining the standard response data returned by the third-party network library; and encapsulating the standard response data into custom response data corresponding to the custom network request.
[0100] In some optional implementations, the target underlying library converts the custom network request to obtain a standard network request available to the third-party network library, which may include: parsing the custom network request to obtain the type of the custom network request and the data structure of the custom network request; when it is determined that the type of the custom network request belongs to a supportable type of the third-party network library, determining a standard request structure in the third-party network library that corresponds to the type of the custom network request; and, based on the standard request structure, converting the data structure of the custom network request to obtain a standard network request available to the third-party network library.
[0101] In some optional implementations, the network request processing method may further include: after receiving the monitoring data packet, the target underlying library sends the monitoring data packet to the business layer; wherein, the monitoring data packet is obtained by the third-party network library by monitoring the processing process of the standard network request and sent to the target underlying library.
[0102] In some optional implementations, the target underlying library sends the monitoring data packet to the business layer, which may include: extracting the standard exception data from the monitoring data packet when the monitoring data packet carries standard exception data; converting the standard exception data into corresponding custom exception data; and sending the custom exception data to the business layer by carrying the custom exception data in the monitoring data packet.
[0103] In some optional implementations, the client communication implementation library initiates a custom network request to the target underlying library, which may include: generating a custom network request in response to a request triggering operation; determining a target underlying library for the custom network request from multiple candidate underlying libraries based on an underlying library selection indication; and initiating a custom network request to the target underlying library.
[0104] In some optional implementations, the network request processing method may further include: when the business layer monitors the generation of a custom network request, obtaining historical request processing records related to the custom network request; the business layer determines, based on the historical request processing records, a target underlying library with optimal processing performance for the custom network request from multiple candidate underlying libraries; wherein the optimal processing performance includes a processing speed that is not less than a set speed threshold; the business layer generates an underlying library selection indication based on the identification information of the target underlying library; and the business layer sends the underlying library selection indication to the client communication implementation library.
[0105] In some optional implementations, the plurality of candidate underlying libraries may include a target candidate underlying library, wherein the communication network library corresponding to the target candidate underlying library supports the third generation hypertext transfer protocol.
[0106] In some optional implementations, the custom network request is custom constrained by pre-set custom specifications.
[0107] In addition, in the embodiment of the present disclosure, the specific implementation of the above steps can be referred to the previous client communication network embodiment, and will not be repeated here.
[0108] According to the network request processing method provided by the embodiment of the present disclosure, a custom network request can be initiated to a target underlying library through a client communication implementation library; the target underlying library uses a third-party network library to obtain custom response data corresponding to the custom network request, wherein the third-party network library is a communication network library corresponding to the target underlying library; the business layer parses the custom response data to obtain a data parsing result; because the target underlying library is added between the client communication implementation library and the business layer and the third-party network library, and the target underlying library can use the third-party network library to obtain the custom response data corresponding to the custom network request, the client communication implementation library and the business layer do not need to pay attention to the implementation class in the third-party network library, thereby achieving decoupling between the business party and the third-party network library. In this way, even if the third-party network library needs to be replaced with another communication network library, there is no need to perform corresponding replacement processing on both the client communication implementation library and the business layer, which can achieve unawareness to the business party, thereby reducing the maintenance cost of the client communication network and improving the stability of the client communication network.
[0109] Please refer to FIG12 , which is a schematic diagram of an application scenario of the network request processing method provided by an embodiment of the present disclosure.
[0110] As previously mentioned, the network request processing method provided in the embodiments of the present disclosure is applied to a client communication network, which can be implemented in an electronic device. The electronic device is intended to represent various forms of digital computers, such as mainframe computers, desktop computers, laptop computers, or other suitable terminal devices.
[0111] In an embodiment of the present disclosure, the electronic device can be configured to execute a network request processing method, including: the client communication implementation library initiates a custom network request to the target underlying library; the target underlying library uses a third-party network library to obtain custom response data corresponding to the custom network request, wherein the third-party network library is a communication network library corresponding to the target underlying library; and the business layer parses the custom response data to obtain a data parsing result.
[0112] It should be noted that, in an embodiment of the present disclosure, the target underlying library uses a third-party network library to obtain custom response data corresponding to the custom network request, which may include: converting the custom network request to obtain a standard network request available to the third-party network library; sending the standard network request to the third-party network library, so that the third-party network library initiates a standard network request to the server and obtains standard response data returned by the server based on the standard network request; obtaining the standard response data returned by the third-party network library; and encapsulating the standard response data into custom response data corresponding to the custom network request.
[0113] In addition, it should be noted that in the embodiment of the present disclosure, the scene diagram shown in Figure 12 is only illustrative and not restrictive. Those skilled in the art can make various obvious changes and / or replacements based on the example of Figure 12, and the obtained technical solutions still fall within the scope of the disclosure of the embodiment of the present disclosure.
[0114] In the technical solutions disclosed herein, the acquisition, storage, and application of user personal information involved comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0115] According to an embodiment of the present disclosure, the present disclosure also provides a communication system, an electronic device, a storage medium, and a computer program product.
[0116] In the disclosed embodiment, the communication system includes: a third-party network library and the client communication network provided in the disclosed embodiment. The specific implementation of the client communication network and the third-party network library in the disclosed embodiment can be found in the previous client communication network embodiment and the network request processing method embodiment, and will not be repeated here.
[0117] FIG13 shows a schematic block diagram of an example electronic device 1300 that can be used to implement embodiments of the present disclosure.
[0118] As previously mentioned, in the embodiments of the present disclosure, electronic devices are intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. Electronic devices can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0119] As shown in FIG13 , the electronic device 1300 includes a computing unit 1301, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1302 or a computer program loaded from a storage unit 1308 into a random access memory (RAM) 1303. Various programs and data required for the operation of the electronic device 1300 can also be stored in the RAM 1303. The computing unit 1301, the ROM 1302, and the RAM 1303 are connected to each other via a bus 1304. An input / output (I / O) interface 1305 is also connected to the bus 1304.
[0120] Multiple components in the electronic device 1300 are connected to the I / O interface 1305, including an input unit 1306, such as a keyboard, a mouse, etc.; an output unit 1307, such as various types of displays, speakers, etc.; a storage unit 1308, such as a magnetic disk, an optical disk, etc.; and a communication unit 1309, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1309 allows the electronic device 1300 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0121] The computing unit 1301 can be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1301 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The computing unit 1301 executes the various methods described above, for example, the network request processing method. For example, in some optional embodiments, the network request processing method can be implemented as a computer software program, which is tangibly contained in a non-transitory computer-readable storage medium, such as a storage unit 1308. In some optional embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 1300 via the ROM 1302 and / or the communication unit 1309. When the computer program is loaded into RAM 1303 and executed by the computing unit 1301, one or more steps of the network request processing method described above may be performed. Alternatively, in other embodiments, the computing unit 1301 may be configured to perform the network request processing method in any other appropriate manner (e.g., by means of firmware).
[0122] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0123] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0124] In the context of the present disclosure, a non-transient computer-readable storage medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or apparatus. A non-transient computer-readable storage medium may be a machine-readable signal medium or a machine-readable storage medium. A non-transient computer-readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or apparatus, or any suitable combination of the foregoing. More specific examples of non-transient computer-readable storage media may include an electrical connection based on one or more wires, a portable computer disk, a hard disk, RAM, ROM, an erasable programmable read-only memory (EPROM) or flash memory, an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0125] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a cathode ray tube (CRT) display or a liquid crystal display (LCD)) configured to display information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be configured to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0126] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.
[0127] A computer system may include a client and a server. The client and server are generally remote from each other and typically interact through a communication network. The client-server relationship arises from computer programs running on the respective computers and having a client-server relationship with each other. The server may be a cloud server, a server in a distributed system, or a server integrated with a blockchain.
[0128] The embodiment of the present disclosure further provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the aforementioned network request processing method.
[0129] The embodiments of the present disclosure further provide a computer program product, including a computer program, which implements the aforementioned network request processing method when executed by a processor.
[0130] The communication system, electronic device, medium, and computer program product provided by the embodiments of the present disclosure can initiate a custom network request to a target underlying library through a client communication implementation library; the target underlying library uses a third-party network library to obtain custom response data corresponding to the custom network request, wherein the third-party network library is a communication network library corresponding to the target underlying library; and the business layer parses the custom response data to obtain a data parsing result. In the embodiments of the present disclosure, since the target underlying library is added between the client communication implementation library and the business layer and the third-party network library, the target underlying library can use the third-party network library to obtain the custom response data corresponding to the custom network request. This eliminates the need for the client communication implementation library and the business layer to be aware of the implementation class in the third-party network library, thereby achieving decoupling between the business party and the third-party network library. In this way, even if the third-party network library needs to be replaced with another communication network library, there is no need to replace the client communication implementation library and the business layer accordingly, which can achieve unawareness for the business party, thereby reducing the maintenance cost of the client communication network and improving the stability of the client communication network.
[0131] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document is not limited here. In addition, in this disclosure, relational terms such as "first", "second", "third", etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Furthermore, "multiple" in this disclosure can be understood as at least two.
[0132] The foregoing specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.
Claims
1. A client communication network, comprising: The client communication implementation library is configured to initiate custom network requests to the target underlying library; The target underlying library is configured to use a third-party network library to obtain custom response data corresponding to the custom network request; wherein the third-party network library is a communication network library corresponding to the target underlying library; as well as The business layer is configured to parse the custom response data to obtain a data parsing result.
2. The communication network according to claim 1, wherein: The target underlying libraries are configured as: Convert the custom network request to obtain a standard network request available to the third-party network library; Sending the standard network request to the third-party network library, so that the third-party network library initiates the standard network request to the server and obtains standard response data returned by the server based on the standard network request; Obtaining the standard response data returned by the third-party network library; Encapsulating the standard response data into the custom response data corresponding to the custom network request; as well as The custom response data is sent to the business layer.
3. The communication network according to claim 2, wherein: The target underlying libraries are configured as: Parsing the custom network request to obtain the type of the custom network request and the data structure of the custom network request; In the case where it is determined that the type of the custom network request belongs to a type that can be supported by the third-party network library, determining a standard request structure in the third-party network library that corresponds to the type of the custom network request; as well as According to the standard request structure, the data structure of the custom network request is converted to obtain the standard network request available to the third-party network library.
4. The communication network according to claim 2, wherein the target underlying library is further configured as: After receiving the monitoring data packet, sending the monitoring data packet to the service layer; in, The monitoring data packet is obtained by the third-party network library through monitoring the processing process of the standard network request and sent to the target underlying library.
5. The communication network according to claim 4, wherein: The target underlying library is also configured as: In the case where the monitoring data packet carries standard abnormal data, extracting the standard abnormal data from the monitoring data packet; Convert the standard exception data into corresponding custom exception data; as well as By carrying the custom exception data in the monitoring data packet, the custom exception data is sent to the business layer.
6. The communication network according to claim 1, wherein: The client communication implementation library is configured as: In response to the request triggering operation, generating the custom network request; Determining the target underlying library for the custom network request from a plurality of candidate underlying libraries according to an underlying library selection indication; and Initiate the custom network request to the target underlying library.
7. The communication network according to claim 6, wherein the service layer is further configured as: When the generation of the custom network request is monitored, obtaining a historical request processing record related to the custom network request; According to the historical request processing records, the target underlying library having the best processing performance for the custom network request is determined from the multiple candidate underlying libraries; wherein, Optimal processing performance includes a processing speed not less than a set speed threshold; Based on the identification information of the target underlying library, generating the underlying library selection instruction; and The bottom layer library selection indication is sent to the client communication implementation library.
8. The communication network according to claim 6, wherein: The multiple candidate underlying libraries include a target candidate underlying library, wherein the communication network library corresponding to the target candidate underlying library supports the third generation hypertext transfer protocol.
9. The communication network according to any one of claims 1 to 8, wherein: The custom network request is custom constrained by a preset custom specification.
10. A network request processing method, applied to an electronic device, wherein the electronic device is configured with a client communication implementation library, a target underlying library and a business layer; wherein: The method comprises: The client communication implementation library initiates a custom network request to the target underlying library; The target underlying library uses a third-party network library to obtain custom response data corresponding to the custom network request; wherein the third-party network library is a communication network library corresponding to the target underlying library; and The business layer parses the custom response data to obtain a data parsing result.
11. The method according to claim 10, wherein: The target underlying library uses the third-party network library to obtain the custom response data corresponding to the custom network request, including: The target underlying library converts the custom network request to obtain a standard network request available to the third-party network library; The target underlying library sends the standard network request to the third-party network library, so that the third-party network library initiates the standard network request to the server and obtains standard response data returned by the server based on the standard network request; The target underlying library obtains the standard response data returned by the third-party network library; and The target underlying library encapsulates the standard response data into the custom response data corresponding to the custom network request.
12. The method according to claim 11, wherein: The target underlying library converts the custom network request to obtain the standard network request available to the third-party network library, including: The target underlying library parses the custom network request to obtain the type of the custom network request and the data structure of the custom network request; When the target underlying library determines that the type of the custom network request belongs to a type that can be supported by the third-party network library, determining a standard request structure in the third-party network library that corresponds to the type of the custom network request; and The target underlying library converts the data structure of the custom network request according to the standard request structure to obtain the standard network request available to the third-party network library.
13. The method according to claim 11, further comprising: After receiving the monitoring data packet, the target underlying library sends the monitoring data packet to the business layer; The monitoring data packet is obtained by the third-party network library through monitoring the processing process of the standard network request and sent to the target underlying library.
14. The method according to claim 13, wherein: The target underlying library sends the monitoring data packet to the business layer, including: When the monitoring data packet carries standard abnormal data, the target underlying library extracts the standard abnormal data from the monitoring data packet; The target underlying library converts the standard exception data into corresponding custom exception data; and The target underlying library sends the custom exception data to the business layer by carrying the custom exception data in the monitoring data packet.
15. The method according to claim 10, wherein: The client communication implementation library initiates the custom network request to the target underlying library, including: The client communication implementation library generates the custom network request in response to the request triggering operation; The client communication implementation library determines the target underlying library for the custom network request from a plurality of candidate underlying libraries according to the underlying library selection indication; and The client communication implementation library initiates the custom network request to the target underlying library.
16. The method according to claim 15, further comprising: When the business layer monitors the generation of the custom network request, it obtains the historical request processing record related to the custom network request; The business layer determines, according to the historical request processing records, the target underlying library having the best processing performance for the custom network request from the multiple candidate underlying libraries; wherein the best processing performance includes a processing speed not less than a set speed threshold; The business layer generates the bottom layer library selection indication based on the identification information of the target bottom layer library; and The business layer sends the bottom layer library selection instruction to the client communication implementation Library.
17. The method according to claim 15, wherein: The multiple candidate underlying libraries include a target candidate underlying library, wherein the communication network library corresponding to the target candidate underlying library supports the third generation hypertext transfer protocol.
18. The method according to any one of claims 10 to 17, wherein: The custom network request is custom constrained by a preset custom specification.
19. A communication system comprising: A third-party network library, and a client communication network according to any one of claims 1 to 9.
20. An electronic device, comprising: at least one processor; as well as a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method according to any one of claims 10 to 18.
21. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to make a computer execute the method according to any one of claims 10 to 18.
22. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 10 to 18.
Citation Information
Patent Citations
Network request method and device based on OKHttp and GSON
CN105681394A
Network request proxy tool and proxy method for Android system
CN107071017A
Realization method of network request framework with self-defined compatibility
CN107748660A
Network data transmission method, device and system for iOS based on static library
CN113946614A
Client communication network, network request processing method, electronic equipment and medium
CN116471265A
