CN114124918A - Message parsing method and device - Google Patents

Message parsing method and device Download PDF

Info

Publication number
CN114124918A
CN114124918A CN202111415195.2A CN202111415195A CN114124918A CN 114124918 A CN114124918 A CN 114124918A CN 202111415195 A CN202111415195 A CN 202111415195A CN 114124918 A CN114124918 A CN 114124918A
Authority
CN
China
Prior art keywords
message
format
preset
http
key
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111415195.2A
Other languages
Chinese (zh)
Inventor
王硕
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Bank of China Ltd
Original Assignee
Bank of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Bank of China Ltd filed Critical Bank of China Ltd
Priority to CN202111415195.2A priority Critical patent/CN114124918A/en
Publication of CN114124918A publication Critical patent/CN114124918A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses a message parsing method and device, and relates to the technical field of mobile interconnection. Wherein the method comprises the following steps: when the received HTTP message is a standard HTTP message, determining the message type of the HTTP message according to whether the preset position in the HTTP message contains a preset message type identifier; when the message type of the HTTP message is a GET type, analyzing the HTTP message to obtain a first message header; when determining that the first message header contains a message with a key value format according to a preset condition, analyzing the first message header according to a preset character to obtain at least one analysis result with the key value format; the preset conditions comprise preset formats of characters which should exist, characters which cannot exist and preset variables in the message format; the obtained analysis results in the key value format are stored as data in the key value format individually. The message parsing efficiency is improved.

Description

Message parsing method and device
Technical Field
The invention relates to the technical field of mobile interconnection, in particular to a message analysis method and a message analysis device.
Background
This section is intended to provide a background or context to the embodiments of the invention that are recited in the claims. The description herein is not admitted to be prior art by inclusion in this section.
The HTTP message includes a standard HTTP message and a non-standard HTTP message. At present, for the parsing of the standard HTTP message, the message can only be parsed into a header or into two parts, namely, the header and a body, but some messages in other formats (for example, messages in key (value), XML, JSON, and other formats) are often nested in the HTTP message, and the standard HTTP message is divided into two types, one type is a GET type HTTP message: only contain the message header, may nest the message of key ═ value format in the message header; the other type is HTTP message of non GET type: the message body comprises a message header and a message body, wherein the message header comprises normal message data in an HTTP message, and formatted messages such as a key value or XML or JSON can be embedded in the message body. The existing analysis scheme aiming at the HTTP message cannot carry out more detailed analysis on the messages with other formats contained in the HTTP message, needs to carry out artificial analysis to obtain more detailed analysis results, and has the advantages of large workload, high error probability and low HTTP message analysis efficiency.
Disclosure of Invention
The embodiment of the invention provides a message analysis method, which is used for further analyzing messages in other formats nested in an HTTP message and improving the analysis efficiency of the HTTP message, and comprises the following steps:
when the received HTTP message is a standard HTTP message, determining the message type of the HTTP message according to whether the preset position in the HTTP message contains a preset message type identifier;
when the message type of the HTTP message is a GET type, analyzing the HTTP message to obtain a first message header;
when determining that a first message header contains a message in a key value format according to a preset condition, analyzing the first message header according to preset characters to obtain at least one analysis result in the key value format; the preset conditions comprise characters which should exist in the message format, characters which cannot exist in the message format and preset formats of preset variables;
the obtained analysis results in the key value format are stored as data in the key value format individually. The embodiment of the present invention further provides a message parsing apparatus, configured to further parse messages in other formats nested in an HTTP message, so as to improve parsing efficiency of the HTTP message, where the apparatus includes:
the message type determining module is used for determining the message type of the HTTP message according to whether the preset position in the HTTP message contains a preset message type identifier or not when the received HTTP message is a standard HTTP message;
the first analysis module is used for analyzing the HTTP message to obtain a first message header when the message type of the HTTP message is a GET type;
the second analysis module is used for analyzing the first message header according to preset characters when the first message header is determined to contain the message with the key value format according to preset conditions, so as to obtain at least one analysis result with the key value format; the preset conditions comprise characters which should exist in the message format, characters which cannot exist in the message format and preset formats of preset variables;
and the storage module is used for respectively storing the obtained analysis results in the key-value format into data in a single key-value format.
The embodiment of the invention also provides computer equipment which comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor realizes the message analysis method when executing the computer program.
The embodiment of the invention also provides a computer readable storage medium, wherein a computer program is stored in the computer readable storage medium, and when the computer program is executed by a processor, the message analysis method is realized.
An embodiment of the present invention further provides a computer program product, where the computer program product includes a computer program, and when the computer program is executed by a processor, the message parsing method is implemented.
In the embodiment of the invention, when the received HTTP message is a standard HTTP message, the message type of the HTTP message is determined according to whether the preset position in the HTTP message contains a preset message type identifier; when the message type of the HTTP message is a GET type, analyzing the HTTP message to obtain a first message header; when determining that a first message header contains a message in a key value format according to a preset condition, analyzing the first message header according to preset characters to obtain at least one analysis result in the key value format; the preset conditions comprise characters which should exist in the message format, characters which cannot exist in the message format and preset formats of preset variables; the obtained analysis results in the key value format are stored as data in the key value format individually. Therefore, messages in other formats nested in the HTTP message can be further analyzed, and the analysis efficiency of the HTTP message is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts. In the drawings:
fig. 1 is a flowchart of a message parsing method provided in an embodiment of the present invention;
fig. 2 is a flowchart of a method for parsing the first packet header according to a preset character to obtain an parsing result in a key-value format according to an embodiment of the present invention;
fig. 3 is a flowchart of an analysis method for a non-GET type packet according to an embodiment of the present invention;
fig. 4 is a flowchart of an analysis method for a non-standard HTTP message according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a message parsing apparatus provided in the embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the embodiments of the present invention are further described in detail below with reference to the accompanying drawings. The exemplary embodiments and descriptions of the present invention are provided to explain the present invention, but not to limit the present invention.
The term "and/or" herein merely describes an associative relationship, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, C, and may mean including any one or more elements selected from the group consisting of A, B and C.
In the description of the present specification, the terms "comprising," "including," "having," "containing," and the like are used in an open-ended fashion, i.e., to mean including, but not limited to. Reference to the description of the terms "one embodiment," "a particular embodiment," "some embodiments," "for example," etc., means that a particular feature, structure, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. The sequence of steps involved in the embodiments is for illustrative purposes to illustrate the implementation of the present application, and the sequence of steps is not limited and can be adjusted as needed.
Research shows that the HTTP message comprises a standard HTTP message and a non-standard HTTP message. At present, for the parsing of the standard HTTP message, the message can only be parsed into a header or into two parts, namely, the header and a body, but some messages in other formats (for example, messages in key (value), XML, JSON, and other formats) are often nested in the HTTP message, and the standard HTTP message is divided into two types, one type is a GET type HTTP message: only contain the message header, may nest the message of key ═ value format in the message header; the other type is HTTP message of non GET type: the message body comprises a message header and a message body, wherein the message header comprises normal message data in an HTTP message, and formatted messages such as a key value or XML or JSON can be embedded in the message body. The existing analysis scheme aiming at the HTTP message cannot carry out more detailed analysis on the messages with other formats contained in the HTTP message, needs to carry out artificial analysis to obtain more detailed analysis results, and has the advantages of large workload, high error probability and low HTTP message analysis efficiency.
In view of the above research, an embodiment of the present invention provides a message parsing method, as shown in fig. 1, including:
s101: when the received HTTP message is a standard HTTP message, determining the message type of the HTTP message according to whether the preset position in the HTTP message contains a preset message type identifier;
s102: when the message type of the HTTP message is a GET type, analyzing the HTTP message to obtain a first message header;
s103: when determining that a first message header contains a message in a key value format according to a preset condition, analyzing the first message header according to preset characters to obtain at least one analysis result in the key value format; the preset conditions comprise characters which should exist in the message format, characters which cannot exist in the message format and preset formats of preset variables;
s104: the obtained analysis results in the key value format are stored as data in the key value format individually.
In the embodiment of the invention, when the received HTTP message is a standard HTTP message, the message type of the HTTP message is determined according to whether the preset position in the HTTP message contains a preset message type identifier; when the message type of the HTTP message is a GET type, analyzing the HTTP message to obtain a first message header; when determining that a first message header contains a message in a key value format according to a preset condition, analyzing the first message header according to preset characters to obtain at least one analysis result in the key value format; the preset conditions comprise characters which should exist in the message format, characters which cannot exist in the message format and preset formats of preset variables; the obtained analysis results in the key value format are stored as data in the key value format individually. Therefore, messages in other formats nested in the HTTP message can be further analyzed, and the analysis efficiency of the HTTP message is improved.
The following describes the details of S101 to S104.
Some terms of embodiments of the present invention are first described:
the standard HTTP message in the embodiment of the invention is an HTTP message only containing a message header or containing a message header and a message body, and the custom HTTP message is an HTTP message containing custom data except the message header and the message body;
the standard HTTP message in the embodiment of the invention comprises a GET type HTTP message and a non-GET type HTTP message; the GET type HTTP message only contains a message header, and the message header may contain normal message data of only HTTP or may be nested with a message in a key value format; the non-GET type HTTP message comprises a message header and a message body.
For the above S101, when the received HTTP message is a standard HTTP message, determining a message type of the HTTP message according to whether a preset position in the HTTP message includes a preset message type identifier, for example, determining the message type of the HTTP message according to the first 3 bytes in the HTTP message, if the first three bytes of the HTTP message are "GET", it represents that the HTTP message is a GET-type HTTP message, and otherwise, it represents that the HTP message is a non-GET-type HTTP message.
For the above S102, when the first three bytes in the HTTP message are "GET", the HTTP message is a GET-type HTTP message, and the HTTP message only includes a message header and does not include a message body, and the GET-type HTTP message is analyzed to obtain a first message header.
For the above S103, the preset condition includes preset formats of characters that should exist in the message format, characters that cannot exist, and a preset variable, and when determining that the message in the key-value format is included in the first message header according to the preset condition, for example, it is determined that a symbol exists in the first message header: "═ and no symbol exists: when the value corresponding to the variable after the symbol "<", "[", "{" and the symbol "═ is a letter or a number, it is determined that the message in the key value format is included in the first header.
Specifically, as shown in fig. 2, a flowchart of a method for analyzing the first packet header according to a preset character to obtain an analysis result in a key value format according to an embodiment of the present invention includes:
s201: traversing the first message header, searching preset characters in a first message header character string, and segmenting the first message header character string from each preset character to obtain at least one sub-character string.
Illustratively, messages in the key value format are separated by a character "&", for example, "key 1 &" 1& key 2& "2 & …", and at least one substring is obtained by splitting from each preset character, for example, "key 1 ═ 1 &", "key 2 &" 2& "….
S202: and extracting the contents of each sub-character string except the preset character to obtain at least one analysis result in a key value format.
Illustratively, the content other than "&" is extracted for the substring "key 1 ═ value1 &", resulting in "key 1 ═ value 1", and "key 3 ═ value 3" is directly extracted for the substring "key 3 ═ value 3".
In S104, each variable in the message body and the value corresponding to each variable are stored as data in a single key value format, and for example, after the messages "key 1 value1& key2 value2& …" are analyzed, the messages are stored in accordance with "key 1 value 1" and "key 2 value 2" ….
In addition, when the received HTTP message is a standard HTTP message and the HTTP message includes a message body in addition to a message header, the HTTP message is a non-GET type HTTP message, and the message header of the non-GET type HTTP message includes normal message data of the HTTP message, but a key value format or an XML format or a JSON format message may be nested in the message body.
Therefore, as shown in fig. 3, a flowchart of an analysis method for a non-GET type packet according to an embodiment of the present invention includes:
s301: and when the message type of the HTTP message is a non GET type, analyzing the HTTP message to obtain a second message header and a message body.
S302: calling a corresponding analysis function according to a message format nested in the message body to analyze the message body to obtain a numerical value corresponding to each variable in the message body; the nested message format in the message body comprises: value format, or XML format, or JSON format.
Specifically, for example, whether messages in other formats are nested in the message body is determined according to preset conditions, and when messages in other formats are nested in the message body, a corresponding parsing function is called according to the message formats nested in the message body to parse the message body.
Here, the preset conditions include preset formats of characters that should exist, characters that cannot exist, and preset variables in the message formats, and the preset conditions corresponding to each nested message format are different.
In an embodiment of the present invention, when a corresponding parsing function is called to parse a message body according to a message format nested in the message body to obtain a value corresponding to each variable in the message body, for example, the message format nested in the message body is: and when the key is in the value format, calling an analysis function corresponding to the key in the value format, and taking out each line in the message body independently as an analysis result of the independent key in the value format to obtain a numerical value corresponding to the variable of each line.
Here, a message in a key value format nested in a message body is a string having "key value" in each row, for example, a first action "key 1" value1 "and a second action" key2 "value 2" ….
In another embodiment of the present invention, when a corresponding parsing function is called to parse a message body according to a message format nested in the message body to obtain a value corresponding to each variable in the message body, for example, the message format nested in the message body is: when the JSON format is adopted, according to characters in the JSON format message, reserved characters and analysis rules are set in the JavaCC to generate an analysis function; and calling an analysis function to analyze the message body character string to obtain the numerical value corresponding to each variable in the message body.
The parsing function for parsing the XML-format message can directly call the library function of the existing Java standard, which is not described herein again.
S303: and storing each variable in the message body and the value corresponding to each variable as single data in a key value format.
In addition, the non-standard HTTP message is composed of custom data and a standard HTTP message. The existing analysis aiming at the non-standard HTTP message cannot analyze the self-defined data part.
Therefore, as shown in fig. 4, a flowchart of an analysis method for a non-standard HTTP message provided in an embodiment of the present invention includes:
s401: when the received HTTP message is a non-standard HTTP message, extracting a sub-character string with a preset number of bits from a preset position in a character string of the HTTP message according to a pre-agreed non-standard HTTP message generation rule to obtain custom data and a standard HTTP message;
s402: analyzing the user-defined data according to a pre-agreed non-standard HTTP message analysis rule to obtain a numerical value corresponding to each variable in the user-defined data; the non-standard HTTP message analysis rule is obtained according to the non-standard HTTP message generation rule;
s403: and respectively storing each variable in the custom data and the value corresponding to each variable as data in a single key value format.
The embodiment of the invention also provides a message analysis device, which is described in the following embodiments. Because the principle of the device for solving the problems is similar to the message analysis method, the implementation of the device can refer to the implementation of the message analysis method, and repeated parts are not described again.
As shown in fig. 5, a message parsing apparatus provided in an embodiment of the present invention includes: the message type determining module 501, the first analyzing module 502, the second analyzing module 503 and the storage module 504; wherein,
a message type determining module 501, configured to determine, when a received HTTP message is a standard HTTP message, a message type of the HTTP message according to whether a preset position in the HTTP message includes a preset message type identifier;
a first parsing module 502, configured to parse the HTTP message to obtain a first message header when the message type of the HTTP message is a GET type;
the second parsing module 503 is configured to, when it is determined that the first packet header includes a packet with a key-value format according to a preset condition, parse the first packet header according to a preset character to obtain at least one parsing result with the key-value format; the preset conditions comprise characters which should exist in the message format, characters which cannot exist in the message format and preset formats of preset variables;
a storage module 504, configured to store the obtained analysis results in the key-value format as data in a single key-value format.
In a possible implementation manner, the second parsing module is specifically configured to traverse the first packet header, search for a preset character in a first packet header character string, segment the first packet header character string from each preset character to obtain at least one sub-character string, extract contents of each sub-character string except the preset character, and obtain an parsing result in a key-value format.
In one possible embodiment, the method further comprises: the third analysis module is used for analyzing the HTTP message to obtain a second message header and a message body when the message type of the HTTP message is a non-GET type; calling a corresponding analysis function according to a message format nested in the message body to analyze the message body to obtain a numerical value corresponding to each variable in the message body; the nested message format in the message body comprises: value format, or XML format, or JSON format; the storage module is further configured to store each variable in the message body and a value corresponding to each variable as data in a single key-value format.
In a possible implementation manner, the third parsing module is specifically configured to use a message format nested in a message body as follows: and when the key is in the value format, calling an analysis function corresponding to the key in the value format, and taking out each line in the message body independently as an analysis result of the independent key in the value format to obtain a numerical value corresponding to the variable of each line.
In a possible implementation manner, the third parsing module is specifically configured to use a message format nested in a message body as follows: when the JSON format is adopted, according to characters in the JSON format message, reserved characters and analysis rules are set in the JavaCC to generate an analysis function; and calling an analysis function to analyze the message body character string to obtain the numerical value corresponding to each variable in the message body.
In one possible embodiment, the method further comprises: the fourth analysis module is used for extracting sub-character strings with preset digits from preset positions in the character strings of the HTTP message according to a preset non-standard HTTP message generation rule when the received HTTP message is a non-standard HTTP message, and obtaining custom data and a standard HTTP message; analyzing the user-defined data according to a pre-agreed non-standard HTTP message analysis rule to obtain a numerical value corresponding to each variable in the user-defined data; the non-standard HTTP message analysis rule is obtained according to the non-standard HTTP message generation rule; the storage module is further configured to store each variable in the custom data and a numerical value corresponding to each variable as data in a single key-value format.
The embodiment of the invention also provides computer equipment which comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor realizes the message analysis method when executing the computer program.
The embodiment of the invention also provides a computer readable storage medium, wherein a computer program is stored in the computer readable storage medium, and when the computer program is executed by a processor, the message analysis method is realized.
An embodiment of the present invention further provides a computer program product, where the computer program product includes a computer program, and when the computer program is executed by a processor, the message parsing method is implemented.
In the embodiment of the invention, when the received HTTP message is a standard HTTP message, the message type of the HTTP message is determined according to whether the preset position in the HTTP message contains a preset message type identifier; when the message type of the HTTP message is a GET type, analyzing the HTTP message to obtain a first message header; when determining that a first message header contains a message in a key value format according to a preset condition, analyzing the first message header according to preset characters to obtain at least one analysis result in the key value format; the preset conditions comprise characters which should exist in the message format, characters which cannot exist in the message format and preset formats of preset variables; the obtained analysis results in the key value format are stored as data in the key value format individually. Therefore, messages in other formats nested in the HTTP message can be further analyzed, and the analysis efficiency of the HTTP message is improved.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are only exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (15)

1. A message parsing method is characterized by comprising the following steps:
when the received HTTP message is a standard HTTP message, determining the message type of the HTTP message according to whether the preset position in the HTTP message contains a preset message type identifier;
when the message type of the HTTP message is a GET type, analyzing the HTTP message to obtain a first message header;
when determining that a first message header contains a message in a key value format according to a preset condition, analyzing the first message header according to preset characters to obtain at least one analysis result in the key value format; the preset conditions comprise characters which should exist in the message format, characters which cannot exist in the message format and preset formats of preset variables;
the obtained analysis results in the key value format are stored as data in the key value format individually.
2. The message parsing method according to claim 1, wherein parsing the first message header according to preset characters to obtain at least one parsing result in a key-value format includes:
traversing the first message header, searching preset characters in a first message header character string, and segmenting the first message header character string from each preset character to obtain at least one sub-character string;
and extracting the contents of each sub-character string except the preset character to obtain at least one analysis result in a key value format.
3. The message parsing method according to claim 1, further comprising:
when the message type of the HTTP message is a non-GET type, analyzing the HTTP message to obtain a second message header and a message body;
calling a corresponding analysis function according to a message format nested in the message body to analyze the message body to obtain a numerical value corresponding to each variable in the message body; the nested message format in the message body comprises: value format, or XML format, or JSON format;
and storing each variable in the message body and the value corresponding to each variable as single data in a key value format.
4. The message parsing method according to claim 3, wherein calling a corresponding parsing function to parse the message body according to a message format nested in the message body to obtain values corresponding to variables in the message body, includes:
the message format nested in the message body is as follows: and when the key is in the value format, calling an analysis function corresponding to the key in the value format, and taking out each line in the message body independently as an analysis result of the independent key in the value format to obtain a numerical value corresponding to the variable of each line.
5. The message parsing method according to claim 3, wherein calling a corresponding parsing function to parse the message body according to a message format nested in the message body to obtain values corresponding to variables in the message body, comprises:
the message format nested in the message body is as follows: when the JSON format is adopted, according to characters in the JSON format message, reserved characters and analysis rules are set in the JavaCC to generate an analysis function;
and calling an analysis function to analyze the message body character string to obtain the numerical value corresponding to each variable in the message body.
6. The message parsing method according to claim 1, further comprising:
when the received HTTP message is a non-standard HTTP message, extracting a sub-character string with a preset number of bits from a preset position in a character string of the HTTP message according to a pre-agreed non-standard HTTP message generation rule to obtain custom data and a standard HTTP message;
analyzing the user-defined data according to a pre-agreed non-standard HTTP message analysis rule to obtain a numerical value corresponding to each variable in the user-defined data; the non-standard HTTP message analysis rule is obtained according to the non-standard HTTP message generation rule;
and respectively storing each variable in the custom data and the value corresponding to each variable as data in a single key value format.
7. A message parsing apparatus, comprising:
the message type determining module is used for determining the message type of the HTTP message according to whether the preset position in the HTTP message contains a preset message type identifier or not when the received HTTP message is a standard HTTP message;
the first analysis module is used for analyzing the HTTP message to obtain a first message header when the message type of the HTTP message is a GET type;
the second analysis module is used for analyzing the first message header according to preset characters when the first message header is determined to contain the message with the key value format according to preset conditions, so as to obtain at least one analysis result with the key value format; the preset conditions comprise characters which should exist in the message format, characters which cannot exist in the message format and preset formats of preset variables;
and the storage module is used for respectively storing the obtained analysis results in the key-value format into data in a single key-value format.
8. The message parsing device as claimed in claim 7, wherein the second parsing module is specifically configured to traverse the first header, search for preset characters in a first header character string, segment the first header character string from each preset character to obtain at least one sub-character string, extract contents of each sub-character string except the preset characters, and obtain at least one parsing result in a key value format.
9. The message parsing apparatus according to claim 7, further comprising: the third analysis module is used for analyzing the HTTP message to obtain a second message header and a message body when the message type of the HTTP message is a non-GET type; calling a corresponding analysis function according to a message format nested in the message body to analyze the message body to obtain a numerical value corresponding to each variable in the message body; the nested message format in the message body comprises: value format, or XML format, or JSON format;
the storage module is further configured to store each variable in the message body and a value corresponding to each variable as data in a single key-value format.
10. The message parsing device according to claim 9, wherein the third parsing module is specifically configured to: and when the key is in the value format, calling an analysis function corresponding to the key in the value format, and taking out each line in the message body independently as an analysis result of the independent key in the value format to obtain a numerical value corresponding to the variable of each line.
11. The message parsing device according to claim 9, wherein the third parsing module is specifically configured to: when the JSON format is adopted, according to characters in the JSON format message, reserved characters and analysis rules are set in the JavaCC to generate an analysis function;
and calling an analysis function to analyze the message body character string to obtain the numerical value corresponding to each variable in the message body.
12. The message parsing apparatus according to claim 7, further comprising: the fourth analysis module is used for extracting sub-character strings with preset digits from preset positions in the character strings of the HTTP message according to a preset non-standard HTTP message generation rule when the received HTTP message is a non-standard HTTP message, and obtaining custom data and a standard HTTP message; analyzing the user-defined data according to a pre-agreed non-standard HTTP message analysis rule to obtain a numerical value corresponding to each variable in the user-defined data; the non-standard HTTP message analysis rule is obtained according to the non-standard HTTP message generation rule;
the storage module is further configured to store each variable in the custom data and a numerical value corresponding to each variable as data in a single key-value format.
13. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any one of claims 1 to 6 when executing the computer program.
14. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which, when executed by a processor, implements the method of any one of claims 1 to 6.
15. A computer program product, characterized in that the computer program product comprises a computer program which, when being executed by a processor, carries out the method of any one of claims 1 to 6.
CN202111415195.2A 2021-11-25 2021-11-25 Message parsing method and device Pending CN114124918A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111415195.2A CN114124918A (en) 2021-11-25 2021-11-25 Message parsing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111415195.2A CN114124918A (en) 2021-11-25 2021-11-25 Message parsing method and device

Publications (1)

Publication Number Publication Date
CN114124918A true CN114124918A (en) 2022-03-01

Family

ID=80373337

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111415195.2A Pending CN114124918A (en) 2021-11-25 2021-11-25 Message parsing method and device

Country Status (1)

Country Link
CN (1) CN114124918A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114760374A (en) * 2022-03-22 2022-07-15 中国工商银行股份有限公司 Message parsing method and device, electronic equipment and medium
CN115292624A (en) * 2022-10-08 2022-11-04 成都同步新创科技股份有限公司 Universal message processing method and device based on HTTP (hyper text transport protocol)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108628634A (en) * 2018-05-09 2018-10-09 平安普惠企业管理有限公司 Message configuration method, device, computer equipment and storage medium
CN113660250A (en) * 2021-08-12 2021-11-16 杭州安恒信息技术股份有限公司 Defense method, device and system based on WEB application firewall and electronic device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108628634A (en) * 2018-05-09 2018-10-09 平安普惠企业管理有限公司 Message configuration method, device, computer equipment and storage medium
CN113660250A (en) * 2021-08-12 2021-11-16 杭州安恒信息技术股份有限公司 Defense method, device and system based on WEB application firewall and electronic device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
MANDYCHENG: "Http报文解析", pages 1 - 7, Retrieved from the Internet <URL:https://www.cnblogs.com/MandyCheng/p/11151803.html> *
小盼你最萌哒: "GET请求的响应报文笔记", pages 1 - 7, Retrieved from the Internet <URL:https://blog.csdn.net/qq_27508477/article/details/105393880> *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114760374A (en) * 2022-03-22 2022-07-15 中国工商银行股份有限公司 Message parsing method and device, electronic equipment and medium
CN114760374B (en) * 2022-03-22 2023-12-05 中国工商银行股份有限公司 Message parsing method and device, electronic equipment and medium
CN115292624A (en) * 2022-10-08 2022-11-04 成都同步新创科技股份有限公司 Universal message processing method and device based on HTTP (hyper text transport protocol)
CN115292624B (en) * 2022-10-08 2023-08-04 成都同步新创科技股份有限公司 General message processing method and device based on HTTP protocol

Similar Documents

Publication Publication Date Title
CN114124918A (en) Message parsing method and device
CN109450900B (en) Mimicry judgment method, device and system
CN110287163B (en) Method, device, equipment and medium for collecting and analyzing security log
CN106547520B (en) Code path analysis method and device
CN102279738A (en) Identifying entries and exits of strongly connected components
CN110083746B (en) Quick matching identification method and device based on character strings
CN109800337B (en) Multi-mode regular matching algorithm suitable for large alphabet
CN105574032A (en) Rule matching operation method and device
CN115913655B (en) Shell command injection detection method based on flow analysis and semantic analysis
CN110263104A (en) JSON character string processing method and device
CN110333990B (en) Data processing method and device
CN112052413A (en) URL fuzzy matching method, device and system
CN105335245A (en) Fault storage method and apparatus and fault search method and apparatus
CN111061927B (en) Data processing method and device and electronic equipment
CN110727828B (en) Business function execution method and device, electronic equipment and storage medium
CN104462322A (en) Method and device for contrasting character strings
CN112069305A (en) Data screening method and device and electronic equipment
CN115344538A (en) Log processing method, device and equipment and readable storage medium
CN113468866B (en) Method and device for analyzing non-standard JSON string
CN113821211B (en) Command parsing method and device, storage medium and computer equipment
CN111352932B (en) Method and device for improving data processing efficiency based on bitmap tree algorithm
CN108881125B (en) Method, storage medium, device and system for analyzing communication protocol
EP3793171A1 (en) Message processing method, apparatus, and system
CN117828382B (en) Network interface clustering method and device based on URL
CN112187700A (en) WAF security rule matching method, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination