Message analysis method and device, equipment and storage medium
By automatically determining the response message type on the client side and selecting an appropriate parsing strategy, the problem of parsing when the server's return type does not conform to the pre-agreed terms is solved, achieving fast and accurate message parsing.
Patent Information
- Application Number
- CN202411142691.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-20
- Publication Date
- 2024-11-22
AI Technical Summary
In existing technologies, when the MIME type returned by the server does not conform to the pre-agreed terms, the client cannot obtain a valid result when parsing the message, requiring an additional parsing process, which results in slow parsing speed.
After receiving the response message, the client searches for the content type information in the header information to determine whether it conforms to the expected response message type pattern. If it does, the client determines the parsing strategy based on the type. If it does not, the client uses the preset format to determine the parsing strategy to ensure accurate parsing of the target resource.
By automatically determining the response message type and selecting an appropriate parsing strategy, message parsing errors are reduced, and parsing speed and efficiency are improved.
Smart Images

Figure CN119011703A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of message processing technology, and in particular to a message parsing method, device, equipment and storage medium. Background Art
[0002] When receiving a Fetch response message returned by a server, the client usually agrees in advance on the MIME (Multipurpose Internet Mail Extensions) type of the message returned by the server, that is, the message content type, and then parses the message according to the agreed message content type. However, when the MIME type returned by the server does not conform to the pre-agreed agreement due to an abnormal situation, if the client parses the message according to the originally agreed message content type, it can only obtain an invalid parsing result, and an additional message parsing process is required. Therefore, a message parsing method is urgently needed to optimize the existing message parsing process and improve the message parsing speed. Summary of the invention
[0003] In view of the fact that currently when the MIME type returned by the server does not conform to the pre-agreed agreement due to abnormal circumstances, if the client parses the message according to the originally agreed message content type, it can only obtain an invalid parsing result and needs to perform an additional message parsing process, this solution is proposed to overcome the above problem or at least partially solve the above problem.
[0004] On the one hand, an object of some embodiments of this specification is to provide a message parsing method, the method comprising:
[0005] Receive a response message corresponding to the request message for the target resource;
[0006] Searching for content type information from the header information of the response message;
[0007] Determining whether the response message conforms to the expected response message type paradigm according to the content type information;
[0008] If the response message conforms to the expected response message type paradigm, determining a corresponding message parsing strategy according to the expected response message type conformed by the response message;
[0009] If the response message does not conform to the expected response message type paradigm, a corresponding message parsing strategy is determined using a preset response format;
[0010] The response message is parsed using the message parsing strategy to obtain the target resource.
[0011] Furthermore, the request message and the response message are transmitted between the client and the server through Fetch communication technology.
[0012] Further, searching for content type information from the header information of the response message includes:
[0013] Obtaining a content type field value from the header information;
[0014] The content type field value is used as the content type information.
[0015] Further, judging whether the response message conforms to an expected response message type paradigm according to the content type information includes:
[0016] Determine whether the content type information is ambiguous, and obtain a first determination result;
[0017] Using character matching, determining whether the content type information meets a preset matching condition, and obtaining a second determination result;
[0018] According to the first judgment result and the second judgment result, it is determined whether the response message conforms to the expected response message type paradigm.
[0019] Furthermore, character matching is used to determine whether the content type information meets a preset matching condition, and a second determination result is obtained, including:
[0020] By using character matching, the content type information is matched with the basic type paradigm included in the preset matching condition to obtain a matching result;
[0021] If the matching result is not empty, the content type information meets the preset matching condition;
[0022] If the matching result is empty, the content type information does not meet the preset matching condition.
[0023] Furthermore, a basic type matching the content type information is used as an expected response message type that the response message complies with.
[0024] Further, judging whether the response message conforms to an expected response message type paradigm according to the first judgment result and the second judgment result includes:
[0025] If the content type information is ambiguous, or the content type information does not meet the preset matching condition, then the response message does not meet the expected response message type paradigm;
[0026] If the content type information is not ambiguous and the content type information satisfies a preset matching condition, then the response message complies with the expected response message type paradigm.
[0027] On the other hand, some embodiments of this specification further provide a message parsing device, the device comprising:
[0028] A receiving module, used to receive a response message corresponding to a request message for a target resource;
[0029] A search module, used to search for content type information from the header information of the response message;
[0030] A judging module, used for judging whether the response message conforms to the expected response message type paradigm according to the content type information;
[0031] A matching module, configured to determine a corresponding message parsing strategy according to the expected response message type that the response message conforms to if the response message conforms to the expected response message type paradigm;
[0032] A determination module, configured to determine a corresponding message parsing strategy using a preset response format if the response message does not conform to an expected response message type paradigm;
[0033] A parsing module is used to parse the response message using the message parsing strategy to obtain the target resource.
[0034] On the other hand, some embodiments of the present specification further provide a computer device, including a memory, a processor, and a computer program stored in the memory, wherein when the computer program is executed by the processor, the instructions of the above method are executed.
[0035] On the other hand, some embodiments of the present specification further provide a computer storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor of a computer device, the instructions of the above method are executed.
[0036] On the other hand, some embodiments of the present specification further provide a computer program product, wherein the computer program product includes a computer program, and when the computer program is executed by a processor of a computer device, the instructions of the above method are executed.
[0037] One or more technical solutions provided by some embodiments of this specification have at least the following technical effects:
[0038] In the embodiments of the present specification, after the client sends a request message for obtaining a target resource, it automatically obtains a response message corresponding to the request message, and searches for content type information from the header information in the response message to analyze and determine whether the response message conforms to the expected response message type paradigm. If it conforms to the expected response message type paradigm, a corresponding message parsing strategy is determined based on the expected response message type that the response message conforms to. If the response message does not conform to the expected response message type paradigm, a corresponding message parsing strategy is determined using a preset response format. Therefore, regardless of whether the response message conforms to the expected response message type paradigm or does not conform to the expected response message type paradigm, an accurate message parsing strategy for the response message can be obtained, and the response message is parsed using the message parsing strategy to obtain the target resource, thereby reducing the occurrence of message parsing errors and improving the message parsing speed.
[0039] The above description is only an overview of the technical solutions of some embodiments of this specification. In order to more clearly understand the technical means of some embodiments of this specification, they can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of some embodiments of this specification more obvious and easy to understand, the specific implementation methods of some embodiments of this specification are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate some embodiments of this specification or technical solutions in the prior art, the following briefly introduces the drawings required for the embodiments or prior art descriptions. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. In the drawings:
[0041] Figure 1 A schematic diagram of an implementation system of a message parsing method in some embodiments of this specification is shown;
[0042] Figure 2 A flowchart of a message parsing method in some embodiments of this specification is shown;
[0043] Figure 3 A schematic diagram of the steps of searching for content type information from the header information of the response message in some embodiments of this specification;
[0044] Figure 4 A schematic diagram of the steps of determining whether the response message conforms to the expected response message type paradigm according to the content type information in some embodiments of this specification;
[0045] Figure 5A detailed flow chart of determining a corresponding message parsing strategy according to whether a response message conforms to an expected response message type paradigm in some embodiments of this specification;
[0046] Figure 6 This is a structural schematic diagram of a message parsing device in some embodiments of this specification;
[0047] Figure 7 This is a schematic diagram of the computer device structure provided in some embodiments of this specification.
[0048] [Description of Reference Numerals]
[0049] 101. Client;
[0050] 102. Server;
[0051] 601, receiving module;
[0052] 602. Search module;
[0053] 603, judgment module;
[0054] 604, matching module;
[0055] 605. Determine module;
[0056] 606. Parsing module;
[0057] 702. Computer equipment;
[0058] 704, processor;
[0059] 706. Memory;
[0060] 708, driving mechanism;
[0061] 710, input / output interface;
[0062] 712. Input devices;
[0063] 714. Output devices;
[0064] 716. Presentation equipment;
[0065] 718. Graphical user interface;
[0066] 720, network interface;
[0067] 722. Communication link;
[0068] 724. Communication bus. DETAILED DESCRIPTION
[0069] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in some embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on some embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.
[0070] It should be noted that the terms "first", "second", etc. in the specification and claims of this article and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of this article described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0071] It should be noted that the acquisition, storage, use, and processing of data in the technical solution of this application are in compliance with the relevant provisions of relevant laws and regulations.
[0072] like Figure 1 The diagram is a schematic diagram of a system for implementing a message parsing method according to an embodiment of the present invention, which may include: a client 101 and a server 102. The client 101 and the server 102 communicate with each other through a network, which may include a local area network (LAN), a wide area network (WAN), the Internet or a combination thereof, and is connected to a website, a user device (such as a computing device) and a back-end system. A staff member may send a request message to the server 102 through the client 101. After receiving the request message, the server 102 calls the data in the database for processing, obtains a response message, and sends the response message to the client 101, so that the client 101 parses the response message according to the message parsing method described in any of the aforementioned embodiments to obtain the target resource, thereby facilitating the staff member to process the business according to the target resource.
[0073] In the embodiments of this specification, the server 102 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN, Content Delivery Network), and big data and artificial intelligence platforms.
[0074] In an optional embodiment, the client 101 may include but is not limited to electronic devices such as self-service terminal devices, desktop computers, tablet computers, laptop computers, smart wearable devices, etc. Optionally, the operating system running on the electronic device may include but is not limited to Android system, IOS system, Linux, Windows, etc. Of course, the client 101 is not limited to the above-mentioned electronic devices with a certain entity, and it can also be software running in the above-mentioned electronic devices.
[0075] In addition, it should be noted that Figure 1 What is shown is only an application environment provided by the present disclosure. In actual application, multiple clients 101 may be included, and this specification does not limit this.
[0076] Figure 2 It is a flowchart of a message parsing method provided by an embodiment of the present invention. This specification provides method operation steps as described in the embodiment or flowchart, but may include more or fewer operation steps based on conventional or non-creative labor. The order of steps listed in the embodiment is only one way of executing the steps among many orders, and does not represent the only order of execution. When the actual system or device product is executed, it can be executed in the order or in parallel according to the method shown in the embodiment or the accompanying drawings. Specifically, Figure 2 As shown, applied to the client side as described above, the method may include:
[0077] S201: receiving a response message corresponding to a request message for a target resource;
[0078] S202: Searching for content type information from the header information of the response message;
[0079] S203: judging whether the response message conforms to the expected response message type paradigm according to the content type information;
[0080] S204: If the response message conforms to the expected response message type paradigm, determine a corresponding message parsing strategy according to the expected response message type conformed by the response message;
[0081] S205: If the response message does not conform to the expected response message type paradigm, determine a corresponding message parsing strategy using a preset response format;
[0082] S206: Parse the response message using the message parsing strategy to obtain the target resource.
[0083] In the embodiments of the present specification, after the client sends a request message for obtaining a target resource, it automatically obtains a response message corresponding to the request message, and searches for content type information from the header information in the response message to analyze and determine whether the response message conforms to the expected response message type paradigm. If it conforms to the expected response message type paradigm, a corresponding message parsing strategy is determined based on the expected response message type that the response message conforms to. If the response message does not conform to the expected response message type paradigm, a corresponding message parsing strategy is determined using a preset response format. Therefore, regardless of whether the response message conforms to the expected response message type paradigm or does not conform to the expected response message type paradigm, an accurate message parsing strategy for the response message can be obtained, and the response message is parsed using the message parsing strategy to obtain the target resource, thereby reducing the occurrence of message parsing errors and improving the message parsing speed.
[0084] It can be understood that, in some embodiments, request messages and response messages are transmitted between the client and the server through the Fetch communication technology. The Fetch technology can support message parsing processes of five data types: json, text, blob, arrayBuffer, and formData. In the prior art, before the client sends a request message through the Fetch communication technology, it is necessary to set the message parsing type (for example, blob) after obtaining the message response body (i.e., the response message) in advance. If an exception occurs in the server, the MIME type of the returned message response body is inconsistent with the expectation (for example, a response message of Content-Type=application / json type is returned). At this time, if the original message is parsed according to the blob type, and the original message is of json type, then valid information cannot be directly parsed out, and further message parsing is required through the downstream process (for example, parsing the blob type message into a string) to obtain valid information. However, this process causes the workflow of parsing the message to be transferred from the current message parsing process to other downstream processes, making the logic of subsequent processing more complicated.
[0085] Specifically, before the client obtains the response message, it further includes:
[0086] The client sends a message request to the server to obtain the target resource;
[0087] The server receives the message request and verifies the message request;
[0088] The server returns a response message corresponding to the message request.
[0089] After the client obtains the response message, it determines whether the response message conforms to the expected response message type paradigm based on the header information of the response message. The paradigm is a data specification. The expected response message type paradigm can be regarded as the specification requirement of the expected response message type. If the response message conforms to the expected response message type paradigm, the corresponding message parsing strategy can be determined by the expected response message type that the response message conforms to. However, the content type (Content-Type) of the response message has diverse characteristics. When judging whether the response message conforms to the expected response message type paradigm based on the content type information, it is necessary to conduct a specific analysis of the content type information to determine the appropriate message parsing strategy. If the response message does not conform to the expected response message type paradigm, the corresponding message parsing strategy is determined using the preset response format to provide a "bottom-line" message parsing strategy for the current response message, thereby avoiding the situation where the corresponding message parsing strategy cannot be determined for the current response message, thereby achieving effective parsing of the response message.
[0090] See attached Figure 3 In some embodiments, searching for content type information from the header information of the response message may include:
[0091] S301: Obtaining a content type field value from the header information;
[0092] S302: Use the content type field value as the content type information.
[0093] It can be understood that, in some embodiments, header information allows the client and server to pass additional information through an HTTP request or response, and the header information includes content type information (Content-Type), and the content type information indicates that the header information is used to indicate the original media type of the resource.
[0094] When determining the content type information in the header information of the current response message, the content type field value is obtained from the header information, as shown in the header information below. The header information includes:
[0095] HTTP / 1.1 200 0K
[0096] Server: nginx
[0097] Date:Tue,02Jul202401:02:18GMT
[0098] Content-Type: text / html; charset=utf-8
[0099] Transfer-Encoding: chunked
[0100] Connection:keep-alive
[0101] TRACE ID:0f3806c3171988213875227011
[0102] The above header information includes the content type expression Content-Type:text / html. The content type field value text / html can be obtained from the above header information. It should be noted that special attention should be paid to the fact that the content type field value should not contain a semicolon, i.e., ";". In some embodiments, in order to simplify the regular matching process, the content type field value can also be selected for standardization, such as converting all uppercase characters to lowercase characters, and intercepting the content type field value through existing separators (such as ":", "=", etc.) to ensure the validity of the content type information, so as to quickly and accurately find the content type information.
[0103] See attached Figure 4 In some embodiments, judging whether the response message conforms to the expected response message type paradigm according to the content type information includes:
[0104] S401: Determine whether the content type information is ambiguous, and obtain a first determination result;
[0105] S402: using character matching to determine whether the content type information meets a preset matching condition, and obtaining a second determination result;
[0106] S403: According to the first judgment result and the second judgment result, determine whether the response message conforms to the expected response message type paradigm.
[0107] It can be understood that, in some embodiments, an ambiguous response message can be parsed using a variety of message parsing strategies. The purpose of determining whether the content type information is ambiguous is to eliminate the interference of ambiguity on the message parsing process. Common ambiguous content type information is: audio format starting with audio, video format starting with video, image format starting with image and not image / svg and application / octet-stream. Character matching can be implemented by regular matching, which is not limited in this article. The preset matching condition refers to whether the content type information can meet the characteristics of the basic type paradigm. For example, if the content type information meets the application / (.*?)json format, the content type information matches the basic type json. If the content type information is a character starting with "text" or the content type information is any one of "application / xml", "application / xhtml", "application / html", and "image / svg", then the content type information matches the basic type text.
[0108] Furthermore, in some embodiments, character matching is used to determine whether the content type information meets a preset matching condition, and a second determination result is obtained, including:
[0109] Using character matching, the content type information is matched with a basic type paradigm included in a preset matching condition;
[0110] If the matching result is not empty, the content type information satisfies the preset matching condition;
[0111] and taking the basic type matching the content type information as the expected response message type that the response message complies with;
[0112] If the matching result is empty, the content type information does not meet the preset matching condition.
[0113] Further, in some embodiments, judging whether the response message conforms to an expected response message type paradigm according to the first judgment result and the second judgment result includes:
[0114] If the content type information is ambiguous, or the content type information does not meet the preset matching condition, then the response message does not meet the expected response message type paradigm;
[0115] If the content type information is not ambiguous and the content type information satisfies a preset matching condition, then the response message complies with the expected response message type paradigm.
[0116] It can be understood that in some embodiments, referring to the attached Figure 5 The figure shows a detailed flow chart of determining the corresponding message parsing strategy based on whether the response message conforms to the expected response message type paradigm. Specifically, when the content type information is ambiguous, the response message does not conform to the expected response message type paradigm. Since the response message can be parsed by a variety of parsing types supported by Fetch at this time, the preset response format can be used to determine the message parsing strategy corresponding to the response message, thereby avoiding the situation where the appropriate message parsing strategy required for the response message cannot be determined, resulting in the inability to automatically parse the response message. It should be noted that the preset response format is pre-set by the client, for example, it can be responseType=blob. When the content type information is not ambiguous, but the content type information does not meet the preset matching conditions, this means that it is impossible to automatically map and generate a parsing type supported by Fetch based on the content type information of the response message. The matching result is empty, and the response message does not conform to the expected response message type paradigm. The preset response format is still used to determine the message parsing strategy corresponding to the response message, thereby providing a fallback parsing strategy for the response message to avoid the situation where the parsing strategy cannot be determined. At the same time, the message parsing strategy determined by the preset response format can ensure a certain response message parsing success rate.
[0117] Furthermore, in some embodiments, when the content type information is not ambiguous and the content type information satisfies the preset matching conditions, the matching result is not empty, and the response message conforms to the expected response message type paradigm. Specifically, the preset matching conditions may include a matching relationship between the basic type paradigm and the content type information. The basic type paradigm can be regarded as a specification requirement for the basic type. When a content type information satisfies the preset matching conditions, the content type information has a matching relationship with the basic type supported by Fetch. Through the matching relationship, the expected response message type that the response message conforms to can be quickly obtained, so as to subsequently determine the corresponding message parsing strategy according to the expected response message type that the response message conforms to, thereby realizing the use of the message parsing strategy to accurately parse the response message, improve the message parsing speed, and avoid the problem that the response message needs to flow into the downstream node before it can be parsed, resulting in increased development costs.
[0118] It should be noted that, although the operations of the method of the present invention are described in a specific order in the above embodiments and the accompanying drawings, this does not require or imply that the operations must be performed in the specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.
[0119] Corresponding to the above-mentioned message parsing method, some embodiments of this specification also provide a message parsing device, referring to Figure 6 As shown, in some embodiments, the apparatus may include:
[0120] The receiving module 601 is used to receive a response message corresponding to a request message for requesting a target resource;
[0121] A search module 602 is used to search for content type information from the header information of the response message;
[0122] A judging module 603 is used to judge whether the response message conforms to an expected response message type paradigm according to the content type information;
[0123] A matching module 604 is used to determine a corresponding message parsing strategy according to the expected response message type that the response message conforms to if the response message conforms to the expected response message type paradigm;
[0124] A determination module 605, configured to determine a corresponding message parsing strategy using a preset response format if the response message does not conform to an expected response message type paradigm;
[0125] The parsing module 606 is used to parse the response message using the message parsing strategy to obtain the target resource.
[0126] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0127] It should be noted that in the embodiments of this specification, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user and fully authorized by all parties.
[0128] It should be noted that the computer program product described in this specification is a software product that mainly implements the method described in this specification through a computer program.
[0129] The embodiments of this specification also provide a computer device. Figure 7As shown, in some embodiments of the present specification, the computer device 702 may include one or more processors 704, such as one or more central processing units (CPUs) or graphics processing units (GPUs), and each processing unit may implement one or more hardware threads. The computer device 702 may also include any memory 706, which is used to store any kind of information such as code, settings, data, etc. In a specific embodiment, the computer program on the memory 706 and can be run on the processor 704, when the computer program is run by the processor 704, the instructions of the method described in any of the above embodiments may be executed. Non-limitingly, for example, the memory 706 may include any one or more combinations of the following: any type of RAM, any type of ROM, flash memory device, hard disk, optical disk, etc. More generally, any memory may use any technology to store information.
[0130] Further, any memory can provide volatile or non-volatile retention of information. Further, any memory can represent a fixed or removable component of the computer device 702. In one case, when the processor 704 executes the associated instructions stored in any memory or combination of memories, the computer device 702 can perform any operation of the associated instructions. The computer device 702 also includes one or more drive mechanisms 708 for interacting with any memory, such as a hard disk drive mechanism, an optical disk drive mechanism, etc.
[0131] The computer device 702 may also include an input / output interface 710 (I / O) for receiving various inputs (via input device 712) and for providing various outputs (via output device 714). A specific output mechanism may include a presentation device 716 and an associated graphical user interface 718 (GUI). In other embodiments, the input / output interface 710 (I / O), input device 712, and output device 714 may not be included, and the computer device 702 may be used as a computer device in a network. The computer device 702 may also include one or more network interfaces 720 for exchanging data with other devices via one or more communication links 722. One or more communication buses 724 couple the components described above together.
[0132] The communication link 722 may be implemented in any manner, for example, through a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication link 722 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc. governed by any protocol or combination of protocols.
[0133] The present application is described with reference to flowcharts and / or block diagrams of methods, devices (systems), computer-readable storage media, and computer program products of some embodiments of the present specification.
[0134] It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processor to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processor generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0135] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processor to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0136] These computer program instructions can also be loaded onto a computer or other programmable data processor so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0137] In a typical configuration, a computer device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0138] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0139] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computer device. As defined in this specification, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0140] Those skilled in the art should understand that the embodiments of this specification can be provided as methods, systems or computer program products. Therefore, the embodiments of this specification can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware.
[0141] Moreover, the embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0142] The present specification embodiments may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present specification embodiments may also be practiced in distributed computing environments where tasks are performed by remote processors connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0143] It should also be understood that in the embodiments of this specification, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0144] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0145] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiments of this specification. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0146] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A message parsing method, characterized in that: The method comprises: Receive a response message corresponding to the request message for the target resource; Searching for content type information from the header information of the response message; Determining whether the response message conforms to the expected response message type paradigm according to the content type information; If the response message conforms to the expected response message type paradigm, determining a corresponding message parsing strategy according to the expected response message type conformed by the response message; If the response message does not conform to the expected response message type paradigm, a corresponding message parsing strategy is determined using a preset response format; The response message is parsed using the message parsing strategy to obtain the target resource.
2. The method according to claim 1, characterized in that The request message and the response message are transmitted between the client and the server through the Fetch communication technology.
3. The method according to claim 1, characterized in that Searching for content type information from the header information of the response message includes: Obtaining a content type field value from the header information; The content type field value is used as the content type information.
4. The method according to claim 1, characterized in that: Judging whether the response message conforms to an expected response message type paradigm according to the content type information includes: Determine whether the content type information is ambiguous, and obtain a first determination result; Using character matching, determining whether the content type information meets a preset matching condition, and obtaining a second determination result; According to the first judgment result and the second judgment result, it is determined whether the response message conforms to the expected response message type paradigm.
5. The method according to claim 4, characterized in that Using character matching, determining whether the content type information meets a preset matching condition, and obtaining a second determination result, including: By using character matching, the content type information is matched with the basic type paradigm included in the preset matching condition to obtain a matching result; If the matching result is not empty, the content type information meets the preset matching condition; If the matching result is empty, the content type information does not meet the preset matching condition.
6. The method according to claim 5, characterized in that The basic type that matches the content type information is used as the expected response message type that the response message conforms to.
7. The method according to claim 4, characterized in that Judging, according to the first judgment result and the second judgment result, whether the response message conforms to an expected response message type paradigm includes: If the content type information is ambiguous, or the content type information does not meet the preset matching condition, then the response message does not meet the expected response message type paradigm; If the content type information is not ambiguous and the content type information satisfies a preset matching condition, then the response message complies with the expected response message type paradigm.
8. A message parsing device, characterized in that: The device comprises: A receiving module, used to receive a response message corresponding to a request message for a target resource; A search module, used to search for content type information from the header information of the response message; A judging module, used for judging whether the response message conforms to the expected response message type paradigm according to the content type information; A matching module, configured to determine a corresponding message parsing strategy according to the expected response message type that the response message conforms to if the response message conforms to the expected response message type paradigm; A determination module, configured to determine a corresponding message parsing strategy using a preset response format if the response message does not conform to an expected response message type paradigm; A parsing module is used to parse the response message using the message parsing strategy to obtain the target resource.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory, characterized in that: When the computer program is executed by the processor, the computer program executes the instructions of the method according to any one of claims 1 to 7.
10. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor of a computer device, the computer program executes instructions of the method according to any one of claims 1 to 7.
11. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the computer program executes instructions of the method according to any one of claims 1 to 7.
