A method for filtering HTTP request data

Through the combination of custom request mapping, script mapping and improved prefix tree, the error judgment, deletion and expansion problems of Bloom filter in HTTP request filtering are solved, and efficient and flexible HTTP request filtering is achieved, saving memory resources .

CN118660009BActive Publication Date: 2024-12-27CHINA LIFE INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411154558.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-22
Publication Date
2024-12-27
Estimated Expiration
2044-08-22

AI Technical Summary

Technical Problem

The existing Bloom filters have problems such as misjudgment, difficulty in deletion, inability to reuse and inability to scale in HTTP request data filtering, and do not store values, resulting in waste of memory resources.

Method used

Use custom request mapping, custom script mapping and improved version prefix tree to realize dynamic filtering through Map and Java scripts. The improved version prefix tree serves as a multi-level custom HashMap data structure to store actual values ​​to solve misjudgment and deletion difficulties. Supports user-defined extensions.

Benefits of technology

It achieves low misjudgment rate, easy deletion and memory savings, supports flexible expansion, improves the flexibility and efficiency of HTTP request filtering, and avoids hash collisions and expansion restrictions of Bloom filters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118660009B_ABST
    Figure CN118660009B_ABST
Patent Text Reader

Abstract

The present invention provides a method for filtering HTTP request data, which implements filtering of specified HTTP requests based on custom filtering request mapping, determines whether data exists based on custom filtering scripts and improved prefix trees, and perfectly solves various problems existing in Bloom filters such as misjudgment, difficulty in deletion, and inability to reuse. The improved prefix tree is a multi-level custom HashMap data structure, which realizes unlimited reuse of key data, thereby saving memory resources, and because the improved prefix tree stores values, there is no misjudgment and deletion is very easy. The values ​​of the child nodes of the improved prefix tree are ordered one-dimensional arrays, so the speed of retrieving keys and values ​​is very fast.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method for filtering HTTP request data. Background Art

[0002] In HTTP request data filtering, Bloom filter is generally used to implement it. Bloom filter is actually a very long binary vector and a series of randomly mapped hash functions. Bloom filter can be used to retrieve whether an element is "possibly in the set" or "definitely not in the set", that is, there is a certain misjudgment rate and Bloom filter does not store values, but stores the value of the element after a series of random mapping hash functions. The design of Bloom filter leads to some unsolvable defects: first, it is difficult to delete due to non-storage of values, second, there are misjudgments due to hash conflicts, third, it cannot be reused, and fourth, it cannot be expanded. In order to solve the above problems, the present invention designs a new method, which realizes the storage of actual values ​​to solve the problems of misjudgment, difficulty in deletion, and inability to reuse through custom request mapping, custom script mapping and improved prefix tree, saves memory resources, and supports user-defined extensions. Summary of the invention

[0003] The purpose of the present invention is to solve the shortcomings in the prior art and to propose a method for filtering HTTP request data.

[0004] To achieve the above object, the present invention adopts the following technical solution: a method for filtering HTTP request data, the method is as follows:

[0005] S1: Create a custom request filter to receive HTTP requests;

[0006] Create a custom request filter, which will filter all received HTTP requests and intercept or release them according to the situation;

[0007] S2: Get the URI from the HTTP request, determine whether the URI exists in the filter request mapping based on the URI, and perform corresponding operations;

[0008] S21: Get URI from HTTP request;

[0009] S22: judging whether there is a key in the filter request mapping that is the same as the obtained URI according to the value of the URI;

[0010] The filtering request mapping is a Map type of data, the key is URI, and the value is URI alias and parameter name;

[0011] Users can add URIs, URI aliases, and parameter names to the filter request mapping, or delete the URIs specified in the filter request mapping to achieve flexible and dynamic filtering of HTTP requests;

[0012] S23: If the same URI does not exist in the filter request mapping, the HTTP request is allowed;

[0013] S24: if the same URI exists in the filter request mapping, obtain a value whose key is the same URI from the filter request mapping, and obtain the URI alias and parameter name from the value;

[0014] S25: According to the parameter name, obtain the parameter value corresponding to the parameter name from the HTTP request.

[0015] S3: Determine whether there is a key with the URI in the filter script map according to the URI and perform corresponding operations;

[0016] S31: judging whether there is a URI with the same key in the filtering script mapping according to the URI and performing corresponding operations;

[0017] The filtering script map is a Map type of data, the key is the URI, and the value is the custom script statement;

[0018] The custom script is a Java source code that implements a specified script interface.

[0019] Users can add URIs and custom script statements to the filter script mapping, and delete the URIs specified in the filter script mapping to achieve flexible dynamic judgment and interception of HTTP requests;

[0020] S32: If the same URI does not exist in the filtering script mapping, execute step S4;

[0021] S33: if the same URI exists in the filter script map, obtain a value whose key is the same URI from the filter script map, that is, the custom script statement;

[0022] S34: Create a script executor to execute custom script statements;

[0023] S35: If the result returned by the custom script statement is true, the HTTP request is allowed;

[0024] S36: If the result returned by the custom script statement is false, execute step S4.

[0025] S4: judging whether there is data in the improved prefix tree that has a false result returned by the custom script statement in step S3 according to the URI alias and parameter value, and performing corresponding operations;

[0026] S41: According to the URI alias and the parameter value, with the parameter value as the key and the URI alias as the value, query whether there is a key-value pair with the parameter value in the improved prefix tree;

[0027] The improved prefix tree is a multi-level custom HashMap type data structure, which is a multi-branch tree structure used for fast retrieval.

[0028] The improved prefix tree has the following characteristics:

[0029] The key of custom HashMap type data is character type, and the value is custom HashMap type and one-dimensional ordered array; the root node and each child node contain a character type key and a one-dimensional ordered array type value; all characters on the path from the root node to a child node constitute the string corresponding to the node, which is used to store the data to be queried, that is, the parameter value. The value stored in the node is a one-dimensional array, and the data in the array is a URI alias; by judging whether the node has the specified value, it is judged whether the data to be queried exists; to delete data, it is only necessary to delete the value in the one-dimensional array on the corresponding child node; if a terminal child node has no value, delete the terminal child node; child nodes can have one or more layers.

[0030] S42: If a key-value pair with the parameter value exists in the improved prefix tree, the HTTP request is allowed;

[0031] S43: If the key-value pair with the parameter value does not exist in the improved prefix tree, the request is intercepted and the illegal request information is responded to.

[0032] Compared with the prior art, the present invention has the following beneficial effects:

[0033] The present invention provides a method for filtering HTTP request data, which implements filtering of specified HTTP requests based on custom filtering request mapping, determines whether data exists based on custom filtering scripts and improved prefix trees, and perfectly solves the problems of Bloom filters such as misjudgment, difficulty in deletion, inability to reuse and inability to expand. The improved prefix tree is a multi-level custom HashMap data structure, which realizes unlimited reuse of key data, thereby saving memory resources, and because the improved prefix tree stores values, there is no misjudgment and deletion is very easy. The nodes of the improved prefix tree are of HashMap type, and the values ​​are ordered one-dimensional arrays. The hash method is used to retrieve keys and the binary method is used to retrieve values, and the speed is very fast. Users can add, modify and delete URI related information in the custom request mapping at any time according to needs, and the custom filtering script filters HTTP requests with very high flexibility, avoiding the problem that the Bloom filter can only rely on hash functions and cannot be expanded. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 It is a schematic diagram of the process of the present invention. DETAILED DESCRIPTION

[0035] In order to provide a further understanding of the purpose, structure, features, and functions of the present invention, the following detailed description is given in conjunction with the embodiments.

[0036] Please refer to Figure 1 , the present invention provides a method for filtering HTTP request data.

[0037] To achieve the above object, the present invention adopts the following technical solution: a method for filtering HTTP request data, the method is as follows:

[0038] S1: Create a custom request filter to receive HTTP requests;

[0039] Create a custom request filter, which will filter all received HTTP requests and intercept or release them according to the situation;

[0040] S2: Obtain the URI from the HTTP request, determine whether there is a filter request mapping that is identical to the obtained URI based on the URI, and perform corresponding operations;

[0041] S21: Get URI from HTTP request;

[0042] S22: judging whether there is a key in the filter request mapping that is the same as the obtained URI according to the value of the URI;

[0043] The filtering request mapping is a Map type of data, the key is URI, and the value is URI alias and parameter name;

[0044] Users can add URIs, URI aliases, and parameter names to the filter request mapping, or delete the URIs specified in the filter request mapping to achieve flexible and dynamic filtering of HTTP requests;

[0045] S23: If the same URI does not exist in the filter request mapping, the HTTP request is allowed;

[0046] S24: if the same URI exists in the filter request mapping, obtain a value whose key is the same URI from the filter request mapping, and obtain the URI alias and parameter name from the value;

[0047] S25: According to the parameter name, obtain the parameter value corresponding to the parameter name from the HTTP request.

[0048] S3: Determine whether there is a URI with the same key in the filter script map according to the URI and perform corresponding operations;

[0049] S31: judging whether there is a URI with the same key in the filtering script mapping according to the URI;

[0050] The filtering script map is a Map type of data, the key is the URI, and the value is the custom script statement;

[0051] The custom script is a Java source code that implements a specified script interface.

[0052] Users can add URIs and custom script statements to the filter script mapping, and delete the URIs specified in the filter script mapping to achieve flexible dynamic judgment and interception of HTTP requests;

[0053] S32: If the same URI does not exist in the filtering script mapping, execute step S4;

[0054] S33: if the same URI exists in the filter script map, obtain a value whose key is the same URI from the filter script map, that is, the custom script statement;

[0055] S34: Create a script executor to execute custom script statements;

[0056] S35: If the result returned by the custom script statement is true, the HTTP request is allowed;

[0057] S36: If the result returned by the custom script statement is false, execute step S4.

[0058] S4: judging whether there is data in the improved prefix tree that has a false result returned by the custom script statement in step S3 according to the URI alias and parameter value, and performing corresponding operations;

[0059] S41: According to the URI alias and the parameter value, with the parameter value as the key and the URI alias as the value, query whether there is a key-value pair with the parameter value in the improved prefix tree;

[0060] The improved prefix tree is a multi-level custom HashMap type data structure, which is a multi-branch tree structure used for fast retrieval.

[0061] The improved prefix tree has the following characteristics:

[0062] The key of the custom HashMap type data is of character type, and the value is of custom HashMap type. In addition, the custom HashMap type data also stores an additional one-dimensional ordered array; the root node and each child node contain a key of character type and a value of one-dimensional ordered array type.

[0063] Using characters as keys allows for efficient hierarchical lookups. The ordered arrays stored in each node can help speed up query and update operations for specific prefixes or paths; at the same time, since each node can store its own state information (through an ordered array), when processing dynamic data (such as insertion and deletion operations), data can be quickly updated or adjusted without recalculating the entire structure.

[0064] All characters on the path from the root node to a child node form the string corresponding to the node, which is used to store the data to be queried. By judging whether the node has a specified value, it is determined whether the data to be queried exists. To delete data, you only need to delete the specified value on the corresponding child node. If a terminal child node has no value, delete the terminal child node.

[0065] By removing terminal child nodes with no values, the prefix tree can keep the storage overhead small; this avoids storing redundant data and optimizes memory usage.

[0066] Nodes are created only when needed and can be deleted as needed, which simplifies node management. Especially when dealing with dynamic data, the height of the tree and the number of nodes can be effectively reduced.

[0067] S42: If a key-value pair with the parameter value exists in the improved prefix tree, the HTTP request is allowed;

[0068] S43: If the key-value pair with the parameter value does not exist in the improved prefix tree, the request is intercepted and the illegal request information is responded to.

[0069] The present invention has been described by the above-mentioned relevant embodiments, however, the above-mentioned embodiments are only examples for implementing the present invention. It must be pointed out that the disclosed embodiments do not limit the scope of the present invention. On the contrary, changes and modifications made without departing from the spirit and scope of the present invention are all within the scope of patent protection of the present invention.

Claims

1. A method for filtering HTTP request data, characterized in that: The method is specifically as follows: S1: Create a custom request filter to receive HTTP requests; Create a custom request filter, which will filter all received HTTP requests and intercept or release them according to the situation; S2: Obtain the URI from the HTTP request, determine whether there is a filter request mapping that is identical to the obtained URI based on the URI, and perform corresponding operations; Get the URI from the HTTP request; Based on the value of the URI, determine whether there is a key in the filter request mapping that is the same as the obtained URI; The filtering request mapping is a Map type of data, the key is URI, and the value is URI alias and parameter name; The user adds URI, URI alias and parameter name to the filter request mapping, and deletes the URI specified in the filter request mapping to achieve flexible and dynamic filtering of HTTP requests; If the same URI does not exist in the filter request mapping, the HTTP request is allowed; If the same URI exists in the filter request mapping, the value with the same URI as the key is obtained from the filter request mapping, and the URI alias and parameter name are obtained from the value; According to the parameter name, obtain the parameter value corresponding to the parameter name from the HTTP request; S3: judging whether there is a URI with the same key in the filter script mapping according to the URI and performing corresponding operations; Based on the URI, determine whether there is a URI with the same key in the filter script map; The filtering script map is a Map type of data, the key is the URI, and the value is the custom script statement; The custom script is a Java source code that implements a specified script interface; Users can add URIs and custom script statements to the filter script mapping, and delete the URIs specified in the filter script mapping to achieve flexible dynamic judgment and interception of HTTP requests; If the same URI does not exist in the filtering script mapping, execute step S4; If the same URI exists in the filter script map, the value with the same URI as the key is obtained from the filter script map, that is, the custom script statement; Create a script executor to execute custom script statements; If the custom script statement returns true, the HTTP request is allowed; If the result returned by the custom script statement is false, execute step S4; S4: judging whether there is data in the improved prefix tree that has a false result returned by the custom script statement in step S3 according to the URI alias and parameter value, and performing corresponding operations; According to the URI alias and parameter value, the parameter value is used as the key and the URI alias is used as the value to query whether there is a key-value pair with the parameter value in the improved prefix tree; The improved prefix tree is a multi-level custom HashMap type data structure, which is a multi-branch tree structure used for fast retrieval; If there is a key-value pair with the parameter value in the improved prefix tree, the HTTP request is allowed; If the key-value pair with the parameter value does not exist in the improved prefix tree, the request is intercepted and the illegal request information is responded.

2. A method for filtering HTTP request data as claimed in claim 1, characterized in that: The root node and each child node in the improved prefix tree include a key of character type and a value of one-dimensional ordered array type.

3. A method for filtering HTTP request data as claimed in claim 1, characterized in that: All characters on the path from the root node to a child node in the improved prefix tree form a string corresponding to the node, which is used to store the data to be queried, i.e., the parameter value. The value stored in the node is a one-dimensional array, and the data in the array is a URI alias. To delete the data, you only need to delete the value in the one-dimensional array on the corresponding child node. If a terminal child node has no value, the terminal child node is deleted.

4. A method for filtering HTTP request data as claimed in claim 1, characterized in that: The improved prefix tree has one or more layers of child nodes.