CN111294369B - Page request processing method and device and electronic equipment - Google Patents
Page request processing method and device and electronic equipment Download PDFInfo
- Publication number
- CN111294369B CN111294369B CN201811488660.3A CN201811488660A CN111294369B CN 111294369 B CN111294369 B CN 111294369B CN 201811488660 A CN201811488660 A CN 201811488660A CN 111294369 B CN111294369 B CN 111294369B
- Authority
- CN
- China
- Prior art keywords
- request
- page
- page request
- requests
- token
- 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
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/02—Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/08—Network architectures or network communication protocols for network security for authentication of entities
- H04L63/0807—Network architectures or network communication protocols for network security for authentication of entities using tickets, e.g. Kerberos
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/16—Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
- H04L69/161—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
- H04L69/162—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/56—Provisioning of proxy services
- H04L67/565—Conversion or adaptation of application format or content
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Computer Hardware Design (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- Computer And Data Communications (AREA)
Abstract
The embodiment of the invention provides a page request processing method, a page request processing device and electronic equipment, wherein the method comprises the following steps: acquiring a plurality of page requests to a target address initiated from a business processing page in a browser; merging the multiple page requests to generate a merged page request; sending the combined page request to a server of a target address; the method comprises the steps that request result information sent by a server side aiming at each page request in the combined page requests is received, the server side is used for carrying out concurrent processing on each page request in the combined page requests, generating a piece of corresponding request result information aiming at each page request, and sending the request result information to the request side after any piece of request result information is generated. According to the scheme of the embodiment of the invention, after the server side receives the combined page requests sent by the request side, the parallelization processing is carried out on the page requests and the generated request result information is respectively sent to the request side, so that the page requests are not mutually dependent in the processing process.
Description
Technical Field
The present application relates to the field of communications technologies, and in particular, to a method and an apparatus for processing a page request, and an electronic device.
Background
In the browser page request service, a front-end page needs to send a large number of requests to a back-end to acquire data required by the page during initialization. If the data is not available, some blocks on the page cannot be rendered, and therefore, the speed of acquiring the data determines the page rendering speed. In the browser, the number of requests simultaneously initiated to a domain name is limited, and in order to accelerate the request process, the requests are combined and sent to the server side at one time in the prior art. However, this approach brings about the following new problems:
if one of the requests has a problem when the server processes the merged requests, all the merged requests may be slowed down or have errors; in addition, in a service scenario of request merging, if a malicious user constructs a request to make a Cross-site request forgery (CSRF) attack, a significant security risk may occur.
Disclosure of Invention
The invention provides a page request processing method, a page request processing device and electronic equipment.
In order to achieve the above purpose, the embodiment of the invention adopts the following technical scheme:
in a first aspect, a method for processing a page request is provided, including:
acquiring a plurality of page requests to a target address initiated from a business processing page in a browser;
merging the multiple page requests to generate a merged page request;
sending the merged page request to a server of the target address;
and receiving request result information respectively sent by the server side aiming at each page request in the combined page requests, wherein the server side is used for generating a piece of corresponding request result information aiming at each page request after carrying out concurrent processing on each page request in the combined page requests, and sending the request result information to the request side after any piece of request result information is generated.
In a second aspect, another page request processing method is provided, including:
receiving a combined page request sent by a request end, wherein the combined page request comprises a plurality of page requests initiated from a service processing page;
performing concurrent processing on each page request in the combined page request, and generating a piece of corresponding request result information for each page request;
and sending any piece of request result information to the request end after the request result information is generated.
In a third aspect, a page request processing apparatus is provided, including:
the system comprises a page request acquisition module, a service processing page processing module and a page request processing module, wherein the page request acquisition module is used for acquiring a plurality of page requests which are initiated from the service processing page and reach a target address in a browser;
the page request merging module is used for merging the multiple page requests to generate a merged page request;
a page request sending module, configured to send the merged page request to a server of the target address;
the request result receiving module is used for receiving request result information which is respectively sent by the server side aiming at each page request in the combined page requests, and the server side is used for generating a piece of corresponding request result information aiming at each page request after carrying out concurrent processing on each page request in the combined page requests and sending the request result information to the request side after any piece of request result information is generated.
In a fourth aspect, there is provided another page request processing apparatus, including:
the page request receiving module is used for receiving a combined page request sent by a request end, wherein the combined page request comprises a plurality of page requests initiated from a service processing page;
the page request processing module is used for performing concurrent processing on each page request in the combined page request and generating corresponding request result information for each page request;
and the request result feedback module is used for sending any request result information to the request end after the request result information is generated.
In a fifth aspect, an electronic device is provided, comprising:
a memory for storing a program;
a processor, coupled to the memory, for executing the program, wherein the program executes the page request processing method according to the first aspect.
In a sixth aspect, another electronic device is provided, including:
a memory for storing a program;
a processor, coupled to the memory, for executing the program, wherein the program executes the page request processing method according to the second aspect.
The invention provides a page request processing method, a page request processing device and electronic equipment, wherein when a service processing page initiates a page request, the page requests are combined through a request end to generate a combined page request, and then the combined page request is sent to a server end of a target address; after receiving the combined page request, the server side performs concurrent processing on each page request in the combined page request, and generates a piece of corresponding request result information for each page request; after any request result information is generated, the request result information is sent to a request end, and therefore the page requests are not mutually dependent in the processing process. The request terminal sends the page request to the server terminal in a page merging request mode, so that the request process is accelerated; meanwhile, the server side adopts a mode of concurrently processing the page requests when processing the merged page requests, so that various problems caused by interdependence among the page requests are avoided, for example, when processing the merged requests, one of the requests has a problem, and all the requests may be slowed down or have errors.
The foregoing description is only an overview of the technical solutions of the present application, and the present application can be implemented according to the content of the description in order to make the technical means of the present application more clearly understood, and the following detailed description of the present application is given in order to make the above and other objects, features, and advantages of the present application more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the application. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 is a schematic diagram of a page request processing logic according to an embodiment of the present invention;
FIG. 2 is a schematic structural diagram of a page request processing system according to an embodiment of the present invention;
FIG. 3 is a first flowchart of a page request processing method according to an embodiment of the present invention;
FIG. 4 is a flowchart of a page request processing method according to an embodiment of the present invention;
FIG. 5 is a diagram illustrating a page request merging method according to an embodiment of the present invention;
FIG. 6 is a third flowchart of a page request processing method according to an embodiment of the present invention;
FIG. 7 is a fourth flowchart of a page request processing method according to an embodiment of the present invention;
FIG. 8 is a first block diagram of a page request processing apparatus according to an embodiment of the present invention;
FIG. 9 is a second block diagram of a page request processing apparatus according to an embodiment of the present invention;
FIG. 10 is a third block diagram of a page request processing apparatus according to an embodiment of the present invention;
FIG. 11 is a fourth block diagram of a page request processing apparatus according to an embodiment of the present invention;
FIG. 12 is a first schematic structural diagram of an electronic device according to an embodiment of the invention;
fig. 13 is a schematic structural diagram of an electronic device according to an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
The embodiment of the invention improves the defects that in the prior art, after a request terminal initiates a combined page request from a service processing page, if a server terminal processes the combined page request, one request has a problem, which may cause the slowdown or error of all requests.
Based on the above concept of the page request processing scheme, fig. 1 is a schematic diagram of a page request processing logic provided in an embodiment of the present invention. The processing logic includes:
when it is determined that a certain service processing page in the browser has a requirement for initiating a page request, a plurality of page requests may be merged without being sent one by one for each page request, and the merged page requests are serialized to form a merged page request. In order to prevent a malicious user from making a Cross-site request forgery (CSRF) attack, a check Token (Token) may be added in the merged page request for the server to implement CSRF check.
The request end is in communication connection with the server end in a WebSocket mode. It should be noted that, in the present solution, the communication mode adopted by the request end and the server end needs to satisfy that the server end may not be limited by the request sent by the request end but may maintain a relatively stable connection state with the request end, so as to actively send information to the request end. Therefore, in addition to the WebSocket mode, the communication connection between the request side and the service side can be realized by adopting modes such as long polling and long connection.
After receiving the combined page request sent by the request end, the server end may perform CSRF verification if the combined page request includes a CSRFToken, and then perform concurrent request processing on each page request in the combined page request based on a verification result to generate a page request result corresponding to each page request. And after any page request is processed to generate a corresponding page request result, the page request result is used as request result information in cooperation with the Token generated by the Token generator at this time and fed back to the request end.
After receiving the request result information, the requester extracts the Token therein to refresh and replace the locally stored Token so as to be used when sending the combined page request next time; then, the rest part of the request result information is deserialized, and the page request result is analyzed from the deserialized request result and sent to the corresponding service processing page.
Based on the page request processing logic shown in fig. 1, as shown in fig. 2, a schematic structural diagram of a page request processing system provided in an embodiment of the present invention is shown. The system comprises: a requester 210 and a server 220 of a target address. Wherein:
the request end 210 may be a browser with a page request service, and after acquiring a plurality of page requests initiated from a service processing page to the server end 220, the request end 210 merges the plurality of page requests to generate a merged page request, and then sends the merged page request to the server end 220 with a target address.
The server 220 of the destination address may be a server corresponding to the destination address to which the page request sent by the service processing page is directed. After receiving the merged page request sent by the request end 210, the server end 220 of the target address performs a concurrent processing operation on each page request included in the merged page request, and actively sends request result information to the request end 210 after any page request is processed to generate a corresponding request result.
In order to ensure that the server 220 can actively send the request result to the requester 210 without being constrained by the merged page request, any one of the WebSocket, the long polling, the long connection, and the like can be used between the server 220 and the requester 210 to implement the communication connection.
The technical solution of the present application is further illustrated by a plurality of examples.
Example one
Based on the above solution idea of page request processing, as shown in fig. 3, it is a flowchart of a page request processing method according to an embodiment of the present invention, and the method can be performed by the request end 210 shown in fig. 2. As shown in fig. 3, the page request processing method includes the following steps:
s310, a plurality of page requests to the target address initiated from the business processing page in the browser are obtained.
Generally, when a business processing page in a browser sends a page request to a target address, the page request is sent through a postMessage API, so that the page request can be intercepted and obtained through the postMessage API.
S320, merging the multiple page requests to generate a merged page request.
The conventional method for sending a page request from a service processing page to a server of a target address is to trigger a request process every time a page request is generated, so as to send the page request to the server of the target address for processing. In the scheme, in order to accelerate the request process, the multiple page requests are combined to generate one combined page request, so that the combined page request comprising the multiple page requests is sent to the server side for processing through one request process.
In order to ensure that the page requests to be merged can meet the requirement of the number of merging conditions within the preset time, the page requests are sent out as merged page requests. The method and the device introduce the simulation request to trigger the merging operation to be normally carried out, ensure that each page request can be sent in time within the specified time, and avoid the problem that the merging operation cannot be triggered to form the merged page request to be sent to the server side due to the fact that the number of the page requests for a long time does not meet the merging requirement, so that the processing efficiency of the page request is influenced. Specifically, the page request may be merged by the page request processing method as shown in fig. 4.
S410, generating simulation requests according to a preset frequency, and monitoring the number of the simulation requests and the number of the page requests which are not processed currently.
After the service processing page initiates a plurality of page requests, the page requests are not immediately issued, but are queued in the manner shown in fig. 5, which is to more efficiently multiplex Token issued by the server. If following the conventional page request processing procedure, each page request requires a Token. However, when the business processing page is initialized, it cannot be determined how many page requests are requested in total, and therefore the server cannot issue enough tokens. If too many tokens are issued but no page requests are eventually issued, server resources are wasted. Therefore, according to the method shown in fig. 5, the page requests are buffered in a request queue, and when the number of page requests in the queue reaches the set value N, the page requests will proceed to the next step.
In order to prevent the number of requests in the request queue from reaching N for a long time, which results in a part of page requests waiting all the time, a timer may be set, and the timer may frequently add analog requests to the request queue according to a fixed frequency, which may ensure that page requests are always issued in a short period of time.
Because the simulation request in the scheme is only used as the request placeholder for triggering the merge page request operation, and is not a processing object of the actual merge operation, the content of the simulation request can be null.
S420, if the total number of the current unprocessed simulation requests and the page requests is equal to the preset number, extracting all the unprocessed page requests for combination, generating a combined page request, and discarding all the unprocessed simulation requests.
For example, when the total number of the currently unprocessed requests and the page requests in the request queue is equal to the preset number N, the requests are fetched, the requests are removed, and then the remaining page requests are merged and serialized into a request packet. At the same time, the request queue is emptied to begin the next number monitoring process for unprocessed requests and page requests.
Because the simulation request is generated according to the preset frequency, even if the normal page request generation speed is low, the execution process of the combination operation of the request end on the page request cannot be influenced, and the page request generated by the service page can be timely sent to the server end for processing.
In addition, the merged page request may specifically include: a request body and a check Token (Token) for preventing cross-site request forgery.
The request body includes the essential content of the page request, that is, the content of the request packet formed by combining and serializing the page requests as described above. The server side can execute corresponding processing logic based on the page request content in the request body, and generates an execution result. The check Token for cross-site request forgery CSRF is used for the service end to carry out CSRF check on the merged page request, and whether the page request is executed or not is determined based on the check result, and request result information is formed.
When a merged page request is formed, the formed request packet and the CSRF Token acquired in advance by the request end may be used together as the content of the merged page request.
In order to further check the validity of Token, the merge page request may further include: and the user identity information of the user to which the service page belongs can be acquired from the stored cookie, and the check token is generated based on the user identity information.
For example, after Token is generated by using user identity information provided by a malicious user, the Token is inconsistent with Token carried in the merged page request, and even if the Token of the later is legal, the Token check is considered to be failed. Therefore, when a malicious user uses an effective Token to forge a merged page request, the malicious user cannot pass Token verification of the server because the malicious user cannot obtain the corresponding correct user identity information.
S330, the merged page request is sent to a server of the target address.
After the request end forms the merged page request, the merged page request is sent to the server end of the target address, and in order to ensure that the subsequent server end can actively send a request result corresponding to each page request to the request end after the merged page request is concurrently processed for each page request in the merged page request, a communication mode between the request end and the server end may include: WebSocket, long poll, long connect.
S340, receiving request result information which is respectively sent by the server aiming at each page request in the combined page requests; the server is used for generating a piece of corresponding request result information for each page request after carrying out concurrent processing on each page request in the combined page requests, and sending any piece of request result information to the request end after the request result information is generated.
After receiving the merged page request through any one of the communication modes of WebSocket, long polling and long connection, the server executes concurrent request processing aiming at each page request in the request body in the merged page request, and generates a page request result corresponding to each page request. And when any page request is processed to generate a corresponding page request result, the page request result is fed back to the request end as a piece of request result information.
After the server executes each page request, the server sends the corresponding request result information to the request end through one-time data transmission, so that the request end receives the request result information which is sent by the server end aiming at each page request in the combined page requests.
Further, if the page request process of the present solution further includes a check process related to the CSRF, the request result information may specifically include: and the execution result or the error information and the check token generated by the server at this time are used for replacing the check token currently stored by the request end. The verification token is correspondingly provided with a validity period, and the validity period is used for continuously validating the new verification token after the new verification token is generated every time.
Specifically, after receiving a merged page request from, for example, WebSocket, a server first checks whether Token in the merged page request is valid, and if not, rejects execution of any page request in the merged page request, and generates error information corresponding to each page request; if the page request is valid, all page requests are parsed from the request body. In order to improve the performance, the server side adopts multiple threads to process the page requests concurrently, and when any one of the page requests is completed and a corresponding execution result or error information is generated, the request result (the execution result or the error information) can be immediately returned to the request side by utilizing the characteristic of WebSocket two-way communication. Therefore, the page requests are not dependent on one another, and even if errors or timeouts occur, the page requests cannot affect one another. Before any request result is returned, a latest Token is added in the request result information through the Token generator. The Token generator will cache the new Token generated by the last session and will not generate a new Token until it is consumed or expired, i.e., within the validity period.
After receiving the request result information, the requesting end first replaces the local CSRF Token with Token in the information, so that the Token can be used for the next request. Then, the return value in the request result information is analyzed, and the return value is distributed to the sender of the request through a callback function, so that the process of one request is completed.
The page request processing method provided by the invention comprises the steps that when a service processing page initiates a page request, the page requests are merged through a request end to generate a merged page request, and then the merged page request is sent to a server end of a target address; the method comprises the steps that request result information sent by a server side aiming at each page request in the combined page requests is received, the server side is used for generating a piece of corresponding request result information aiming at each page request after the page requests in the combined page requests are processed in a concurrent mode, and the request result information is sent to the request side after any piece of request result information is generated, so that the page requests are not mutually dependent in the processing process. The request terminal sends the page request to the server terminal in a page merging request mode, so that the request process is accelerated; meanwhile, the server side adopts a mode of concurrently processing the page requests when processing the merged page requests, so that various problems caused by interdependence among the page requests are avoided, for example, when processing the merged requests, one of the requests has a problem, and all the requests may be slowed down or have errors.
Furthermore, by referring to the simulation request, it is ensured that the normal page request can be merged in time to generate a merged page request, and the merged page request is sent to the server for processing.
Furthermore, the CSRF Token and the user identity information are added in the combined page request to realize CSRF verification, so that the legality of the combined page request is ensured, and the processing risk is reduced.
Further, in order to ensure that the server can actively send the request result to the request end without being constrained by the merged page request, any mode of WebSocket, long polling, long connection and the like can be adopted between the server and the request end to realize communication connection.
Example two
Based on the above solution idea of page request processing, as shown in fig. 6, it is a flowchart of a page request processing method according to an embodiment of the present invention, and the method can be performed by the server 220 shown in fig. 2. As shown in fig. 6, the page request processing method includes the following steps:
s610, receiving a merged page request sent by a request end, wherein the merged page request comprises a plurality of page requests initiated from a service processing page.
Generally, when a business processing page in a browser sends a page request to a target address, the page request is sent through a postMessage API, so that a server can intercept and obtain the page request to be sent to the target address by monitoring the postMessage API, and then merge the page requests to generate a merged page request. The server of the target address corresponding to the page request can receive the merged page request through one data transmission.
For the generation process of the merged page request, reference may be made to the method steps shown in fig. 4.
S620, the page requests in the combined page request are processed concurrently, and a piece of corresponding request result information is generated for each page request.
After receiving the combined page request, the server executes concurrent request processing for each page request in the combined page request, generates a page request result corresponding to each page request, and forms a request result message to be sent to the request end by using each page request result as message content.
S630, after any request result information is generated, the request result information is sent to the request end.
And after any page request is processed to generate corresponding page request result information, feeding the page request result information back to the request end.
After the server executes each page request, the server sends the corresponding request result information to the request end through one-time data transmission, so that the request end receives the request result information which is sent by the server end aiming at each page request in the combined page requests.
Further, in order to ensure that the server can actively send the request result to the request end without being constrained by the merged page request, any mode of WebSocket, long polling, long connection and the like can be adopted between the server and the request end to realize communication connection.
In addition, the merge page request may specifically include: a request body and a check Token (Token) for preventing cross-site request forgery.
The request body includes the essential content of the page request, that is, the content of the request packet formed by combining and serializing the page requests as described above. The server side can execute corresponding processing logic based on the page request content in the request body, and generates an execution result. The check Token for cross-site request forgery CSRF is used for the server side to carry out CSRF check on the merged page request, determine whether to execute the page request or not based on the check result and form request result information. Specifically, as shown in fig. 7, the method shown in fig. 6 further includes the following steps:
s710, verifying the verification token; if the verification is passed, go to step S720; if the verification is not passed, the process proceeds to step S730.
And the server extracts the Token carried in the merged page request and compares the Token with the local Token to perform CSRF verification.
S720, executing the processing business logic based on the request body, and adding the execution result to the request result information.
If the verification is passed, it indicates that the merged page request is not attacked by the CSRF attack, and at this time, the server may concurrently process each page request in the request body in the merged page request, and add the execution result generated after processing each page request to the request result information corresponding to the page request.
S730, add the error information generated by the verification to the request result information.
If the check is not passed, it indicates that the merged page request may have a CSRF attack, at this time, the server may refuse to process any page request included in the merged page request, and add error information generated by the check to the request result information corresponding to each page request.
And S740, generating the current check token, and adding the current check token into the request result information to replace the currently stored check token of the request end.
Before any request result is returned, a latest check Token is added to the request result information through the Token generator. The verification token is correspondingly provided with a validity period, and the validity period is used for continuously validating the new verification token after the new verification token is generated every time.
The Token generator will cache the new Token generated by the last session and will not generate a new Token until it is consumed or expired, i.e., within the validity period.
In summary, the finally generated request result information may include an execution result or error information and a check token generated by the server at this time, where the check token is used to replace the check token currently stored by the request end.
Step S720 to step S740 can be used as the detailed contents of step S620.
In order to further realize that the server checks the validity of Token, the merging page request may further include: the user identity information of the user to which the service page belongs can be obtained from the stored cookie, and the verification token is generated based on the user identity information.
Accordingly, in the method shown in fig. 7, the following steps may be further included:
and verifying the verification token according to the user identity information included in the combined page request.
For example, when the Token generated by using the user identity information provided by the malicious user is inconsistent with the Token carried in the merged page request, the Token check is considered to be failed even if the Token of the later is legal. Therefore, when a malicious user uses an effective Token to forge a merged page request, the corresponding correct user identity information cannot be obtained, so that the Token check of the server cannot be passed.
The page request processing method provided by the invention has the advantages that after the server receives the combined page request sent by the request end, the server carries out concurrent processing on each page request in the combined page request and generates a piece of corresponding request result information aiming at each page request; after any request result information is generated, the request result information is sent to a request end, so that the page requests are not mutually dependent in the processing process. The request end sends the page request to the server end in a page merging request mode, so that the request process is accelerated; meanwhile, the server side adopts a mode of concurrently processing the page requests when processing the merged page requests, so that various problems caused by interdependence among the page requests are avoided, for example, when processing the merged requests, one of the requests has a problem, and all the requests may be slowed down or have errors.
Furthermore, CSRF check is realized by adding CSRF Token and user identity information in the merged page request, so that the validity of the merged page request is ensured, and the processing risk is reduced.
Further, in order to ensure that the server can actively send the request result to the request end without being constrained by the merged page request, any mode of WebSocket, long polling, long connection and the like can be adopted between the server and the request end to realize communication connection.
EXAMPLE III
As shown in fig. 8, a first structure of a page request processing apparatus according to an embodiment of the present invention is a first structure of a page request processing apparatus, which can be disposed at a request end 210 in the page request processing system shown in fig. 2, and is configured to execute the method steps shown in fig. 3, including:
a page request obtaining module 810, configured to obtain multiple page requests to a target address, where the multiple page requests are initiated from a business processing page in a browser;
a page request merging module 820, configured to merge multiple page requests to generate a merged page request;
a page request sending module 830, configured to send the merged page request to a server of the destination address;
the request result receiving module 840 is configured to receive request result information that is sent by the server for each page request in the merged page request, where the server is configured to generate a piece of corresponding request result information for each page request after performing concurrent processing on each page request in the merged page request, and send the request result information to the request after any piece of request result information is generated.
Further, as shown in fig. 9, the page request merging module 820 may include:
a page request monitoring unit 910, configured to generate an analog request according to a preset frequency, and monitor the number of currently unprocessed analog requests and page requests;
and a page request merging unit 920, configured to extract all unprocessed page requests for merging if the total number of the current unprocessed simulation requests and the page requests is equal to a preset number, generate a merged page request, and discard all unprocessed simulation requests.
The page request processing means shown in fig. 9 may be used to perform the method steps as shown in fig. 4.
Further, the merged page request may include: a request body and a check token for preventing cross-site request forgery; the request result information includes: and the execution result or the error information and the check token generated by the server at this time are used for replacing the check token currently stored by the request end.
Further, the merge page request may further include: and the check token is generated based on the user identity information of the user to which the service page belongs.
Further, the check token is correspondingly provided with a validity period, and the validity period is used for continuously enabling a new check token to be valid after the new check token is generated every time.
Further, the method for communicating with the server side may include: WebSocket, long poll, long connect.
When a service processing page initiates a page request, the page request is merged through a request end to generate a merged page request, and then the merged page request is sent to a server end of a target address; the method comprises the steps that request result information sent by a server side aiming at each page request in the combined page requests is received, the server side is used for generating a piece of corresponding request result information aiming at each page request after the page requests in the combined page requests are processed in a concurrent mode, and the request result information is sent to the request side after any piece of request result information is generated, so that the page requests are not mutually dependent in the processing process. The request end sends the page request to the server end in a page merging request mode, so that the request process is accelerated; meanwhile, the server side adopts a mode of concurrently processing the page requests when processing the merged page requests, so that various problems caused by interdependence among the page requests are avoided, for example, when processing the merged requests, one of the requests has a problem, and all the requests may be slowed down or have errors.
Furthermore, by referring to the simulation request, it is ensured that the normal page request can be timely merged to generate a merged page request, and the merged page request is sent to the server for processing.
Furthermore, the CSRF Token and the user identity information are added in the combined page request to realize CSRF verification, so that the legality of the combined page request is ensured, and the processing risk is reduced.
Further, in order to ensure that the server can actively send the request result to the request end without being constrained by the merged page request, any mode of WebSocket, long polling, long connection and the like can be adopted between the server and the request end to realize communication connection.
Example four
As shown in fig. 10, a third structural diagram of a page request processing apparatus according to an embodiment of the present invention is a page request processing apparatus, which can be disposed at a server 220 in the page request processing system shown in fig. 2, and is configured to execute the method steps shown in fig. 6, where the method steps include:
a page request receiving module 101, configured to receive a consolidated page request sent by a request end, where the consolidated page request includes multiple page requests initiated from a service processing page;
the page request processing module 102 is configured to perform concurrent processing on each page request in the combined page request, and generate a piece of corresponding request result information for each page request;
and the request result feedback module 103 is used for sending any piece of request result information to the request end after the request result information is generated.
Further, the merged page request may include: a request body and a check token for preventing cross-site request forgery;
correspondingly, as shown in fig. 11, the page request processing apparatus shown in fig. 10 may further include:
a token verifying module 111, configured to verify a verification token;
accordingly, the page request processing module 102 may include:
an execution result adding unit 112 for executing the processing service logic based on the request body if the check passes, and adding the execution result to the request result information;
an error information adding unit 113 for adding error information generated by the verification to the request result information if the verification fails;
and the check token adding unit 114 is configured to generate a check token of this time, and add the check token to the request result information, so as to replace the currently stored check token of the request end.
The page request processing apparatus shown in fig. 11 may be used to perform the method steps shown in fig. 7.
Further, the merge page request may further include: the user identity information of the user to which the business page belongs, and the verification token is generated based on the user identity information;
accordingly, the token checking module 111 described above may also be used to,
and verifying the verification token according to the user identity information included in the combined page request.
Further, the check token is correspondingly provided with a validity period, and the validity period is used for continuously enabling a new check token to be valid after the new check token is generated every time.
Further, the communication mode with the request end can include: WebSocket, long poll, long connect.
According to the page request processing device provided by the invention, after the server receives the combined page request sent by the request end, the server carries out concurrent processing on each page request in the combined page request, and generates a piece of corresponding request result information aiming at each page request; after any request result information is generated, the request result information is sent to a request end, so that the page requests are not mutually dependent in the processing process. The request end sends the page request to the server end in a page merging request mode, so that the request process is accelerated; meanwhile, the server side adopts a mode of concurrently processing the page requests when processing the merged page requests, so that various problems caused by interdependence among the page requests are avoided, for example, when processing the merged requests, one of the requests has a problem, and all the requests may be slowed down or have errors.
Furthermore, the CSRF Token and the user identity information are added in the combined page request to realize CSRF verification, so that the legality of the combined page request is ensured, and the processing risk is reduced.
Further, in order to ensure that the server can actively send the request result to the request end without being constrained by the merged page request, any mode of WebSocket, long polling, long connection and the like can be adopted between the server and the request end to realize communication connection.
EXAMPLE five
The third embodiment describes an overall architecture of the page request processing apparatus, and the functions of the apparatus can be implemented by an electronic device, as shown in fig. 12, which is a schematic structural diagram of the electronic device according to the embodiment of the present invention, and specifically includes: a memory 121 and a processor 122.
The memory 121 stores programs.
In addition to the above-described programs, the memory 121 may also be configured to store other various data to support operations on the electronic device. Examples of such data include instructions for any application or method operating on the electronic device, contact data, phonebook data, messages, pictures, videos, and the like.
The memory 121 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
A processor 122, coupled to the memory 121, for executing a program in the memory 121, where the program is executed to perform a page request processing method as shown in any one of fig. 3 to 4.
The above specific processing operations have been described in detail in the foregoing embodiments, and are not described again here.
Further, as shown in fig. 12, the electronic device may further include: communication components 123, power components 124, audio components 125, display 126, and other components. Only some of the components are schematically shown in fig. 12, and the electronic device is not meant to include only the components shown in fig. 12.
The communication component 123 is configured to facilitate wired or wireless communication between the electronic device and other devices. The electronic device may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 123 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 123 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
A power supply component 124 that provides power to the various components of the electronic device. The power components 124 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for an electronic device.
The display 126 includes a screen, which may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.
EXAMPLE six
The fourth embodiment describes an overall architecture of the page request processing apparatus, and the functions of the apparatus can be implemented by an electronic device, as shown in fig. 13, which is a schematic structural diagram of the electronic device according to the embodiment of the present invention, and specifically includes: a memory 131 and a processor 132.
The memory 131 stores programs.
In addition to the above-described programs, the memory 131 may also be configured to store other various data to support operations on the electronic device. Examples of such data include instructions for any application or method operating on the electronic device, contact data, phonebook data, messages, pictures, videos, and so forth.
The memory 131 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
A processor 132, coupled to the memory 131, for executing a program in the memory 131, the program executing the page request processing method as shown in any one of fig. 6 to 7.
The above specific processing operations have been described in detail in the foregoing embodiments, and are not described again here.
Further, as shown in fig. 13, the electronic device may further include: communication components 133, power components 134, audio components 135, a display 136, and the like. Only some of the components are schematically shown in fig. 13, and the electronic device is not meant to include only the components shown in fig. 13.
The communication component 133 is configured to facilitate wired or wireless communication between the electronic device and other devices. The electronic device may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 133 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 133 further includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
A power supply component 134 provides power to the various components of the electronic device. The power components 134 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for electronic devices.
The audio component 135 is configured to output and/or input audio signals. For example, the audio component 135 includes a Microphone (MIC) configured to receive external audio signals when the electronic device is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal may further be stored in the memory 131 or transmitted via the communication component 133. In some embodiments, audio assembly 135 also includes a speaker for outputting audio signals.
The display 136 includes a screen, which may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.
Claims (20)
1. A page request processing method comprises the following steps:
acquiring a plurality of page requests to a target address initiated from a business processing page in a browser;
merging the multiple page requests to generate a merged page request;
sending the merged page request to a server of the target address;
receiving request result information respectively sent by the server side aiming at each page request in the combined page requests, wherein the server side is used for generating a piece of corresponding request result information aiming at each page request after carrying out concurrent processing on each page request in the combined page requests and sending the request result information to the request side after any piece of request result information is generated,
wherein, the merge page request includes: a request body and a check token for preventing cross-site request forgery; the request result information includes: and the execution result or the error information and the check token generated by the server at this time are used for replacing the check token currently stored by the request end.
2. The method of claim 1, wherein said merging the plurality of page requests, generating a merged page request comprises:
generating simulation requests according to a preset frequency, and monitoring the number of the simulation requests and the page requests which are not processed currently;
if the total number of the simulation requests and the page requests which are not processed currently is equal to the preset number, extracting all the unprocessed page requests for combination, generating the combined page request, and discarding all the unprocessed simulation requests.
3. The method of claim 1, wherein the consolidated page request further comprises: and the check token is generated based on the user identity information.
4. The method of claim 1, wherein the check token is correspondingly provided with a validity period for the new check token to be valid continuously in the validity period after each generation of the new check token.
5. The method of claim 1, wherein the means for communicating with the server comprises: WebSocket, long poll, long connect.
6. A page request processing method comprises the following steps:
receiving a combined page request sent by a request end, wherein the combined page request comprises a plurality of page requests initiated from a service processing page;
performing concurrent processing on each page request in the combined page request, and generating a piece of corresponding request result information for each page request;
any one piece of the request result information is sent to the request side after being generated,
wherein, the merge page request includes: a request body and a check token for preventing cross-site request forgery;
the method further comprises the following steps:
verifying the verification token;
if the verification is passed, executing the processing service logic based on the request body, and adding an execution result to the request result information;
if the verification is not passed, adding error information generated by the verification to the request result information;
and generating a current check token, and adding the current check token into the request result information to replace the currently stored check token of the request terminal.
7. The method of claim 6, wherein the consolidated page request further comprises: the service page belongs to user identity information of a user, and the check token is generated based on the user identity information;
the method further comprises the following steps:
and verifying the verification token according to the user identity information included in the combined page request.
8. The method of claim 6, wherein the check token is correspondingly provided with a validity period for the new check token to be valid continuously in the validity period after each generation of the new check token.
9. The method of claim 6, wherein communicating with the requesting end comprises: WebSocket, long poll, long connect.
10. A page request processing apparatus comprising:
the system comprises a page request acquisition module, a service processing page processing module and a page request processing module, wherein the page request acquisition module is used for acquiring a plurality of page requests which are initiated from the service processing page and reach a target address in a browser;
the page request merging module is used for merging the multiple page requests to generate a merged page request;
the page request sending module is used for sending the combined page request to a server of the target address;
a request result receiving module, configured to receive request result information sent by the server for each page request in the merged page requests, where the server is configured to generate a piece of corresponding request result information for each page request after concurrently processing each page request in the merged page requests, and send any piece of the request result information to the request end after generating the request result information,
wherein, the merge page request includes: a request body and a check token for preventing cross-site request forgery; the request result information includes: and the execution result or the error information and the check token generated by the server at this time are used for replacing the check token currently stored by the request end.
11. The apparatus of claim 10, wherein the page request merge module comprises:
the page request monitoring unit is used for generating simulation requests according to a preset frequency and monitoring the number of the simulation requests and the page requests which are not processed currently;
and the page request merging unit is used for extracting all unprocessed page requests for merging if the total number of the current unprocessed simulation requests and the page requests is equal to a preset number, generating the merged page request and discarding all the unprocessed simulation requests.
12. The apparatus of claim 10, wherein the consolidated page request further comprises: and the check token is generated based on the user identity information.
13. The apparatus of claim 10, wherein the check token is correspondingly configured with a validity period, and the new check token is configured to be valid continuously during the validity period after each generation of the new check token.
14. The apparatus of claim 10, wherein the means for communicating with the server comprises: WebSocket, long poll, long connect.
15. A page request processing apparatus comprising:
the page request receiving module is used for receiving a combined page request sent by a request end, wherein the combined page request comprises a plurality of page requests initiated from a service processing page;
the page request processing module is used for carrying out concurrent processing on each page request in the combined page request and generating a piece of corresponding request result information aiming at each page request;
a request result feedback module for sending any one piece of request result information to the request end after the request result information is generated,
wherein, the merge page request includes: a request body and a check token for preventing cross-site request forgery;
the device further comprises:
the token checking module is used for checking the checking token;
the page request processing module comprises:
an execution result adding unit, configured to execute a processing service logic based on the request body if the check passes, and add an execution result to the request result information;
an error information adding unit configured to add error information generated by the verification to the request result information if the verification fails;
and the check token adding unit is used for generating a current check token and adding the current check token into the request result information so as to replace the currently stored check token of the request end.
16. The apparatus of claim 15, wherein the consolidated page request further comprises: the service page belongs to user identity information of a user, and the check token is generated based on the user identity information;
the token checking module is further configured to,
and verifying the verification token according to the user identity information included in the combined page request.
17. The apparatus of claim 15, wherein the check token is correspondingly configured with a validity period, and the new check token is configured to be valid for the validity period after each generation of the new check token.
18. The apparatus of claim 15, wherein the means for communicating with the requesting end comprises: WebSocket, long poll, long connect.
19. An electronic device, comprising:
a memory for storing a program;
a processor, coupled to the memory, for executing the program, which when executed performs the page request processing method of any one of claims 1 to 5.
20. An electronic device, comprising:
a memory for storing a program;
a processor, coupled to the memory, for executing the program, which when executed performs the page request processing method of any one of claims 6 to 9.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811488660.3A CN111294369B (en) | 2018-12-06 | 2018-12-06 | Page request processing method and device and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811488660.3A CN111294369B (en) | 2018-12-06 | 2018-12-06 | Page request processing method and device and electronic equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111294369A CN111294369A (en) | 2020-06-16 |
CN111294369B true CN111294369B (en) | 2022-06-03 |
Family
ID=71024235
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811488660.3A Active CN111294369B (en) | 2018-12-06 | 2018-12-06 | Page request processing method and device and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111294369B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113885902B (en) * | 2021-08-23 | 2022-10-11 | 贝壳找房(北京)科技有限公司 | Application program interface updating method |
CN113934953A (en) * | 2021-10-11 | 2022-01-14 | 上海哔哩哔哩科技有限公司 | Webpage first screen rendering method and device |
CN113821750B (en) * | 2021-11-23 | 2022-03-04 | 北京交研智慧科技有限公司 | Page data processing method and system, electronic equipment and readable storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103188248A (en) * | 2011-12-31 | 2013-07-03 | 卓望数码技术(深圳)有限公司 | Identity authentication system and method based on single sign-on |
CN103701714A (en) * | 2013-12-25 | 2014-04-02 | 北京奇虎科技有限公司 | Page extraction method, server and network system |
CN106293794A (en) * | 2015-06-05 | 2017-01-04 | 阿里巴巴集团控股有限公司 | Load the methods, devices and systems of the page |
CN107734012A (en) * | 2017-09-27 | 2018-02-23 | 努比亚技术有限公司 | Information push method, system and computer-readable recording medium |
CN108055311A (en) * | 2017-12-07 | 2018-05-18 | 畅捷通信息技术股份有限公司 | HTTP Asynchronous Requests method, apparatus, server, terminal and storage medium |
CN108769059A (en) * | 2018-06-21 | 2018-11-06 | 网易宝有限公司 | Method of calibration, device, medium and computing device |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
AU775865B2 (en) * | 1999-12-24 | 2004-08-19 | Telstra Corporation Limited | A virtual token |
US20100223677A1 (en) * | 2001-05-15 | 2010-09-02 | Altair Engineering, Inc. | Digital content licensing method |
US8261335B2 (en) * | 2007-02-23 | 2012-09-04 | Hewlett-Packard Company | Method and system for online image security |
-
2018
- 2018-12-06 CN CN201811488660.3A patent/CN111294369B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103188248A (en) * | 2011-12-31 | 2013-07-03 | 卓望数码技术(深圳)有限公司 | Identity authentication system and method based on single sign-on |
CN103701714A (en) * | 2013-12-25 | 2014-04-02 | 北京奇虎科技有限公司 | Page extraction method, server and network system |
CN106293794A (en) * | 2015-06-05 | 2017-01-04 | 阿里巴巴集团控股有限公司 | Load the methods, devices and systems of the page |
CN107734012A (en) * | 2017-09-27 | 2018-02-23 | 努比亚技术有限公司 | Information push method, system and computer-readable recording medium |
CN108055311A (en) * | 2017-12-07 | 2018-05-18 | 畅捷通信息技术股份有限公司 | HTTP Asynchronous Requests method, apparatus, server, terminal and storage medium |
CN108769059A (en) * | 2018-06-21 | 2018-11-06 | 网易宝有限公司 | Method of calibration, device, medium and computing device |
Also Published As
Publication number | Publication date |
---|---|
CN111294369A (en) | 2020-06-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108306877B (en) | NODE JS-based user identity information verification method and device and storage medium | |
CN111294369B (en) | Page request processing method and device and electronic equipment | |
CN108833950B (en) | Barrage message issuing method, server, system and storage medium | |
KR101488268B1 (en) | Push message service system and method thereof | |
US20220115012A1 (en) | Method and apparatus for processing voices, device and computer storage medium | |
US20140245420A1 (en) | Web ticket based upon a symmetric key usable for user authentication | |
CN108052474B (en) | Data format conversion method, device, equipment and computer readable storage medium | |
US20130018948A1 (en) | Method and system for use in providing network services interchange | |
CN101622587A (en) | Be used to wake up the centralized service of computing equipment | |
CN110113381A (en) | The method and device of theme is subscribed in a kind of block chain | |
CN113360301B (en) | Message transmission system and method | |
CN111356117A (en) | Voice interaction method and Bluetooth device | |
US20210350805A1 (en) | Method, apparatus, device and computer storage medium for processing voices | |
CN113225351A (en) | Request processing method and device, storage medium and electronic equipment | |
CN105812413B (en) | Communication method and device | |
CN108632300B (en) | Data synchronization system, method, server, client and electronic equipment | |
CN111212016B (en) | Cross-site request processing method and device and electronic equipment | |
CN109600722B (en) | Short message receiving verification method and device, electronic equipment and storage medium | |
CN103428171A (en) | Session processing method, application server and system | |
CN102510398A (en) | Request concurrent processing method and device, and server | |
CN113133027B (en) | Communication method, server, terminal and communication system | |
CN114265642A (en) | Information processing method, information processing device, electronic equipment and computer readable storage medium | |
CN107977284A (en) | A kind of data processing method, device, server and medium | |
CN109150893B (en) | Service request forwarding method and related device | |
CN114677810A (en) | Storage data processing method and device, electronic equipment and medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |