HTTP communication response processing method and device

By using HTTP context conversion classes and state object queues in HTTP communication response processing, taking out the actual state classes and performing corresponding operations, the problem of poor flexibility in HTTP communication response processing in the prior art is solved, and stronger client program scalability and reusability are achieved.

CN120223685APending Publication Date: 2025-06-27BEIJING LUSTER LIGHTTECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510209100.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-25
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

The existing HTTP communication response processing methods have poor flexibility and cannot effectively handle various types of HTTP communication response processes, resulting in poor scalability, maintenance and readability of client programs.

Method used

The current actual state class is retrieved from the state object queue through the HTTP context conversion class, and the start state interface is called to send an HTTP communication request to the server. After receiving the server response, the state operation of the actual state class and the conversion interface are called through the HTTP context conversion class to perform state operations, realizing flexible processing of different HTTP communication response processes.

Benefits of technology

This method improves the scalability, maintenance and readability of client programs, enhances the reusability of client program code, and can handle various types of HTTP communication response processes more flexibly.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120223685A_ABST
    Figure CN120223685A_ABST
Patent Text Reader

Abstract

The invention discloses an HTTP (Hyper Text Transport Protocol) communication response processing method and device, and belongs to the technical field of computer networks. The HTTP communication response processing method comprises the following steps: under the condition that a state conversion interface of an HTTP context conversion class is called, extracting a current actual state class from a state object queue through the HTTP context conversion class; calling a starting state interface of the current actual state class through the HTTP context conversion class, and sending an HTTP communication request to a server side through the current actual state class; and under the condition that an HTTP communication response of the server side for the HTTP communication request is received, calling a state operation interface of the HTTP context conversion class, calling the state operation of the current actual state class through the HTTP context conversion class, and executing the state operation through the conversion interface. According to the HTTP communication response processing method and device provided by the invention, different communication response flows can be processed more flexibly.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the technical field of computer networks, and particularly relates to an HTTP communication response processing method and device. Background Art

[0002] HTTP (Hypertext Transfer Protocol) communication mainly includes an HTTP communication request and an HTTP communication response. Among them, the HTTP communication response is a response to an HTTP communication request. In an actual HTTP communication response, the client is used to initiate an HTTP communication request, and the server is used to respond to the received HTTP communication request and return an HTTP communication response for the HTTP communication request.

[0003] Currently, the processing methods of the client for HTTP communication responses are mainly divided into two types. The first type is that the client records the current request type when sending an HTTP communication request, and after receiving the HTTP communication response returned by the client, it judges the current message type through conditional branching and calls the response method corresponding to this type; after the response method is executed, a new HTTP communication request is sent as needed, and the server responds to the new HTTP communication request. The second type is that the client abstracts the type of the current HTTP communication request into a state type, and performs a response through the state design pattern in the traditional design pattern, encapsulates the response method into different state classes, and the state transition is completed through the state class.

[0004] In the above first method, different message types are judged through branch statements, and then the corresponding response method is called. The scalability, maintainability, and readability of the client program are poor. In the above second method, the traditional state design pattern can only process fixed state transition processes, and cannot customize the state transition process in advance, and the reusability of the state class is poor. In summary, the existing HTTP communication response processing methods have deficiencies such as poor flexibility. Summary of the Invention

[0005] This application aims to solve at least one of the technical problems existing in the prior art. For this purpose, this application proposes an HTTP communication response processing method and device, which can more flexibly process various types of HTTP communication response processes.

[0006] In a first aspect, this application provides an HTTP communication response processing method, and the method includes:

[0007] When the state transition interface of the HTTP context conversion class is called, the current actual state class is taken out from the state object queue through the HTTP context conversion class;

[0008] Call the start state interface of the current actual state class through the HTTP context conversion class, and send the current HTTP communication request in the target HTTP communication process to the server through the current actual state class;

[0009] In the case of receiving the HTTP communication response from the server for the current HTTP communication request, call the state operation interface of the HTTP context conversion class, and execute the state operation by calling the state operation and conversion interface of the current actual state class through the HTTP context conversion class.

[0010] According to the HTTP communication response processing method of the present application, the current actual state class is taken out from the state object queue through the HTTP context conversion class, and the current actual state class is called to send an HTTP communication request to the server. In the case of receiving the HTTP communication response from the server for the HTTP communication request, the current actual state class is called through the HTTP context conversion class to execute the state operation, which can handle different HTTP communication response processes more flexibly, and the scalability, maintainability and readability of the client program are stronger, and the reusability of the client program code is stronger.

[0011] According to an embodiment of the present application, before the current actual state class is taken out from the state object queue through the HTTP context conversion class when the state conversion interface of the HTTP context conversion class is called, the method further includes:

[0012] Call the HTTP context conversion class to register the state object queue into the HTTP context class; the state object queue stores each of the actual state classes in a target order; the number of the actual state classes is multiple.

[0013] According to an embodiment of the present application, after the HTTP context conversion class is called to register the state object queue into the HTTP context class, and before the current actual state class is taken out from the state object queue through the HTTP context conversion class when the state conversion interface of the HTTP context conversion class is called, the method further includes:

[0014] Initiate the first call in the target HTTP communication process to the state conversion interface of the HTTP context conversion class.

[0015] According to an embodiment of the present application, the calling the HTTP context conversion class to register the state object queue into the HTTP context class includes:

[0016] For each of the actual state classes, perform an operation of inheriting the target state interface class, so that the start state interface of the actual state class performs a start state operation when called, and the state operation and transition interface performs a state operation when called.

[0017] According to an embodiment of the present application, after calling the state operation interface of the HTTP context conversion class and performing a state operation by calling the state operation and transition interface of the current actual state class through the HTTP context conversion class, the method further includes:

[0018] After the current actual state class finishes performing the state operation, initiate a new call to the state transition interface of the HTTP context conversion class through the current actual state class.

[0019] According to an embodiment of the present application, after the current actual state class finishes performing the state operation and initiates a new call to the state transition interface of the HTTP context conversion class through the current actual state class, the method further includes:

[0020] When the state object queue is empty, end the target HTTP communication process.

[0021] In a second aspect, the present application provides an HTTP communication response processing device, which includes:

[0022] A dequeue module, configured to, when the state transition interface of the HTTP context conversion class is called, take out the current actual state class from the state object queue through the HTTP context conversion class;

[0023] A request module, configured to call the start state interface of the current actual state class through the HTTP context conversion class and send the current HTTP communication request in the target HTTP communication process to the server through the current actual state class;

[0024] A call module, configured to, when receiving the HTTP communication response from the server for the current HTTP communication request, call the state operation interface of the HTTP context conversion class and perform a state operation by calling the state operation and transition interface of the current actual state class through the HTTP context conversion class.

[0025] The HTTP communication response processing device according to the present application retrieves the current actual status class from the status object queue through an HTTP context conversion class, calls the current actual status class to send an HTTP communication request to the server, and in the case of receiving an HTTP communication response from the server for the HTTP communication request, calls the current actual status class through the HTTP context conversion class to perform a status operation, which can handle different HTTP communication response processes more flexibly, and the scalability, maintainability, and readability of the client program are stronger, and the reusability of the client program code is stronger.

[0026] In a third aspect, the present application provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where when the processor executes the computer program, the HTTP communication response processing method described in the first aspect above is implemented.

[0027] In a fourth aspect, the present application provides a non-transitory computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the HTTP communication response processing method described in the first aspect above is implemented.

[0028] In a fifth aspect, the present application provides a chip, which includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is used to run a program or an instruction to implement the HTTP communication response processing method described in the first aspect.

[0029] In a sixth aspect, the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, the HTTP communication response processing method described in the first aspect above is implemented.

[0030] The additional aspects and advantages of the present application will be partially given in the following description, partially will become obvious from the following description, or will be understood through the practice of the present application. Description of the Drawings

[0031] The above and / or additional aspects and advantages of the present application will become obvious and easy to understand from the description of the embodiments in conjunction with the following drawings, where:

[0032] Figure 1 is a flowchart of the HTTP communication response processing method provided by the embodiment of the present application;

[0033] Figure 2 is a signaling diagram of the HTTP communication response processing method provided by the embodiment of the present application;

[0034] Figure 3 is a structural diagram of the HTTP communication response processing device provided by the embodiment of the present application;

[0035] Figure 4 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners

[0036] Next, the technical solutions in the embodiments of the present application will be clearly described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art belong to the scope of protection of the present application.

[0037] Terms such as "first" and "second" in the specification and claims of the present application are used to distinguish similar objects, rather than to describe a specific order or sequence. It should be understood that such used data can be interchanged under appropriate circumstances so that the embodiments of the present application can be implemented in an order different from those illustrated or described herein, and the objects distinguished by "first", "second", etc. are usually of the same category, and the number of objects is not limited. For example, the first object can be one or multiple. In addition, "and / or" in the specification and claims means at least one of the connected objects, and the character " / " generally means an "or" relationship between the associated objects before and after.

[0038] Next, in conjunction with the accompanying drawings, the HTTP communication response processing method, the HTTP communication response processing device, the electronic device, and the readable storage medium provided by the embodiments of the present application will be described in detail through specific embodiments and their application scenarios.

[0039] Among them, the HTTP communication response processing method can be applied to a terminal, and specifically can be executed by hardware or software in the terminal.

[0040] The terminal includes, but is not limited to, portable communication devices such as mobile phones or tablet computers having a touch-sensitive surface (for example, a touch screen display and / or a touchpad). It should also be understood that in some embodiments, the terminal may not be a portable communication device, but a desktop computer having a touch-sensitive surface (for example, a touch screen display and / or a touchpad).

[0041] In the following various embodiments, a terminal including a display and a touch-sensitive surface is described. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, a mouse, and a joystick.

[0042] The HTTP communication response processing method provided by the embodiments of the present application may be executed by an electronic device or a functional module or entity in the electronic device that can implement the HTTP communication response processing method. The electronic devices mentioned in the embodiments of the present application include, but are not limited to, mobile phones, tablet computers, computers, cameras, wearable devices, etc. Hereinafter, taking the electronic device as the execution subject as an example, the HTTP communication response processing method provided by the embodiments of the present application will be described.

[0043] As Figure 1 shown, the HTTP communication response processing method includes: step 110, step 120, and step 130.

[0044] Step 110: When the status conversion interface of the HTTP context conversion class is called, retrieve the current actual status class from the status object queue through the HTTP context conversion class.

[0045] In actual execution, the HTTP communication response processing method provided by the embodiments of the present application is applied to the client. The client is the initiator of the HTTP communication request and the receiver of the HTTP communication response in the HTTP communication process. It should be noted that in the embodiments of the present application, a complete HTTP communication process may include the client sending multiple HTTP communication requests to the server and receiving the HTTP communication responses returned by the server for each HTTP communication request.

[0046] In some embodiments, the HTTP communication response processing method provided by the embodiments of the present application can be implemented through multiple types of core classes. The above multiple types of core classes may at least include the following two types: the actual status class and the HTTP context conversion class. In some embodiments, the above multiple types of core classes may also include a status interface class.

[0047] In some embodiments, the status interface class may have at least two core functions: the start status operation function and the execution status operation and conversion function. Among them, the start status operation function can be used to start the current type of status. The execution status operation and conversion function can be used to respond to the execution of the HTTP operation and convert to the next type of status after the operation is successful.

[0048] In some embodiments, the number of actual status classes is generally multiple. Each actual status class can inherit from the status interface class to implement the above two interface functions, that is, the start status operation function and the execution status operation and conversion function.

[0049] In some embodiments, the HTTP context conversion class may have at least three core functions: adding a status flow function, performing a status conversion function, and performing a status operation function. Among them, the function of adding a status flow is the key to the customization and reuse of the HTTP communication response processing flow. The HTTP context conversion class may have a queue. This queue is a status object queue, which is used to store the sequence of multi-status continuous conversions. The function of adding a status flow can be used to add different types of status objects to the status object queue. Each status object may correspond to a type of status, and the status object may be an actual status class. The function of performing a status conversion is actually to dequeue an actual status object (i.e., the actual status class) from the status object queue, and then use this status object to perform the operation of starting the current status, and the status conversion officially starts. The function of performing status operations and conversions belongs to the operation of responding to an HTTP communication request. The function of performing status operations and conversions can be used to call an interface after the client receives an HTTP communication request. For the function of performing status operations and conversions, internally, it actually calls the status conversion operation of the current actual status class, so that the operations corresponding to the status corresponding to the actual status class can be performed.

[0050] In some embodiments, the function of performing a status conversion of the HTTP context conversion class can be implemented through the status conversion interface of the HTTP context conversion class. The status conversion interface of the HTTP context conversion class can be called by a client program or an actual status class. The client program can be a program for performing HTTP communication.

[0051] When the status conversion interface of the HTTP context conversion class is called, the HTTP context conversion class can perform dequeue on the status object queue, take out the current actual status class, and can record the dequeued status object, that is, the current status. It should be noted that each actual status class is a status object, and the taken-out actual status class is not put back into the status object queue in the target HTTP communication process.

[0052] Step 120: Call the start status interface of the current actual status class through the HTTP context conversion class, and send the current HTTP communication request in the target HTTP communication process to the server through the current actual status class.

[0053] In actual execution, after the current actual status class dequeues from the status object queue, the HTTP context conversion class can call the start status interface of the actual status class, and the actual status class performs the start status operation to implement the start status operation function. During the process of the actual status class performing the start status operation, the current HTTP communication request can be sent to the server.

[0054] In some embodiments, the server can be an HTTP server, etc.

[0055] Step 130: When receiving the HTTP communication response from the server for the current HTTP communication request, call the status operation interface of the HTTP context conversion class, and through the HTTP context conversion class, call the status operation and conversion interface of the current actual status class to execute the status operation.

[0056] In actual execution, after the server receives the current HTTP communication request, it can respond to the HTTP communication request and return the HTTP communication response for the current HTTP communication request to the client. After the client receives the HTTP communication response, when the current state is being executed, it can initiate a call to the status operation interface of the HTTP context conversion class. The status operation interface of the HTTP context conversion class can be used to implement the function of executing the status operation of the HTTP context conversion class.

[0057] When the status operation interface of the HTTP context conversion class is called, the HTTP context conversion class can, according to the currently dequeued status object, call the status operation and conversion interface of its corresponding actual status class (i.e., the current actual status class). When the status operation and conversion interface of the current actual status class is called, the current actual status class can execute the status operation to confirm the result of the current HTTP communication request.

[0058] It can be understood that through the above process, the processing of the current HTTP communication request and the return of the HTTP communication response for the current HTTP communication request can be completed.

[0059] According to the HTTP communication response processing method provided by the embodiments of the present application, the current actual status class is taken out from the status object queue through the HTTP context conversion class, and the current actual status class is called to send an HTTP communication request to the server. When receiving the HTTP communication response from the server for the HTTP communication request, the current actual status class is called through the HTTP context conversion class to execute the status operation, which can process different HTTP communication response processes more flexibly, and the scalability, maintainability, and readability of the client program are stronger, and the reusability of the client program code is stronger.

[0060] In some embodiments, when the status conversion interface of the HTTP context conversion class is called, before taking out the current actual status class from the status object queue through the HTTP context conversion class, the method further includes: calling the HTTP context conversion class to register the status object queue into the HTTP context class; the status object queue stores each actual status class in a target order; the number of actual status classes is multiple.

[0061] In actual execution, before starting the target HTTP communication process, it is possible to first determine which state transitions the entire communication process needs to go through according to the actual requirements of the target HTTP communication process, and call the HTTP context conversion class to register the state object queue into the HTTP context conversion class, that is, arrange each actual state class into the state object queue in the target order.

[0062] In some embodiments, during the execution of the target HTTP communication process, it is also possible to call the HTTP context conversion class to register a new state object queue into the HTTP context conversion class, that is, place the new actual state class at the target position in the state object queue.

[0063] According to the HTTP communication response processing method provided by the embodiments of the present application, by calling the HTTP context conversion class to register the state object queue into the HTTP context class, the processes of various types of operations for the HTTP communication response can be customized, the state transition process can be customized in advance, and different HTTP communication response processes can be processed more flexibly.

[0064] In some embodiments, after calling the HTTP context conversion class to register the state object queue into the HTTP context class, and when the state transition interface of the HTTP context conversion class is called, before the current actual state class is taken out from the state object queue by the HTTP context conversion class, the method further includes: initiating the first call in the target HTTP communication process to the state transition interface of the HTTP context conversion class.

[0065] In actual execution, the first call to the state transition interface of the HTTP context conversion class in the target HTTP communication process can be initiated by the client.

[0066] In some embodiments, after determining the state object queue, the client can initiate the first call in the target HTTP communication process to the state transition interface of the HTTP context conversion class.

[0067] According to the HTTP communication response processing method provided by the embodiments of the present application, by initiating the first call in the target HTTP communication process to the state transition interface of the HTTP context conversion class by the client program after registering the state object queue into the HTTP context class, different HTTP communication response processes can be processed more flexibly, and the scalability, maintainability, and readability of the client program are stronger, and the code reusability of the client program is stronger.

[0068] In some embodiments, an HTTP context conversion class is called to register a status object queue into the HTTP context class, including: for each actual status class, performing an operation of inheriting the target status interface class, so that the start status interface of the actual status class performs a start status operation when called, and the status operation and conversion interface performs a status operation when called.

[0069] In actual execution, during the process of registering the status object queue into the HTTP context class, for each actual status class that needs to be stored in the status object queue, by inheriting the status interface class, the actual status class can have functions such as a start status operation function and a status operation and conversion function.

[0070] In some embodiments, each actual status class may have a start status interface and a status operation and conversion interface. Among them, when the start status interface of the actual status class is called, the actual status class performs a start status operation to implement the start status operation function; when the status operation and conversion interface of the actual status class is called, the actual status class performs a status operation to implement the status operation and conversion function.

[0071] According to the HTTP communication response processing method provided by the embodiments of the present application, by inheriting the core functions of the target status interface class through each actual status class, more flexible processing of different HTTP communication response processes can be achieved, and the scalability, maintainability, and readability of the client program are stronger, and the reusability of the client program code is stronger.

[0072] In some embodiments, after calling the status operation interface of the HTTP context conversion class and calling the status operation and conversion interface of the current actual status class through the HTTP context conversion class to perform a status operation, the method further includes: after the current actual status class finishes performing the status operation, initiating a new call to the status conversion interface of the HTTP context conversion class through the current actual status class.

[0073] In actual execution, after the current actual status class finishes performing the status operation, the result of the current HTTP communication request can be confirmed in the current actual status class, and a new call is initiated to the status conversion interface of the HTTP context conversion class. Through the above process, the execution cycle of the current actual status class ends, and then steps 110 to 130 can be started again. The next actual status class is taken out from the status object queue and used as the new current actual status class.

[0074] According to the HTTP communication response processing method provided by the embodiments of the present application, after the status operation of the current actual status class is completed, by initiating a new call to the status conversion interface of the HTTP context conversion class through the current actual status class, more flexible processing of different HTTP communication response processes can be achieved, and the scalability, maintainability, and readability of the client program are stronger, and the reusability of the client program code is stronger.

[0075] In some embodiments, after the status operation of the current actual status class is completed and a new call is initiated to the status conversion interface of the HTTP context conversion class through the current actual status class, the method further includes: when the status object queue is empty, ending the target HTTP communication process.

[0076] In actual execution, when the status conversion interface of the HTTP context conversion class is called by a certain actual status class, the HTTP context conversion class can determine whether the status object queue is empty.

[0077] In some embodiments, if the status object queue is not empty, then steps 110 to 130 can be executed again subsequently, and the next actual status class is taken out from the status object queue and used as the new current actual status class.

[0078] In some embodiments, if the status object queue is empty, then the target HTTP communication process is ended, and the entire target HTTP communication process is automatically completed by itself.

[0079] According to the HTTP communication response processing method provided by the embodiments of the present application, by ending the target HTTP communication process when the status object queue is empty, more flexible processing of different HTTP communication response processes can be achieved, and the scalability, maintainability, and readability of the client program are stronger, and the reusability of the client program code is stronger.

[0080] For the convenience of the above embodiments of the present application, the following combines Figure 2 to describe the execution timing in the HTTP communication response processing process. In some embodiments, as Figure 2 shown, the entire process steps of the HTTP communication response processing method are as follows:

[0081] First step, the HTTP client program determines which status conversions need to be experienced in the entire communication process according to actual needs, and calls the HTTP context conversion class to execute the process of adding statuses;

[0082] Second step, the HTTP context conversion class registers the status object queue into the HTTP context conversion class, and the status objects are queued, that is, each status object enters the status object queue in the target order;

[0083] Step 3: After the state queue is determined, the HTTP client program initiates the first state transition call to the HTTP context transition class to execute the state transition.

[0084] Step 4: The HTTP context conversion class executes the state queue dequeue for the state queue and records the state object currently dequeued, that is, the current state;

[0085] Step 5: The HTTP context conversion class calls the currently dequeued state object, and the currently dequeued state object performs the start state operation;

[0086] Step 6: During the execution of the start state operation, the current dequeued state object will eventually send an HTTP communication request to the HTTP server;

[0087] Step 7: The HTTP server sends an HTTP communication response to the HTTP client program according to the HTTP communication request;

[0088] Step 8. If the current state is successfully executed, the HTTP client program calls the state operation interface of the HTTP context conversion class;

[0089] Step 9. The HTTP context conversion class calls the execution status operation based on the currently dequeued status object recorded;

[0090] Step 10. After the operation is completed, the state object currently out of the queue initiates a state transition call to the HTTP context transition class to execute the state transition, and a cycle ends here.

[0091] Step 11. The HTTP context conversion class determines whether the state object queue is empty; if not, it goes to step 4 above and continues to perform related operations until the entire communication process is completed.

[0092] In some embodiments, assuming that the target HTTP communication process needs to execute states A, B, and C, the entire process steps of the HTTP communication response processing method can be as follows:

[0093] Step 1: The HTTP client program first creates an HTTP context conversion class and calls the queue registration interface of the HTTP context conversion class to register the state objects corresponding to states A, B, and C into the HTTP context conversion class, that is, to create the state objects corresponding to states A, B, and C and add them to the state object queue;

[0094] Step 2: The HTTP client program calls the state transition interface of the HTTP context transition class;

[0095] Step 3: The state object corresponding to state A is dequeued and marked as the current state by the HTTP context conversion class;

[0096] Step 4: The HTTP context conversion class calls the start state interface of the state object corresponding to state A. After the state object corresponding to state A completes some preparatory work before the request starts, the state object corresponding to state A will send an HTTP communication request to the HTTP server;

[0097] Step 5: After receiving the HTTP communication request, the HTTP server returns the corresponding HTTP communication response to the HTTP client program;

[0098] Step 6: The HTTP client calls the state operation interface of the HTTP context conversion class. In the state operation interface, according to the currently recorded state, the state operation and conversion interface of the state object corresponding to state A is called;

[0099] Step 7: In the state object corresponding to state A, the result of the HTTP communication request is confirmed, and the state operation interface of the HTTP context conversion class is called, and the execution cycle of state A ends.

[0100] After that, it will go back to the above Step 3, and the state object corresponding to state B dequeues and runs in a loop until the conversion of states A, B, and C ends, and the entire communication process is automatically executed and completed.

[0101] For the HTTP communication response processing method provided by the embodiments of the present application, the execution subject can be an HTTP communication response processing device. In the embodiments of the present application, taking the HTTP communication response processing device executing the HTTP communication response processing method as an example, the HTTP communication response processing device provided by the embodiments of the present application is described.

[0102] The embodiments of the present application also provide an HTTP communication response processing device. As Figure 3 shown, the HTTP communication response processing device includes: a dequeue module 310, a request module 320, and a call module 330.

[0103] The dequeue module 310 is configured to, when the state conversion interface of the HTTP context conversion class is called, retrieve the current actual state class from the state object queue through the HTTP context conversion class;

[0104] The request module 320 is configured to call the start state interface of the current actual state class through the HTTP context conversion class, and send the current HTTP communication request in the target HTTP communication process to the server through the current actual state class;

[0105] The calling module 330 is used to, when receiving an HTTP communication response from the server for the current HTTP communication request, call the status operation interface of the HTTP context conversion class, and call the status operation and conversion interface of the current actual status class through the HTTP context conversion class to perform a status operation.

[0106] According to the HTTP communication response processing device provided by an embodiment of the present application, the current actual status class is taken out from the status object queue through the HTTP context conversion class, and the current actual status class is called to send an HTTP communication request to the server. When receiving an HTTP communication response from the server for the HTTP communication request, the current actual status class is called through the HTTP context conversion class to perform a status operation, which can more flexibly process different HTTP communication response processes, and the scalability, maintainability, and readability of the client program are stronger, and the reusability of the client program code is stronger.

[0107] In some embodiments, the HTTP communication response processing device may further include:

[0108] A registration module is used to call the HTTP context conversion class to register the status object queue into the HTTP context class; the status object queue stores each actual status class in a target order; the number of actual status classes is multiple.

[0109] In some embodiments, the calling module 330 may further be used to initiate a first call in the target HTTP communication process to the status conversion interface of the HTTP context conversion class.

[0110] In some embodiments, the registration module may specifically be used to perform an operation of inheriting the target status interface class for each actual status class, so that the start status interface of the actual status class performs a start status operation when called, and the status operation and conversion interface performs a status operation when called.

[0111] In some embodiments, the calling module 330 may further be used to, after the current actual status class finishes performing a status operation, initiate a new call to the status conversion interface of the HTTP context conversion class through the current actual status class.

[0112] In some embodiments, the dequeue module 310 may further be used to end the target HTTP communication process when the status object queue is empty.

[0113] The HTTP communication response processing device in the embodiments of the present application may be an electronic device or a component in an electronic device, such as an integrated circuit or a chip. The electronic device may be a terminal or other devices other than terminals. Exemplarily, the electronic device may be a mobile phone, a tablet computer, a laptop computer, a handheld computer, a vehicle-mounted electronic device, a Mobile Internet Device (MID), an augmented reality (AR) / virtual reality (VR) device, a robot, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc. It may also be a server, a Network Attached Storage (NAS), a personal computer (PC), a television (TV), a teller machine, or a self-service machine, etc. The embodiments of the present application do not make specific limitations.

[0114] The HTTP communication response processing device in the embodiments of the present application may be a device with an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems. The embodiments of the present application do not make specific limitations.

[0115] The HTTP communication response processing device provided in the embodiments of the present application can implement Figures 1 to 2 each process implemented by the method embodiments. To avoid repetition, it will not be elaborated here.

[0116] In some embodiments, as Figure 4 shown, the embodiments of the present application further provide an electronic device 400, including a processor 410, a memory 420, and a computer program stored on the memory 420 and executable on the processor 410. When the program is executed by the processor 410, it implements each process of the above-mentioned HTTP communication response processing method embodiment and can achieve the same technical effect. To avoid repetition, it will not be elaborated here.

[0117] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.

[0118] The embodiments of the present application further provide a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements each process of the above-mentioned embodiment of the HTTP communication response processing method and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.

[0119] Wherein, the processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes computer-readable storage media, such as computer read-only memory ROM, random access memory RAM, magnetic disk or optical disc, etc.

[0120] The embodiments of the present application further provide a computer program product, including a computer program. When the computer program is executed by a processor, it implements the above-mentioned HTTP communication response processing method.

[0121] Wherein, the processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes computer-readable storage media, such as computer read-only memory ROM, random access memory RAM, magnetic disk or optical disc, etc.

[0122] The embodiments of the present application further provide a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement each process of the above-mentioned embodiment of the HTTP communication response processing method and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.

[0123] It should be understood that the chip mentioned in the embodiments of the present application may also be referred to as a system-on-chip, system chip, chip system or system-on-chip, etc.

[0124] It should be noted that in this article, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. Without more limitations, the element defined by the statement "including one..." does not exclude the existence of another identical element in the process, method, article or device including the element. In addition, it should be pointed out that the methods and devices in the embodiments of the present application are not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in a reverse order according to the functions involved. For example, the described methods may be performed in an order different from that described, and various steps may be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0125] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-described method of the embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases, the former is a better implementation. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions for causing a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present application.

[0126] The embodiments of the present application have been described above with reference to the accompanying drawings. However, the present application is not limited to the above specific embodiments. The above specific embodiments are merely illustrative and not restrictive. Under the inspiration of the present application, those of ordinary skill in the art can also make many forms without departing from the purpose of the present application and the scope protected by the claims, and all of them fall within the protection scope of the present application.

[0127] In the description of this specification, the descriptions with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples", etc. mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic descriptions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.

[0128] Although the embodiments of the present application have been shown and described, those of ordinary skill in the art can understand that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and purposes of the present application. The scope of the present application is defined by the claims and their equivalents.

Claims

1. A method for processing HTTP communication response, characterized in that: include: When the state conversion interface of the HTTP context conversion class is called, the current actual state class is taken out from the state object queue through the HTTP context conversion class; Calling the start state interface of the current actual state class through the HTTP context conversion class, and sending the current HTTP communication request in the target HTTP communication process to the server through the current actual state class; When receiving the HTTP communication response from the server to the current HTTP communication request, the state operation interface of the HTTP context conversion class is called, and the state operation and conversion interface of the current actual state class is called through the HTTP context conversion class to perform state operation.

2. The HTTP communication response processing method according to claim 1, characterized in that: In the case where the state conversion interface of the HTTP context conversion class is called, before taking out the current actual state class from the state object queue through the HTTP context conversion class, the method further includes: The HTTP context conversion class is called to register the state object queue into the HTTP context class; the state object queue stores each of the actual state classes in a target order; and the number of the actual state classes is multiple.

3. The HTTP communication response processing method according to claim 2, characterized in that: After calling the HTTP context conversion class and registering the state object queue in the HTTP context class, and before taking out the current actual state class from the state object queue through the HTTP context conversion class when the state conversion interface of the HTTP context conversion class is called, the method further includes: The first call in the target HTTP communication process is initiated to the state transfer interface of the HTTP context transfer class.

4. The HTTP communication response processing method according to claim 2, characterized in that: The calling of the HTTP context conversion class to register the state object queue in the HTTP context class includes: For each of the actual state classes, operations of the inherited target state interface class are executed, so that the start state interface of the actual state class executes the start state operation when called and the state operation and conversion interface executes the state operation when called.

5. The HTTP communication response processing method according to any one of claims 1 to 4, characterized in that: After calling the state operation interface of the HTTP context conversion class and calling the state operation and conversion interface of the current actual state class through the HTTP context conversion class to perform state operation, the method further includes: After the current actual state class finishes executing the state operation, a new call is initiated to the state conversion interface of the HTTP context conversion class through the current actual state class.

6. The HTTP communication response processing method according to claim 5, characterized in that: After the current actual state class completes the state operation, after initiating a new call to the state conversion interface of the HTTP context conversion class through the current actual state class, the method further includes: When the state object queue is empty, the target HTTP communication process is terminated.

7. An HTTP communication response processing device, characterized in that: include: A dequeue module, used for taking out the current actual state class from the state object queue through the HTTP context conversion class when the state conversion interface of the HTTP context conversion class is called; A request module, used to call the start state interface of the current actual state class through the HTTP context conversion class, and send the current HTTP communication request in the target HTTP communication process to the server through the current actual state class; The calling module is used to call the state operation interface of the HTTP context conversion class when receiving the HTTP communication response of the server to the current HTTP communication request, and call the state operation and conversion interface of the current actual state class through the HTTP context conversion class to perform state operation.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the HTTP communication response processing method as described in any one of claims 1-6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the HTTP communication response processing method as described in any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the HTTP communication response processing method as described in any one of claims 1-6 is implemented.