CN104954415B - Handle the method and device of HTTP request - Google Patents
Handle the method and device of HTTP request Download PDFInfo
- Publication number
- CN104954415B CN104954415B CN201410495917.3A CN201410495917A CN104954415B CN 104954415 B CN104954415 B CN 104954415B CN 201410495917 A CN201410495917 A CN 201410495917A CN 104954415 B CN104954415 B CN 104954415B
- Authority
- CN
- China
- Prior art keywords
- path
- node
- character
- access
- http request
- 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.)
- Active
Links
Landscapes
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The invention discloses a kind of method and devices for handling HTTP request, wherein this method comprises: receiving the HTTP request that client is sent;The access path by string representation is obtained from HTTP request;It is searched and the matched destination path of access path in the path node set with tree pre-established, wherein, a path being allowed access to is indicated from root node to the path node subclass of each leaf node in path node set, and identical continuation character string is indicated by multiple connected path nodes in a path node subclass including root node in different paths;If found in path node set with the matched destination path of access path, execute request indicated by HTTP request operation.The present invention solves the lower technical problem of the efficiency verified in the prior art when handling HTTP request to HTTP request.
Description
Technical field
The present invention relates to computer fields, in particular to a kind of method and device for handling HTTP request.
Background technique
Currently, being frequently necessary to use " white list " in many application scenarios, wherein " white list " and " blacklist " is opposite
It answers.For example, if being arranged and enabling blacklist in computer system, it is formulated into user (or the IP address, IP of blacklist
Packet, mail, virus etc.) it will not pass through verification.Similarly, if being arranged and enabling white list in computer system,
User's (or IP address, IP packet, mail etc.) in white list can pass through verification, it might even be possible to and it is preferential by verifying, without
Being treated as illegal user's (or illegal IP address, illegal IP packet, spam, virus etc.) can not be by verification, such safety
It is all greatly improved with agility.
It is in the conventional technology, main to the matching of " white list " to carry out lookup matching by the way of traversing whole arrays,
It in this way if " white list " number is more, then requires a great deal of time in search procedure, thus greatly reduces behaviour
Make efficiency, and since " white list " mode that some applications need is different, it is relatively low using the versatility of aforesaid way.
By taking the verification to HTTP request as an example, pre-set " white list " is stored in the form of array, wherein array is such as
Shown in following table:
Array member | The path being allowed access to |
1 | www.AB.com |
2 | www.AC.com |
3 | www.ABC.com |
If the access path in HTTP request are as follows: www.ABC.com then needs the access path in HTTP request successively
It is matched with the path being allowed access to recorded in above-mentioned each array member.For example, according to the sequence of character, successively
Compare the path " www.AB.com " being allowed access to recorded in " www.ABC.com " sum number group membership 1;Finding the two not
When matching, then again according to the sequence of character, successively compare recorded in " www.ABC.com " sum number group membership 2 be allowed to visit
The path " www.AC.com " asked, and so on, until having traversed all array members.
However, in above-mentioned matched process, if finding to record in the access path and a several group memberships in HTTP request
The path that is allowed access to mismatch, then need the from the path being allowed access to recorded in another array member
One character start to judge whether again with the access path in HTTP request, this results in when handling HTTP request pair
The efficiency that HTTP request is verified is lower.
For above-mentioned problem, currently no effective solution has been proposed.
Summary of the invention
The embodiment of the invention provides a kind of method and devices for handling HTTP request, at least to solve to exist in the prior art
The lower technical problem of the efficiency that HTTP request is verified when handling HTTP request.
According to an aspect of an embodiment of the present invention, a kind of method for handling HTTP request is provided, comprising: receive client
Hold the HTTP request sent;The access path by string representation is obtained from HTTP request;It is pre-establishing with tree-shaped
It is searched and the matched destination path of access path in the path node set of structure, wherein from root node in path node set
Path node subclass to each leaf node indicates a path being allowed access to, identical continuous in different paths
Character string is indicated by multiple connected path nodes in a path node subclass including root node;If being saved in path
Found in point set with the matched destination path of access path, then execute request indicated by HTTP request operation.
According to another aspect of an embodiment of the present invention, a kind of device for handling HTTP request is additionally provided, comprising: receive single
Member, for receiving the HTTP request of client transmission;Acquiring unit, for obtaining the visit by string representation from HTTP request
It asks the way diameter;Searching unit, for being searched and access path in the path node set with tree pre-established
The destination path matched, wherein indicate one from root node to the path node subclass of each leaf node in path node set
The path that item is allowed access to, identical continuation character string is by including root section in a path node subclass in different paths
Multiple connected path nodes including point indicate;Execution unit, for being found in path node set and access path
When matched destination path, the operation of request indicated by HTTP request is executed.
In embodiments of the present invention, the path being allowed access in white list is indicated using tree, and for not
With path in identical continuation character string, only indicate primary by identical path node, without such as institute in the prior art
What is used is indicated by different array members respectively.In this way, not needing traversal each root section during lookup
It puts to path represented by leaf node, it can whether the access path for judging HTTP request is to be allowed to visit in white list
The path asked to improve the efficiency verified when handling HTTP request to HTTP request, and then solves and is handling
The lower technical problem of the efficiency that HTTP request is verified when HTTP request.
Detailed description of the invention
The drawings described herein are used to provide a further understanding of the present invention, constitutes part of this application, this hair
Bright illustrative embodiments and their description are used to explain the present invention, and are not constituted improper limitations of the present invention.In the accompanying drawings:
Fig. 1 is a kind of schematic diagram of optional network environment according to an embodiment of the present invention;
Fig. 2 is a kind of flow chart of the method for optional processing HTTP request according to an embodiment of the present invention;
Fig. 3 is a kind of schematic diagram of optionally path node set with tree according to an embodiment of the present invention;
Fig. 4 is the signal of another optionally path node set with tree according to an embodiment of the present invention
Figure;
Fig. 5 is according to an embodiment of the present invention a kind of optionally in the mistake for establishing the path node set with tree
The schematic diagram of path node set in journey;
Fig. 6 is another path node set optionally in foundation with tree according to an embodiment of the present invention
The schematic diagram of path node set in the process;
Fig. 7 be it is according to an embodiment of the present invention another optionally establish have tree path node set
The schematic diagram of path node set in the process;
Fig. 8 is a kind of structural block diagram of the device of optional processing HTTP request according to an embodiment of the present invention;
Fig. 9 is the structural block diagram of the device of another optional processing HTTP request according to an embodiment of the present invention;
Figure 10 is the structural block diagram of the device of another optional processing HTTP request according to an embodiment of the present invention;
Figure 11 is the structural block diagram of the device of another optional processing HTTP request according to an embodiment of the present invention;
Figure 12 is the structural block diagram of the device of another optional processing HTTP request according to an embodiment of the present invention.
Specific embodiment
In order to enable those skilled in the art to better understand the solution of the present invention, below in conjunction in the embodiment of the present invention
Attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is only
The embodiment of a part of the invention, instead of all the embodiments.Based on the embodiments of the present invention, ordinary skill people
The model that the present invention protects all should belong in member's every other embodiment obtained without making creative work
It encloses.
It should be noted that description and claims of this specification and term " first " in above-mentioned attached drawing, "
Two " etc. be to be used to distinguish similar objects, without being used to describe a particular order or precedence order.It should be understood that using in this way
Data be interchangeable under appropriate circumstances, so as to the embodiment of the present invention described herein can in addition to illustrating herein or
Sequence other than those of description is implemented.In addition, term " includes " and " having " and their any deformation, it is intended that cover
Cover it is non-exclusive include, for example, the process, method, system, product or equipment for containing a series of steps or units are not necessarily limited to
Step or unit those of is clearly listed, but may include be not clearly listed or for these process, methods, product
Or other step or units that equipment is intrinsic.
Embodiment 1
Step shown in the flowchart of the accompanying drawings can be in a computer system such as a set of computer executable instructions
It executes, although also, logical order is shown in flow charts, and it in some cases, can be to be different from herein suitable
Sequence executes shown or described step.
Optionally, in the present embodiment, the method for above-mentioned processing HTTP request can be, but not limited to be applied to as shown in Figure 1
Network environment in, wherein send HTTP request client can be, but not limited to be located at terminal 102 shown in FIG. 1 in, Fig. 1
Shown in server 104 will receive above-mentioned HTTP request by network, wherein above-mentioned server 104 can also be replaced with terminal.
Optionally, in the present embodiment, above-mentioned network can include but is not limited to: wide area network, Metropolitan Area Network (MAN), local area network.Above-mentioned server
104 by from above-mentioned HTTP request obtain by string representation access path, and search with the matched mesh of above-mentioned access path
Path is marked, and after finding above-mentioned destination path, executes the operation of request indicated by above-mentioned HTTP request.Optionally, at this
In embodiment, above-mentioned terminal be can include but is not limited to: mobile phone, tablet computer, laptop, PC machine.
Optionally, in the present embodiment, the flow chart of the method for above-mentioned processing HTTP request can be as shown in Fig. 2, the party
Method includes:
S202 receives the HTTP request that client is sent;Optionally, above-mentioned HTTP request can receive for server 104
To terminal 102 on the client installed send for accessing the HTTP request of webpage.It optionally, can in above-mentioned HTTP request
With but be not limited to include: access path, for example, above-mentioned access path can be, but not limited to as the network address of above-mentioned webpage, e.g.,
" Host:o.mCGI:/t ", Huo Zhewei, " Host:m.o.m ".
The access path for including in above-mentioned HTTP request may include Host field and/or CGI (common gateway interface,
Common Gateway Interface) field, wherein above-mentioned Host can be, but not limited in Internet protocol, indicate energy
Enough local computers accessed mutually with other machines.For example, a local has unique designation code, together with netmask
IP address is formed, if accessing internet by ISP by peer-peer protocol, unique IP will be possessed during the connection
Address, in this case, Host indicate a network node.Above-mentioned CGI is physically one section run on the server
Program, for providing the interface with client html page.
S204 obtains the access path by string representation from HTTP request;
S206 is searched and the matched target of access path in the path node set with tree pre-established
Path, wherein indicate one to the path node subclass of each leaf node from root node in path node set and be allowed to
The path of access, in different paths identical continuation character string by a path node subclass including root node
Multiple connected path nodes indicate;
Optionally, Fig. 3 shows a kind of schematic diagram of the path node set with tree pre-established, needs
Illustrate, path node set shown in Fig. 3 is only a kind of example, and the path node set in the present embodiment can be according to not
Same scene is configured, as shown in Figure 4.
As shown in figure 3, the path node set with tree can be used to indicate that 4 paths being allowed access to:
Specifically, as shown in figure 3, the expression of path node subclass 1 of root node " H, root " to leaf node " D, P, t "
Above-mentioned path 1).That is, in path node subclass 1 path node " H, root ", " H, S, HOST ", " D, S, m ", " D, S, ",
" D, S, o ", " D, P, CGI ", " D, P ,/", " D, P, t " indicate above-mentioned path 1) " Host:o.m CGI:/t ";
The path node subclass 2 of D, S, m " indicate above-mentioned path 2 to root node " H, root " to leaf node ").That is, road
In diametral pitch point subclass 2 path node " H, root ", " H, S, HOST ", " D, S, m ", " D, S, ", " D, S, o ", " D, S, ",
" D, S, m " indicate above-mentioned path 2) " Host:m.o.m CGI:null ";
The path node subclass 3 of D, P, m " indicate above-mentioned path 3 to root node " H, root " to leaf node ").That is, road
In diametral pitch point subclass 3 path node " H, root ", " H, S, HOST ", " D, S, n ", " D, S, ", " D, S, o ", " D, P,
CGI ", " D, P ,/", " D, P, m " indicate above-mentioned path 3) " Host:o.n CGI:/m ";
The path node subclass 4 of D, P, n " indicate above-mentioned path 4 to root node " H, root " to leaf node ").That is, road
In diametral pitch point subclass 4 path node " H, root ", " H, S, HOST ", " D, S, n ", " D, S, ", " D, S, o ", " D, P,
CGI ", " D, P ,/", " D, P, n " indicate above-mentioned path 4) " Host:o.n CGI:/n ".
Wherein, above-mentioned path 1) and 2) shared path node " H, root ", " H, S, HOST ", " D, S, m ", " D, S, ",
"D,S,o".That is, above-mentioned path 1) and 2) in identical continuation character string " Host:o.m " by above-mentioned path node " H,
Root ", " H, S, HOST ", " D, S, m ", " D, S, ", " D, S, o " are indicated.
Similarly, above-mentioned path 3) and 4) shared path node " H, root ", " H, S, HOST ", " D, S, n ", " D,
S, ", " D, S, o ", " D, P, CGI ", " D, P ,/".That is, above-mentioned path 3) and 4) in identical continuation character string
" Host:o.n CGI :/" by above-mentioned path node " H, root ", " H, S, HOST ", " D, S, n ", " D, S, ", " D, S, o ", " D,
P, CGI ", " D, P ,/" indicate.
In Fig. 3, path 1) -4) in HOST field in character (for example, path 1) in " o.m ") according to " from rear
Sew prefix " sequence passage path node indicate.By taking path 1 as an example, the character in HOST field is " o.m ", wherein
" m " is suffix, and " n " is prefix, and the sequence of above-mentioned " from suffix to prefix " refers to: " D, S, m " are path node to path node
" child node of H, S, HOST ", " D, S, " are that " child node of D, S, m ", " D, S, o " are path node to path node to path node
" the child node of D, S, ".In other words, " H, S, HOST ", " D, S, m ", " D, S, ", " D, S, o " are sequentially connected.
It should be noted that the above-mentioned sequence passage path node according to " from suffix to prefix " indicates path 1) -4)
In HOST field in character be only a kind of example, the present embodiment is not limited only to this, for example, it is also possible to according to " from prefix to
Suffix " or the sequence passage path node of " since prefix " indicate path 1) -4) in HOST field in character,
In, it only includes prefix, without the scene including suffix that the sequence of " since prefix ", which is suitable for HOST field,.By taking path 1 as an example,
Character in HOST field is " o.m ", wherein " m " is suffix, and " n " is prefix, what the sequence of above-mentioned " from prefix to suffix " referred to
Be: path node " D, S, o " be path node " child node of H, S, HOST ", path node " D, S, " be path node " D, S,
The child node of o ", " D, S, m " are the path node " child node of D, S, ".
Optionally, it is searched and the matched mesh of access path in the path node set with tree pre-established
During marking path, can since compare root node the character in access path and the character in path node whether phase
Together.Since path node set has tree, by the character in access path and with multiple child node (examples
Such as, child node 1 " D, P, CGI ", child node 2 " D, S, ") path node (node " D, S, o ") be compared after, Ke Yixuan
The branch where said one child node (for example, child node 1 " D, P, CGI ") is selected (for example, " D, P, CGI " arrive leaf to child node 1
Node " D, P, t ") continue to continue to compare with character remaining in access path.If branch's comparison result failure is (for example, access
Path is " Host:m.o.m ", corresponding to the path 2 in Fig. 3)), this goes to other sub- sections of path node (node " D, S, o ")
Branch where point (for example, child node 2 " D, S, ") is compared, without compare again again path node (node " D,
S, o ") before compared node (for example, " H, root ", " H, S, HOST ", " D, S, m ", " D, S, ", " D, S, o "),
To reduce the number of comparison, that is, improve the efficiency verified when handling HTTP request to HTTP request.
That is, identical continuation character string at most only needs to compare one during comparison in different paths
It is secondary, that is, to judge to whether there is and the matched destination path of access path in the path node set with tree.
S208, if found in path node set with the matched destination path of access path, execute HTTP request
Indicated request operation.
Optionally, in the present embodiment, the above-mentioned path node set with tree pre-established can be used to
The path being allowed access to recorded in " white list " is indicated, for example, the every road being allowed access to recorded in " white list "
Diameter can be by indicating from root node to the path node subclass of a leaf node.In other words, it is recorded in " white list "
The path being allowed access to is indicated by tree.Optionally, in above-mentioned S208, if being searched in path node set
To with the matched destination path of access path, then it represents that access path in HTTP request is being allowed to of recording in " white list "
The path of access.
In embodiments of the present invention, the path being allowed access in white list is indicated using tree, and for not
With path in identical continuation character string, only indicate primary by identical path node, without such as institute in the prior art
What is used is indicated by different array members respectively.In this way, not needing traversal each root section during lookup
It puts to path represented by leaf node, it can whether the access path for judging HTTP request is to be allowed to visit in white list
The path asked to improve the efficiency verified when handling HTTP request to HTTP request, and then solves and is handling
The lower technical problem of the efficiency that HTTP request is verified when HTTP request.
As a kind of optional scheme, searches and access in the path node set with tree pre-established
After the destination path of route matching, the method for above-mentioned processing HTTP request further include: if not searched in path node set
To with the matched destination path of access path, then sent to client and be used to indicate the response message of denied access.In other words,
If not found in path node set and the matched destination path of access path, then it represents that the access path in HTTP request
The not path being allowed access to be recorded in " white list ".
Optionally, in the present embodiment, before receiving the HTTP request that client is sent, need to pre-establish above-mentioned tool
There is the path node set of tree.It describes to establish below in conjunction with specific example and attached drawing above-mentioned with tree
The scheme of path node set.It should be noted that following scheme is only a kind of example, established in the present embodiment above-mentioned with tree
The scheme of the path node set of shape structure is not limited only to this.
Optionally, in the present embodiment, before receiving the HTTP request that client is sent, above-mentioned processing HTTP request
Method further include:
Root node is arranged, such as root node " H, root " in Fig. 3 in S1;
The child node (for example, " H, S, HOST ") of root node is arranged, wherein the character list for including in each child node in S2
Show the HOST field in path that one is allowed access to, the identical HOST field in the different paths being allowed access to by
The character representation for including in one child node;
Multiple path nodes are arranged until leaf node in S3 under each child node, wherein different to be allowed access to
Identical continuation character string is indicated by multiple connected path nodes in multiple path nodes in path.
By taking the path being allowed access to includes 4 paths in Fig. 3 as an example, Fig. 5-Fig. 7 is shown with tree
The establishment process of path node set.
As shown in figure 5, path node set is initialized as sky, on this basis, road first is formed in path node set
Diameter 1) " Host:o.m CGI:/t " tree, that is, path node " H, root ", " H, S, HOST ", " D, S, m ", " D,
S, ", " D, S, o ", " D, P, CGI ", " D, P ,/", " D, P, t " are sequentially connected.
Further, on the basis of Fig. 5, then path 2 is formed in path node set) " Host:m.o.m CGI:
null".Due to path 1) and 2) continuation character string " Host:o.m " having the same, thus, it is only required to will on the basis of Fig. 5,
By path node, " D, S, " are set as the path node " child node of D, S, o ", then " D, S, m " are set as path by path node
Node " child node of D, S, ", as shown in Figure 6.In Fig. 6, above-mentioned path 1) and 2) shared path node " H, root ",
" H, S, HOST ", " D, S, m ", " D, S, ", " D, S, o ".
In an identical manner, on the basis of Fig. 6, then path 3 is formed in path node set) " Host:o.n
CGI:/m".Due to path 3) in HOST field in character " n " and path 1) and path 2) in HOST field in character
" m " is different, and therefore, by path node, " D, S, n " are as a path node " new child node of H, S, HOST ", and in path
Node " is sequentially connected path node " D, S, ", " D, S, o ", " D, P, CGI ", " D, P ,/", " D, P, m ", Fig. 7 after D, S, n "
It is shown.
Further, on the basis of Fig. 7, then path 4 is formed in path node set) " Host:o.nCGI:/n ".By
In above-mentioned path 3) and 4) continuation character string having the same " Host:o.n CGI :/", thus, it is only required to will be on the basis of Fig. 7
On, by path node, " D, P, n " are set as the child node of path node " D, P ,/", as shown in Figure 3.In Fig. 3, above-mentioned path
3) and 4) shared path node " H, root ", " H, S, HOST ", " D, S, n ", " D, S, ", " D, S, o ", " D, P, CGI ", " D,
P,/”。
Optionally, in tree, if a path node there are multiple child nodes, can be according to being wrapped in child node
The sequence of the character included is arranged the traversal order (or putting in order) of above-mentioned child node.For example, since character " m " is located at word
It, therefore, can " " child node of H, S, HOST " be arranged in path as path node by D, S, m " by path node before according with " n "
Node " left side of D, S, n ", in this way, when executing search operation in the path node set with tree, first traversal
Path node " D, S, m ", then traverse path node " D, S, n " again.
It should be noted that the above-mentioned arrangement that above-mentioned child node is arranged according to the sequence for the character for including in child node is suitable
Sequence, this is only a kind of example, and the present embodiment is not construed as limiting this.
Optionally, in the present embodiment, it can include but is not limited at least one of in each above-mentioned path node:
Node type, match pattern, node character, wherein above-mentioned node type can include but is not limited to: root node, child node, leaf
Child node, above-mentioned leaf node refer to the last one path node of a paths.Above-mentioned match pattern can include but is not limited to
At least one of: prefix matching, suffix match.Wherein, above-mentioned prefix matching refers to: being successively read HTTP from front to back and asks
Seek the character in access path;Above-mentioned suffix match refers to: is successively read in HTTP request from back to front in access path
Character.
It is alternatively possible to but be not limited by and be arranged each path node with minor function.
The path node in conjunction with shown in foregoing description and Fig. 3 it is found that path node can with 3 elements <
QnodeType, MatchMethod, value > indicate, wherein QnodeType indicates that node type, MatchMethod indicate
Match pattern, value indicate the character for including in path node.
Optionally, QnodeType indicates that T_HEAD_NODE, D indicate T_DATA_NODE with H;MatchMethod P table
Show T_PREFIX, indicate T_SUFFIX with S, indicates T_EQ with E;Value indicates the character for including in the path node.
Specifically example as shown in connection with fig. 3 is illustrated, it is assumed that client id _ 1 from terminal 102, received HTTP
The access path by string representation is obtained in request are as follows:
1)Host:o.m CGI:/t。
Wherein, Host is suffix match, and CGI is prefix matching, then, can be by for the character " o.m " in Host field
According to " m ", " ", the sequence of " o " to be arranged in the path node set with tree and the character in Host field
" o.m " corresponding path node, for example, the corresponding path node of character " o.m " in Host field is successively in Fig. 3 are as follows:
" D, S, m ", " D, S, ", " D, S, o ", wherein " D, S, m " are the path node " child node of H, S, Host " to path node.It is similar
Ground, can be according to "/", and the sequence of " t " to be arranged in the path node set with tree and the character in CGI field
The corresponding path node of "/t ", for example, the corresponding path node of character "/t " in CGI field is followed successively by path section in Fig. 3
Point " D, P ,/", " D, P, t ", wherein path node " D, P ,/" it is the path node " child node of H, P, CGI ".
Optionally, in the present embodiment, when in different paths include identical continuation character string, then it is same as described above
The path that the corresponding path of continuation character string can be made of the multiple connected path nodes including above-mentioned root node
Node subsets, which close, to be indicated.
Specifically example as shown in connection with fig. 3 is illustrated, it is assumed that client id _ 1 from terminal 102, client id _ 2
The access path by string representation is obtained in received HTTP request are as follows:
1)Host:o.m CGI:/t;
2)Host:m.o.m CGI:null。
Wherein, Host includes identical continuation character string " o.m " in two different paths, then can be as shown in figure 3, by phase
Path node corresponding to same continuation character string merges, so that two paths share identical path node subclass: " D, S,
M ", " D, S, ", " D, S, o ".
Optionally, in the present embodiment, it searches and visits in the path node set with tree pre-established
The matched destination path of diameter of asking the way includes:
S1 searches whether the destination path represented by existing by a path node subclass from path node set,
Wherein, the character string constituted from root node to leaf node in a path node subclass is (for example, in above-mentioned path 1
Character string " Host:o.m CGI:/t ") it is identical as character string (for example, " Host:o.m CGI:/t ") in access path.
Optionally, in the present embodiment, it can include but is not limited to a node character in above-mentioned path node, then one
The character string constituted from root node to leaf node in path node subclass is identical as the character string in access path can be with
Including but not limited to: the character in multiple continuous path nodes in above-mentioned path respectively with the access road that is obtained in HTTP request
Character in diameter is identical.
It is specifically illustrated in conjunction with following example, it is assumed that the access path by character string identification obtained from HTTP request
For HOST:QQ.COM, then each path Road diametral pitch is searched in the path node set with tree-shaped set pre-established
Whether the node character in point is successively identical as the character in access path, if they are the same, then it represents that above-mentioned path node subclass
In the character string that is constituted from root node to leaf node it is identical as the character string in access path, and then may determine that in institute
It states and is found in path node set and the matched destination path of the access path.
By embodiment provided by the present application, by being looked into the path node set with tree pre-established
Look for obtained from HTTP request with the matched destination path of access path, wherein from root node in above-mentioned path node set
Path node subclass to each leaf node indicates a path being allowed access to, identical continuous in different paths
Character string is indicated by multiple connected path nodes in a path node subclass including root node, is overcome existing
Technology realizes the problem that verification efficiency is lower caused by the matching to white list by traversing all arrays, by by path
In identical path node merge, realize shortening checking time, and then improve and execute the operation of request indicated by HTTP request
Efficiency.
As a kind of optional scheme, search whether to exist from path node set by a path node subclass institute
The destination path of expression includes:
S1 repeats following operation, until generating lookup result, wherein present node is initialized as root node, currently
Character is initialized as in HTTP request the verification bebinning character in the character string for indicating access path:
S10 judges whether present node is root node " H, root ";
S12 sets present node to the child node of root node, for example, shown in Fig. 3 if present node is root node
Path node " H, S, HOST ";
S14 judges whether the character for including in present node is current character if present node is not root node;
S16 judges whether present node is leaf node if the character for including in present node is current character, if
Present node is leaf node, then using path represented by root node to present node as destination path, and generates by first
Search the lookup result that information indicates, wherein the first lookup information finds and accesses in path node set for indicating
The destination path of route matching;If present node is not leaf node, a son section will be selected in the child node of present node
Point, wherein the character for including in a child node is the character late of current character, is set as a child node to work as prosthomere
Point, and current character is set by the character late of current character;
For example, by character string be " Host:o.m CGI:/t " for, it is assumed that in above-mentioned character string HOST field using " from
Suffix is to prefix " sequence arrangement, CGI field arranged using the sequence of " from prefix to suffix " or " since prefix ", then word
The sequence of character in symbol string are as follows: " Host ", " m ", " ", " o ", " CGI ", "/", " t ", that is, the character late of " Host " is
" m ", the character late of " m " are " ", and the character late of " " is " o ", and the character late of " o " is " CGI ", " CGI's "
Character late is "/", and the character late of "/" is " t ".
That is, the character late of above-mentioned current character can be in HTTP request for indicating the word of access path
The character late of current character in symbol string, wherein the character in above-mentioned character string is suitable according to arrangement corresponding with match pattern
Sequence arrangement.
S18 is generated if the character for including in present node is not current character and is searched the lookup that information indicates by second
As a result, wherein the second lookup information is not found and the matched target road of access path for indicating in path node set
Diameter.
Optionally, in the present embodiment, above-mentioned verification bebinning character includes but is not limited to following one:
1) first character in the HOST field in the character string in HTTP request for indicating access path, for example,
When access path is " Host:o.m CGI:/t ", the first character in HOST field is " m " or " HOST ";
2) last character in the HOST field in the character string in HTTP request for indicating access path, example
Such as, when access path is " Host:o.m CGI:/t ", the last character in HOST field is " o ";
3) first character in the CGI field in the character string in HTTP request for indicating access path, for example, working as
When access path is " Host:o.m CGI:/t ", the first character in CGI field is "/" or " CGI ";
4) last character in the CGI field in the character string in HTTP request for indicating access path, for example,
When access path is " Host:o.m CGI:/t ", the last character in CGI field is " t ";
5) first character in the character string in HTTP request for indicating access path, for example, when access path is
When " Host:o.m CGI:/t ", first character is " m " or " HOST ";
6) last character in the character string in HTTP request for indicating access path, for example, working as access path
When for " Host:o.m CGI:/t ", last character is " t ";
Specifically example as shown in connection with fig. 3 is described, it is assumed that present node is access path (for example, " Host:o.m
CGI:/t ") in the corresponding path node of HOST field " H, S, HOST " and the path node " character " Host " in H, S, HOST "
It is identical as current character " Host ", then by the path node " H, S, HOST " child node " D, S, m " are set as present node, and
Current character is set by the character late " m " of current character in the HOST field in access path.Then, prosthomere is worked as in judgement
" whether the character in D, S, m " is current character " m " to point.Since the character in present node is identical as current character, after
It is continuous that by path node, " " D, S, " are set as present node to the child node of D, S, m ", and by position in the HOST field in access path
Character late " " after current character is set as current character, and so on.
If present node is leaf node " D, P, t " and path node " character " t " and current character in H, S, HOST "
" t " is identical, then by the path represented by D, P, t " above-mentioned root node " H, root " to leaf node " as destination path, and gives birth to
At lookup result.
It should be noted that for the various method embodiments described above, for simple description, therefore, it is stated as a series of
Combination of actions, but those skilled in the art should understand that, the present invention is not limited by the sequence of acts described because
According to the present invention, some steps may be performed in other sequences or simultaneously.Secondly, those skilled in the art should also know
It knows, the embodiments described in the specification are all preferred embodiments, and related actions and modules is not necessarily of the invention
It is necessary.
Through the above description of the embodiments, those skilled in the art can be understood that according to above-mentioned implementation
The method of example can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but it is very much
In the case of the former be more preferably embodiment.Based on this understanding, technical solution of the present invention is substantially in other words to existing
The part that technology contributes can be embodied in the form of software products, which is stored in a storage
In medium (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that a terminal device (can be mobile phone, calculate
Machine, server or network equipment etc.) execute method described in each embodiment of the present invention.
Embodiment 2
According to embodiments of the present invention, the device for additionally providing a kind of processing HTTP request can be, but not limited to be located at such as Fig. 1
Shown in network environment, wherein the client for sending HTTP request can be, but not limited to be located in terminal 102 shown in FIG. 1,
Server 104 shown in FIG. 1 will receive above-mentioned HTTP request by network, wherein above-mentioned server 104 can also be replaced with terminal
It changes.Optionally, in the present embodiment, above-mentioned network can include but is not limited to: wide area network, Metropolitan Area Network (MAN), local area network.Above-mentioned service
Device 104 by from above-mentioned HTTP request obtain by string representation access path, and search it is matched with above-mentioned access path
Destination path, and after finding above-mentioned destination path, execute the operation of request indicated by above-mentioned HTTP request.Optionally, exist
In the present embodiment, above-mentioned terminal be can include but is not limited to: mobile phone, tablet computer, laptop, PC machine.
Optionally, in the present embodiment, the device of above-mentioned processing HTTP request can be as shown in figure 8, the device includes:
1) receiving unit 802, for receiving the HTTP request of client transmission;Optionally, above-mentioned HTTP request can be
The HTTP request for being used to access webpage that the client installed in terminal 102 is sent.Optionally, in above-mentioned HTTP request can with but
It is not limited to include: access path, for example, above-mentioned access path can be, but not limited to as the network address of above-mentioned webpage, e.g., " Host:
O.m CGI:/t ", Huo Zhewei, " Host:m.o.m ".
2) acquiring unit 804, for obtaining the access path by string representation from HTTP request;
3) searching unit 806, for searching and accessing in the path node set with tree pre-established
The destination path of route matching, wherein from root node to the path node subclass of each leaf node in path node set
Indicate a path being allowed access to, identical continuation character string in a path node subclass by wrapping in different paths
Include multiple connected path nodes expressions including root node;
Optionally, Fig. 3 shows a kind of schematic diagram of the path node set with tree pre-established, needs
Illustrate, path node set shown in Fig. 3 is only a kind of example, and the path node set in the present embodiment can be according to not
Same scene is configured, as shown in Figure 4.
As shown in figure 3, the path node set with tree can be used to indicate that 4 paths being allowed access to:
Specifically, as shown in figure 3, the expression of path node subclass 1 of root node " H, root " to leaf node " D, P, t "
Above-mentioned path 1).That is, in path node subclass 1 path node " H, root ", " H, S, HOST ", " D, S, m ", " D, S, ",
" D, S, o ", " D, P, CGI ", " D, P ,/", " D, P, t " indicate above-mentioned path 1) " Host:o.m CGI:/t ";
The path node subclass 2 of D, S, m " indicate above-mentioned path 2 to root node " H, root " to leaf node ").That is, road
In diametral pitch point subclass 2 path node " H, root ", " H, S, HOST ", " D, S, m ", " D, S, ", " D, S, o ", " D, S, ",
" D, S, m " indicate above-mentioned path 2) " Host:m.o.m CGI:null ";
The path node subclass 3 of D, P, m " indicate above-mentioned path 3 to root node " H, root " to leaf node ").That is, road
In diametral pitch point subclass 3 path node " H, root ", " H, S, HOST ", " D, S, n ", " D, S, ", " D, S, o ", " D, P,
CGI ", " D, P ,/", " D, P, m " indicate above-mentioned path 3) " Host:o.n CGI:/m ";
The path node subclass 4 of D, P, n " indicate above-mentioned path 4 to root node " H, root " to leaf node ").That is, road
In diametral pitch point subclass 4 path node " H, root ", " H, S, HOST ", " D, S, n ", " D, S, ", " D, S, o ", " D, P,
CGI ", " D, P ,/", " D, P, n " indicate above-mentioned path 4) " Host:o.n CGI:/n ".
Wherein, above-mentioned path 1) and 2) shared path node " H, root ", " H, S, HOST ", " D, S, m ", " D, S, ",
"D,S,o".That is, above-mentioned path 1) and 2) in identical continuation character string " Host:o.m " by above-mentioned path node " H,
Root ", " H, S, HOST ", " D, S, m ", " D, S, ", " D, S, o " are indicated.
Similarly, above-mentioned path 3) and 4) shared path node " H, root ", " H, S, HOST ", " D, S, n ", " D,
S, ", " D, S, o ", " D, P, CGI ", " D, P ,/".That is, above-mentioned path 3) and 4) in identical continuation character string
" Host:o.n CGI :/" by above-mentioned path node " H, root ", " H, S, HOST ", " D, S, n ", " D, S, ", " D, S, o ", " D,
P, CGI ", " D, P ,/" indicate.
In Fig. 3, path 1) -4) in HOST field in character (for example, path 1) in " o.m ") according to " from rear
Sew prefix " sequence passage path node indicate.By taking path 1 as an example, the character in HOST field is " o.m ", wherein
" m " is suffix, and " n " is prefix, and the sequence of above-mentioned " from suffix to prefix " refers to: " D, S, m " are path node to path node
" child node of H, S, HOST ", " D, S, " are that " child node of D, S, m ", " D, S, o " are path node to path node to path node
" the child node of D, S, ".In other words, " H, S, HOST ", " D, S, m ", " D, S, ", " D, S, o " are sequentially connected.
It should be noted that the above-mentioned sequence passage path node according to " from suffix to prefix " indicates path 1) -4)
In HOST field in character be only a kind of example, the present embodiment is not limited only to this, for example, it is also possible to according to " from prefix to
Suffix " or the sequence passage path node of " since prefix " indicate path 1) -4) in HOST field in character,
In, it only includes prefix, without the scene including suffix that the sequence of " since prefix ", which is suitable for HOST field,.By taking path 1 as an example,
Character in HOST field is " o.m ", wherein " m " is suffix, and " n " is prefix, what the sequence of above-mentioned " from prefix to suffix " referred to
Be: path node " D, S, o " be path node " child node of H, S, HOST ", path node " D, S, " be path node " D, S,
The child node of o ", " D, S, m " are the path node " child node of D, S, ".
Optionally, it is searched and the matched mesh of access path in the path node set with tree pre-established
During marking path, can since compare root node the character in access path and the character in path node whether phase
Together.Since path node set has tree, by the character in access path and with multiple child node (examples
Such as, child node 1 " D, P, CGI ", child node 2 " D, S, ") path node (node " D, S, o ") be compared after, Ke Yixuan
The branch where said one child node (for example, child node 1 " D, P, CGI ") is selected (for example, " D, P, CGI " arrive leaf to child node 1
Node " D, P, t ") continue to continue to compare with character remaining in access path.If branch's comparison result failure is (for example, access
Path is " Host:m.o.m ", corresponding to the path 2 in Fig. 3)), this goes to other sub- sections of path node (node " D, S, o ")
Branch where point (for example, child node 2 " D, S, ") is compared, without compare again again path node (node " D,
S, o ") before compared node (for example, " H, root ", " H, S, HOST ", " D, S, m ", " D, S, ", " D, S, o "),
To reduce the number of comparison, that is, improve the efficiency verified when handling HTTP request to HTTP request.
That is, identical continuation character string at most only needs to compare one during comparison in different paths
It is secondary, that is, to judge to whether there is and the matched destination path of access path in the path node set with tree.
4) it is held when for finding destination path matched with access path in path node set execution unit 808
The operation of request indicated by row HTTP request.
Optionally, the above-mentioned path node set with tree pre-established can be used to indicate in " white list "
The path of record being allowed access to, for example, the every path being allowed access to recorded in " white list " can be by from root section
It o'clock is indicated to the path node subclass of leaf node.In other words, the road being allowed access to recorded in " white list "
Diameter is indicated by tree.Optionally, if found in path node set with the matched destination path of access path,
Then indicate that the access path in HTTP request is the path being allowed access to recorded in " white list ".
In embodiments of the present invention, the path being allowed access in white list is indicated using tree, and for not
With path in identical continuation character string, only indicate primary by identical path node, without such as institute in the prior art
What is used is indicated by different array members respectively.In this way, not needing traversal each root section during lookup
It puts to path represented by leaf node, it can whether the access path for judging HTTP request is to be allowed to visit in white list
The path asked to improve the efficiency verified when handling HTTP request to HTTP request, and then solves and is handling
The lower technical problem of the efficiency that HTTP request is verified when HTTP request.
As a kind of optional scheme, as shown in figure 11, the device of the processing HTTP request in the present embodiment further include: hair
Unit 1102 is sent, for searching and the matched mesh of access path in the path node set with tree pre-established
Mark path after, if do not found in path node set with the matched destination path of access path, to client send
It is used to indicate the response message of denied access.In other words, it is matched if not found in path node set with access path
Destination path, then it represents that the access path in HTTP request is not the path being allowed access to recorded in " white list ".
Optionally, in the present embodiment, before receiving the HTTP request that client is sent, need to pre-establish above-mentioned tool
There is the path node set of tree.It describes to establish below in conjunction with specific example and attached drawing above-mentioned with tree
The scheme of path node set.It should be noted that following scheme is only a kind of example, established in the present embodiment above-mentioned with tree
The scheme of the path node set of shape structure is not limited only to this.
As a kind of optional scheme, as shown in Figure 10, the device of the processing HTTP request in the present embodiment further include:
1) the first setting unit 1002 is such as schemed for root node before receiving the HTTP request that client is sent, to be arranged
Root node " H, root " in 3;
2) the second setting unit 1004, for the child node (for example, " H, S, HOST ") of root node to be arranged, wherein each
HOST field in one path being allowed access to of the character representation for including in child node, the different paths being allowed access to
In identical HOST field by the character representation that includes in a child node;
3) third setting unit 1006, for multiple path nodes being arranged under each child node until leaf node,
In, identical continuation character string is saved by multiple connected paths in multiple path nodes in the different paths being allowed access to
Point indicates.
By taking the path being allowed access to includes 4 paths in Fig. 3 as an example, Fig. 5-Fig. 7 is shown with tree
The establishment process of path node set.
As shown in figure 5, path node set is initialized as sky, on this basis, road first is formed in path node set
Diameter 1) " Host:o.m CGI:/t " tree, that is, path node " H, root ", " H, S, HOST ", " D, S, m ", " D,
S, ", " D, S, o ", " D, P, CGI ", " D, P ,/", " D, P, t " are sequentially connected.
Further, on the basis of Fig. 5, then path 2 is formed in path node set) " Host:m.o.m CGI:
null".Due to path 1) and 2) continuation character string " Host:o.m " having the same, thus, it is only required to will on the basis of Fig. 5,
By path node, " D, S, " are set as the path node " child node of D, S, o ", then " D, S, m " are set as path by path node
Node " child node of D, S, ", as shown in Figure 6.In Fig. 6, above-mentioned path 1) and 2) shared path node " H, root ",
" H, S, HOST ", " D, S, m ", " D, S, ", " D, S, o ".
In an identical manner, on the basis of Fig. 6, then path 3 is formed in path node set) " Host:o.n
CGI:/m".Due to path 3) in HOST field in character " n " and path 1) and path 2) in HOST field in character
" m " is different, and therefore, by path node, " D, S, n " are as a path node " new child node of H, S, HOST ", and in path
Node " is sequentially connected path node " D, S, ", " D, S, o ", " D, P, CGI ", " D, P ,/", " D, P, m ", Fig. 7 after D, S, n "
It is shown.
Further, on the basis of Fig. 7, then path 4 is formed in path node set) " Host:o.nCGI:/n ".By
In above-mentioned path 3) and 4) continuation character string having the same " Host:o.n CGI :/", thus, it is only required to will be on the basis of Fig. 7
On, by path node, " D, P, n " are set as the child node of path node " D, P ,/", as shown in Figure 3.In Fig. 3, above-mentioned path
3) and 4) shared path node " H, root ", " H, S, HOST ", " D, S, n ", " D, S, ", " D, S, o ", " D, P, CGI ", " D,
P,/”。
Optionally, in tree, if a path node there are multiple child nodes, can be according to being wrapped in child node
The sequence of the character included is arranged the traversal order (or putting in order) of above-mentioned child node.For example, since character " m " is located at word
It, therefore, can " " child node of H, S, HOST " be arranged in path as path node by D, S, m " by path node before according with " n "
Node " left side of D, S, n ", in this way, when executing search operation in the path node set with tree, first traversal
Path node " D, S, m ", then traverse path node " D, S, n " again.
It should be noted that the above-mentioned arrangement that above-mentioned child node is arranged according to the sequence for the character for including in child node is suitable
Sequence, this is only a kind of example, and the present embodiment is not construed as limiting this.
Optionally, in the present embodiment, it can include but is not limited at least one of in each above-mentioned path node:
Node type, match pattern, node character, wherein above-mentioned node type can include but is not limited to: root node, child node, leaf
Child node, above-mentioned leaf node refer to the last one path node of a paths.Above-mentioned match pattern can include but is not limited to
At least one of: prefix matching, suffix match.Wherein, above-mentioned prefix matching refers to: being successively read HTTP from front to back and asks
Seek the character in access path;Above-mentioned suffix match refers to: is successively read in HTTP request from back to front in access path
Character.
It is alternatively possible to but be not limited by and be arranged each path node with minor function.
string value;The value HOST (if it is type node) of/* node is if it is value node.It is then a word
Symbol */
The path node in conjunction with shown in foregoing description and Fig. 3 it is found that path node can with 3 elements <
QnodeType, MatchMethod, value > indicate, wherein QnodeType indicates that node type, MatchMethod indicate
Match pattern, value indicate the character for including in path node.
Optionally, QnodeType indicates that T_HEAD_NODE, D indicate T_DATA_NODE with H;MatchMethod P table
Show T_PREFIX, indicate T_SUFFIX with S, indicates T_EQ with E;Value indicates the character for including in the path node.
Specifically example as shown in connection with fig. 3 is illustrated, it is assumed that client id _ 1 from terminal 102, received HTTP
The access path by string representation is obtained in request are as follows:
1)Host:o.m CGI:/t。
Wherein, Host is suffix match, and CGI is prefix matching, then, can be by for the character " o.m " in Host field
According to " m ", " ", the sequence of " o " to be arranged in the path node set with tree and the character in Host field
" o.m " corresponding path node, for example, the corresponding path node of character " o.m " in Host field is successively in Fig. 3 are as follows:
" D, S, m ", " D, S, ", " D, S, o ", wherein " D, S, m " are the path node " child node of H, S, Host " to path node.It is similar
Ground, can be according to "/", and the sequence of " t " to be arranged in the path node set with tree and the character in CGI field
The corresponding path node of "/t ", for example, the corresponding path node of character "/t " in CGI field is followed successively by path section in Fig. 3
Point " D, P ,/", " D, P, t ", wherein path node " D, P ,/" it is the path node " child node of H, P, CGI ".
Optionally, in the present embodiment, when in different paths include identical continuation character string, then it is same as described above
The path that the corresponding path of continuation character string can be made of the multiple connected path nodes including above-mentioned root node
Node subsets, which close, to be indicated.
Specifically example as shown in connection with fig. 3 is illustrated, it is assumed that client id _ 1 from terminal 102, client id _ 2
The access path by string representation is obtained in received HTTP request are as follows:
1)Host:o.m CGI:/t;
2)Host:m.o.m CGI:null。
Wherein, HOST includes identical continuation character string " o.m " in two different paths, then can be as shown in figure 3, by phase
Path node corresponding to same continuation character string merges, so that two paths share identical path node subclass: " D, S,
M ", " D, S, ", " D, S, o ".
As a kind of optional scheme, as shown in figure 9, searching unit 806 includes:
1) searching module 902, for searching whether to exist from path node set by a path node subclass institute
The destination path of expression, wherein the character string (example constituted from root node to leaf node in a path node subclass
Such as, the character string " Host:o.m CGI:/t " in above-mentioned path 1) with access path in character string (for example, " Host:o.m
CGI:/t ") it is identical.
Optionally, in the present embodiment, it can include but is not limited to a node character in above-mentioned path node, then one
The character string constituted from root node to leaf node in path node subclass is identical as the character string in access path can be with
Including but not limited to: the character in multiple continuous path nodes in above-mentioned path respectively with the access road that is obtained in HTTP request
Character in diameter is identical.
It is specifically illustrated in conjunction with following example, it is assumed that the access path by character string identification obtained from HTTP request
For HOST:QQ.COM, then each path Road diametral pitch is searched in the path node set with tree-shaped set pre-established
Whether the node character in point is successively identical as the character in access path, if they are the same, then it represents that above-mentioned path node subclass
In the character string that is constituted from root node to leaf node it is identical as the character string in access path, and then may determine that in institute
It states and is found in path node set and the matched destination path of the access path.
By embodiment provided by the present application, by being looked into the path node set with tree pre-established
Look for the matched destination path of access path, to reduce the traversal to all paths, and then realize shortening and HTTP asked
The checking time asked improves the efficiency for executing request operation indicated by HTTP request.
As a kind of optional scheme, searching module 902 includes:
1) submodule is generated, for repeating following operation, until generating lookup result, wherein present node is initial
Root node is turned to, current character is initialized as in HTTP request the verification banner word in the character string for indicating access path
Symbol:
S1 judges whether present node is root node " H, root ";
S2 sets present node to the child node of root node, for example, shown in Fig. 3 if present node is root node
Path node " H, S, HOST ";
S3 judges whether the character for including in present node is current character if present node is not root node;
S4 judges whether present node is leaf node, if working as if the character for including in present node is current character
Front nodal point is leaf node, then using path represented by root node to present node as destination path, and generates and looked by first
The lookup result for looking for information to indicate, wherein the first lookup information is found and access road for indicating in path node set
The matched destination path of diameter;If present node is not leaf node, a child node will be selected in the child node of present node,
Wherein, the character for including in a child node is the character late of current character, sets present node for a child node,
And current character is set by the character late of current character;
For example, by character string be " Host:o.m CGI:/t " for, it is assumed that in above-mentioned character string HOST field using " from
Suffix is to prefix " sequence arrangement, CGI field arranged using the sequence of " from prefix to suffix " or " since prefix ", then word
The sequence of character in symbol string are as follows: " Host ", " m ", " ", " o ", " CGI ", "/", " t ", that is, the character late of " Host " is
" m ", the character late of " m " are " ", and the character late of " " is " o ", and the character late of " o " is " CGI ", " CGI's "
Character late is "/", and the character late of "/" is " t ".
That is, the character late of above-mentioned current character can be in HTTP request for indicating the word of access path
The character late of current character in symbol string, wherein the character in above-mentioned character string is suitable according to arrangement corresponding with match pattern
Sequence arrangement.
S5 is generated if the character for including in present node is not current character and is searched the lookup that information indicates by second
As a result, wherein the second lookup information is not found and the matched target road of access path for indicating in path node set
Diameter.
Optionally, in the present embodiment, above-mentioned verification bebinning character includes but is not limited to following one:
1) first character in the HOST field in the character string in HTTP request for indicating access path, for example,
When access path is " Host:o.m CGI:/t ", the first character in HOST field is " m " or " HOST ";
2) last character in the HOST field in the character string in HTTP request for indicating access path, example
Such as, when access path is " Host:o.m CGI:/t ", the last character in HOST field is " o ";
3) first character in the CGI field in the character string in HTTP request for indicating access path, for example, working as
When access path is " Host:o.m CGI:/t ", the first character in CGI field is "/" or " CGI ";
4) last character in the CGI field in the character string in HTTP request for indicating access path, for example,
When access path is " Host:o.m CGI:/t ", the last character in CGI field is " t ";
5) first character in the character string in HTTP request for indicating access path, for example, when access path is
When " Host:o.m CGI:/t ", first character is " m " or " HOST ";
6) last character in the character string in HTTP request for indicating access path, for example, working as access path
When for " Host:o.m CGI:/t ", last character is " t ";
Specifically example as shown in connection with fig. 3 is described, it is assumed that present node is access path (for example, " Host:o.m
CGI:/t ") in the corresponding path node of HOST field " H, S, HOST " and the path node " character " Host " in H, S, HOST "
It is identical as current character " Host ", then by the path node " H, S, HOST " child node " D, S, m " are set as present node, and
Current character is set by the character late " m " of current character in the HOST field in access path.Then, prosthomere is worked as in judgement
" whether the character in D, S, m " is current character " m " to point.Since the character in present node is identical as current character, after
It is continuous that by path node, " " D, S, " are set as present node to the child node of D, S, m ", and by position in the HOST field in access path
Character late " " after current character is set as current character, and so on.
If present node is leaf node " D, P, t " and path node " character " t " and current character in H, S, HOST "
" t " is identical, then by the path represented by D, P, t " above-mentioned root node " H, root " to leaf node " as destination path, and gives birth to
At lookup result.
The serial number of the above embodiments of the invention is only for description, does not represent the advantages or disadvantages of the embodiments.
Embodiment 3
The embodiments of the present invention also provide a kind of for implementing to handle the server of the method for HTTP request, such as Fig. 1 institute
The server 104 shown.Optionally, in the present embodiment, above-mentioned server can be the service in network environment as shown in Figure 1
Device, wherein the client for sending HTTP request can be, but not limited to be located in terminal 102 shown in FIG. 1, service shown in FIG. 1
Device 104 will receive above-mentioned HTTP request by network, wherein above-mentioned server 104 can also be replaced with terminal.Optionally, exist
In the present embodiment, above-mentioned network be can include but is not limited to: wide area network, Metropolitan Area Network (MAN), local area network.Above-mentioned server 104 will be from upper
The access path obtained in HTTP request by string representation, and lookup and the matched destination path of above-mentioned access path are stated, and
After finding above-mentioned destination path, the operation of request indicated by above-mentioned HTTP request is executed.Optionally, in the present embodiment,
Above-mentioned terminal can include but is not limited to: mobile phone, tablet computer, laptop, PC machine.
Optionally, in the present embodiment, as shown in figure 12, above-mentioned a kind of for implementing to handle the clothes of the method for HTTP request
Business device include:
1) communication interface;For example, IEEE802.11 network interface 1202, and, 802.16 network interface 1204 of IEEE,
For receiving the HTTP request of client transmission;Optionally, above-mentioned IEEE802.11 network interface 1202 and IEEE 802.16
Network interface 1204 is only a kind of example, and the communication interface in the present embodiment can only include IEEE802.11 network interface 1202
And one in 802.16 network interface 1204 of IEEE, alternatively, including other interfaces, the present embodiment is not construed as limiting this.
2) processor 1206 are arranged to: the access path by string representation is obtained from HTTP request;It is built in advance
It is searched and the matched destination path of access path in the vertical path node set with tree, wherein path node collection
A path being allowed access to, different paths are indicated from root node to the path node subclass of each leaf node in conjunction
In identical continuation character string by multiple connected path node tables in a path node subclass including root node
Show;When finding destination path matched with access path in path node set, request indicated by HTTP request is executed
Operation.
3) access path by string representation obtained in storage HTTP request, Yi Ji is set in memory 1208
The path node set with tree pre-established.
Optionally, in the present embodiment, above-mentioned server can also include keyboard 1212 and display 1214, wherein key
Disk 1212 and display 1214 are connect by equipment interface 1210 with processor 1206.It should be noted that above-mentioned keyboard 1212
It is only a kind of example with display 1214, the server in the present embodiment may include one in keyboard 1212 and display 1214
It is a, it alternatively, including other peripheral equipments, or does not include these peripheral equipments, the present embodiment is not construed as limiting this.
Optionally, in the present embodiment, the content stored in above-mentioned memory can also be from its in addition to server 104
He obtains server, and the present embodiment does not do any restriction to this.
Optionally, in the present embodiment, the processing HTTP that above-mentioned memory can be also used in storage above-described embodiment 1 is asked
Other data stored in the method asked.
Optionally, concrete operations performed by all parts in the present embodiment (for example, processor 1206) can refer to
Example described in above-described embodiment 1 and embodiment 2, details are not described herein for the present embodiment.
Embodiment 4
The embodiments of the present invention also provide a kind of for implementing to handle the storage medium of the method for HTTP request.It is optional
Ground, in the present embodiment, above-mentioned storage medium can be applied to a terminal or server in network environment as shown in Figure 1
In, wherein the client for sending HTTP request can be, but not limited to be located in terminal 102 shown in FIG. 1, service shown in FIG. 1
Device 104 will receive above-mentioned HTTP request by network, wherein above-mentioned server 104 can also be replaced with terminal.Optionally, exist
In the present embodiment, above-mentioned network be can include but is not limited to: wide area network, Metropolitan Area Network (MAN), local area network.Above-mentioned server 104 will be from upper
The access path obtained in HTTP request by string representation, and lookup and the matched destination path of above-mentioned access path are stated, and
After finding above-mentioned destination path, the operation of request indicated by above-mentioned HTTP request is executed.Optionally, in the present embodiment,
Above-mentioned terminal can include but is not limited to: mobile phone, tablet computer, laptop, PC machine.
Optionally, in the present embodiment, above-mentioned storage medium is arranged to store the program generation for executing following steps
Code:
S1 receives the HTTP request that client is sent;
S2 obtains the access path by string representation from HTTP request;
S3 is searched and the matched target road of access path in the path node set with tree pre-established
Diameter, wherein indicate one to the path node subclass of each leaf node from root node in path node set and be allowed to visit
The path asked, identical continuation character string is by more including root node in a path node subclass in different paths
A connected path node indicates;
S4, if found in path node set with the matched destination path of access path, execute HTTP request institute
The request of instruction operates.
Optionally, in the present embodiment, above-mentioned storage medium can include but is not limited to: USB flash disk, read-only memory (ROM,
Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or
The various media that can store program code such as CD.
Optionally, the storage medium in the present embodiment can also be stored for executing in above-described embodiment 1 and embodiment 2
The program code of step in each example, details are not described herein for the present embodiment.
The serial number of the above embodiments of the invention is only for description, does not represent the advantages or disadvantages of the embodiments.
If the integrated unit in above-described embodiment is realized in the form of SFU software functional unit and as independent product
When selling or using, it can store in above-mentioned computer-readable storage medium.Based on this understanding, skill of the invention
Substantially all or part of the part that contributes to existing technology or the technical solution can be with soft in other words for art scheme
The form of part product embodies, which is stored in a storage medium, including some instructions are used so that one
Platform or multiple stage computers equipment (can be personal computer, server or network equipment etc.) execute each embodiment institute of the present invention
State all or part of the steps of method.
In the above embodiment of the invention, it all emphasizes particularly on different fields to the description of each embodiment, does not have in some embodiment
The part of detailed description, reference can be made to the related descriptions of other embodiments.
In several embodiments provided herein, it should be understood that disclosed client, it can be by others side
Formula is realized.Wherein, the apparatus embodiments described above are merely exemplary, such as the division of the unit, and only one
Kind of logical function partition, there may be another division manner in actual implementation, for example, multiple units or components can combine or
It is desirably integrated into another system, or some features can be ignored or not executed.Another point, it is shown or discussed it is mutual it
Between coupling, direct-coupling or communication connection can be through some interfaces, the INDIRECT COUPLING or communication link of unit or module
It connects, can be electrical or other forms.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unit
The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple
In network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme
's.
It, can also be in addition, the functional units in various embodiments of the present invention may be integrated into one processing unit
It is that each unit physically exists alone, can also be integrated in one unit with two or more units.Above-mentioned integrated list
Member both can take the form of hardware realization, can also realize in the form of software functional units.
The above is only a preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art
For member, various improvements and modifications may be made without departing from the principle of the present invention, these improvements and modifications are also answered
It is considered as protection scope of the present invention.
Claims (12)
1. a kind of method for handling HTTP request characterized by comprising
Receive the HTTP request that client is sent;
The access path by string representation is obtained from the HTTP request;
Lookup and the matched destination path of the access path in the path node set with tree pre-established,
Wherein, one is indicated to the path node subclass of each leaf node from root node in the path node set to be allowed to visit
The path asked, identical continuation character string is by including described in a path node subclass in the different paths
Multiple connected path nodes including node indicate;
If found in the path node set with the matched destination path of the access path, execute described in
The operation of request indicated by HTTP request;
Wherein, it is searched and the matched target of the access path in the path node set with tree pre-established
Whether since path include: identical compare the character in character and path node in access path root node, wherein is being incited somebody to action
Character in access path selects point where a child node after being compared with the path node with multiple child nodes
Zhi Jixu is compared with character remaining in access path, if branch's comparison result where one child node fails,
Branch where then going to other child nodes in the path node in addition to one child node is compared;
It wherein, include: node type, match pattern and node character in each path node, before the match pattern includes:
Sew matching and suffix match, wherein the prefix matching refers to the word being successively read in HTTP request from front to back in access path
Symbol, the suffix match refer to the character being successively read in HTTP request from back to front in access path.
2. the method according to claim 1, wherein described save in the path with tree pre-established
It searches in point set with the matched destination path of the access path and includes:
The target represented by existing by a path node subclass is searched whether from the path node set
Path, wherein the character constituted in one path node subclass from the root node to the leaf node
It goes here and there and is used to indicate that the character string of the access path is identical in the HTTP request.
3. according to the method described in claim 2, it is characterized in that, described search whether exist from the path node set
Include: by the destination path represented by a path node subclass
Following operation is repeated, until generating lookup result, wherein present node is initialized as the root node, current word
Symbol is initialized as in the HTTP request verification bebinning character in the character string for indicating the access path:
Judge whether the present node is the root node;
If the present node is the root node, it sets the present node to the child node of the root node;
If the present node is not the root node, judge whether the character for including in the present node is described current
Character;
If the character for including in the present node is the current character, judge whether the present node is the leaf
Node makees path represented by the root node to the present node if the present node is the leaf node
It for the destination path, and generates and searches the lookup result that information indicates by first, wherein described first, which searches information, uses
It is found and the matched destination path of the access path in the path node set in expression;If described work as prosthomere
Point is not the leaf node, then a child node is selected in the child node of the present node, wherein one son
The character for including in node is the character late of the current character, sets described for one child node and works as prosthomere
Point, and the current character is set by the character late of the current character;
If the character for including in the present node is not the current character, generates and searched described in information expression as second
Lookup result, wherein the second lookup information is not found and the access for indicating in the path node set
The destination path of route matching.
4. according to the method described in claim 3, it is characterized in that, the verification bebinning character is one of the following:
The first character in the HOST field in character string in the HTTP request for indicating the access path;
The last character in the HOST field in character string in the HTTP request for indicating the access path;
The first character in the CGI field in character string in the HTTP request for indicating the access path;
The last character in the CGI field in character string in the HTTP request for indicating the access path;
The first character in character string in the HTTP request for indicating the access path;
The last character in character string in the HTTP request for indicating the access path.
5. the method according to claim 1, wherein it is described reception client send HTTP request before,
Further include:
The root node is set;
The child node of the root node is set, wherein is allowed to described in the character representation for including in each child node one
HOST field in the path of access, the identical HOST field in the different paths being allowed access to is by one
The character representation for including in the child node;
Multiple path nodes are set under each child node until leaf node, wherein be allowed access to described in different
Path in identical continuation character string indicated by multiple connected path nodes in the multiple path node.
6. the method according to claim 1, wherein in the path node collection with tree pre-established
After searching in conjunction with the matched destination path of the access path, further includes:
If do not found in the path node set with the matched destination path of the access path, to the visitor
Family end sends the response message for being used to indicate denied access.
7. a kind of device for handling HTTP request characterized by comprising
Receiving unit, for receiving the HTTP request of client transmission;
Acquiring unit, for obtaining the access path by string representation from the HTTP request;
Searching unit, for being searched and the access path in the path node set with tree pre-established
The destination path matched, wherein the path node subclass table in the path node set from root node to each leaf node
Show the path being allowed access to, identical continuation character string is by a path node subset in the different paths
Multiple connected path nodes in conjunction including the root node indicate;
Execution unit, for being found in the path node set and the matched destination path of the access path
When, execute the operation of request indicated by the HTTP request;
Wherein, it is searched and the matched target of the access path in the path node set with tree pre-established
Whether since path include: identical compare the character in character and path node in access path root node, wherein is being incited somebody to action
Character in access path selects point where a child node after being compared with the path node with multiple child nodes
Zhi Jixu is compared with character remaining in access path, if branch's comparison result where one child node fails,
Branch where then going to other child nodes in the path node in addition to one child node is compared;
It wherein, include: node type, match pattern and node character in each path node, before the match pattern includes:
Sew matching and suffix match, wherein the prefix matching refers to the word being successively read in HTTP request from front to back in access path
Symbol, the suffix match refer to the character being successively read in HTTP request from back to front in access path.
8. device according to claim 7, which is characterized in that the searching unit includes:
Searching module, for searching whether to exist from the path node set by a path node subclass institute table
The destination path shown, wherein from the root node to the leaf node in one path node subclass
The character string constituted in the HTTP request for indicating that the character string of the access path is identical.
9. device according to claim 8, which is characterized in that the searching module includes:
Submodule is generated, for repeating following operation, until generating lookup result, wherein present node is initialized as institute
Root node is stated, current character is initialized as in the HTTP request verification in the character string for indicating the access path and rises
Beginning character:
Judge whether the present node is the root node;
If the present node is the root node, it sets the present node to the child node of the root node;
If the present node is not the root node, judge whether the character for including in the present node is described current
Character;
If the character for including in the present node is the current character, judge whether the present node is the leaf
Node makees path represented by the root node to the present node if the present node is the leaf node
It for the destination path, and generates and searches the lookup result that information indicates by first, wherein described first, which searches information, uses
It is found and the matched destination path of the access path in the path node set in expression;If described work as prosthomere
Point is not the leaf node, then a child node is selected in the child node of the present node, wherein one son
The character for including in node is the character late of the current character, sets described for one child node and works as prosthomere
Point, and the current character is set by the character late of the current character;
If the character for including in the present node is not the current character, generates and searched described in information expression as second
Lookup result, wherein the second lookup information is not found and the access for indicating in the path node set
The destination path of route matching.
10. device according to claim 9, which is characterized in that the verification bebinning character is one of the following:
The first character in the HOST field in character string in the HTTP request for indicating the access path;
The last character in character string in the HTTP request for indicating the access path;
The first character in the CGI field in character string in the HTTP request for indicating the access path;
The last character in the CGI field in character string in the HTTP request for indicating the access path;
The first character in character string in the HTTP request for indicating the access path;
The last character in character string in the HTTP request for indicating the access path.
11. device according to claim 7, which is characterized in that further include:
First setting unit, for the root node to be arranged before the HTTP request that the reception client is sent;
Second setting unit, for the child node of the root node to be arranged, wherein the character list for including in each child node
HOST field in the path being allowed access to described in showing one, the identical institute in the different paths being allowed access to
HOST field is stated by the character representation that includes in a child node;
Third setting unit, for multiple path nodes to be arranged until leaf node under each child node, wherein different
The path being allowed access in identical continuation character string by multiple connected paths in the multiple path node
Node indicates.
12. device according to claim 7, which is characterized in that further include:
Transmission unit, for being searched and the access path in the path node set with tree pre-established
After the destination path matched, if not found in the path node set and the matched target road of the access path
Diameter then sends the response message for being used to indicate denied access to the client.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410495917.3A CN104954415B (en) | 2014-09-24 | 2014-09-24 | Handle the method and device of HTTP request |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410495917.3A CN104954415B (en) | 2014-09-24 | 2014-09-24 | Handle the method and device of HTTP request |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104954415A CN104954415A (en) | 2015-09-30 |
CN104954415B true CN104954415B (en) | 2019-06-21 |
Family
ID=54168766
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410495917.3A Active CN104954415B (en) | 2014-09-24 | 2014-09-24 | Handle the method and device of HTTP request |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104954415B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105847262A (en) * | 2016-03-31 | 2016-08-10 | 乐视控股(北京)有限公司 | Anti-stealing-link method and system |
CN108257028A (en) * | 2017-07-25 | 2018-07-06 | 平安科技(深圳)有限公司 | Processing method, device, computer equipment and the storage medium of settlement of insurance claim |
CN109040316B (en) * | 2018-09-19 | 2021-08-27 | 天津字节跳动科技有限公司 | HTTP service processing method and device |
CN110704779A (en) * | 2019-09-27 | 2020-01-17 | 杭州迪普科技股份有限公司 | Website page access compliance detection method, device and equipment |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101909012A (en) * | 2010-08-02 | 2010-12-08 | 深圳中兴力维技术有限公司 | Route addressing method based on tree network |
CN102882987A (en) * | 2011-07-12 | 2013-01-16 | 阿里巴巴集团控股有限公司 | Domain filter list storing and matching method and device |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TWI464608B (en) * | 2010-11-18 | 2014-12-11 | Wang Yen Yao | Fast algorithm for mining high utility itemsets |
CN103377259B (en) * | 2012-04-28 | 2016-12-14 | 北京新媒传信科技有限公司 | A kind of multi-pattern match method and apparatus |
-
2014
- 2014-09-24 CN CN201410495917.3A patent/CN104954415B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101909012A (en) * | 2010-08-02 | 2010-12-08 | 深圳中兴力维技术有限公司 | Route addressing method based on tree network |
CN102882987A (en) * | 2011-07-12 | 2013-01-16 | 阿里巴巴集团控股有限公司 | Domain filter list storing and matching method and device |
Also Published As
Publication number | Publication date |
---|---|
CN104954415A (en) | 2015-09-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2018149292A1 (en) | Object clustering method and apparatus | |
CN104954415B (en) | Handle the method and device of HTTP request | |
CN106302630A (en) | Transmit private data and data object | |
CN105302815B (en) | The filter method and device of the uniform resource position mark URL of webpage | |
CN105491094B (en) | Method and device for processing HTTP (hyper text transport protocol) request | |
JP6608972B2 (en) | Method, device, server, and storage medium for searching for group based on social network | |
CN103067919B (en) | Connection establishment method and authentication method between computing device and mobile device | |
KR101754618B1 (en) | A method and apparatus for generating dinamic virtual network based on software defined networks | |
CN107872548A (en) | Web page interlinkage method, apparatus and readable storage medium storing program for executing | |
CN107580032A (en) | Data processing method, device and equipment | |
CN113507475A (en) | Cross-domain access method and device | |
CN110213365B (en) | User access request processing method based on user partition and electronic equipment | |
CN111107181B (en) | NAT rule matching method and device, electronic equipment and storage medium | |
CN110619022B (en) | Node detection method, device, equipment and storage medium based on block chain network | |
CN105978868A (en) | Method and apparatus for searching IP address authority | |
WO2020019524A1 (en) | Data processing method and device | |
CN102647463B (en) | The generation method of Web side navigation, wireless router terminal and system | |
CN104579939A (en) | Protecting method and device for gateway | |
CN104539538A (en) | IP address matching method and data package forwarding method of router | |
US8069304B2 (en) | Determining the presence of a pre-specified string in a message | |
CN114006868B (en) | Flow screening method and device | |
CN107733767B (en) | Method, device and system for establishing social relationship network | |
CN109842554A (en) | Method for routing, device, equipment and the storage medium of device service | |
US11563715B2 (en) | Pattern matching by a network device for domain names with wildcard characters | |
CN112187743B (en) | Network policy matching method and system based on IP address longest prefix |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |