Network request sending method and device, electronic equipment and storage medium

文档序号:1889406 发布日期:2021-11-26 浏览:4次 中文

阅读说明:本技术 网络请求的发送方法、装置、电子设备及存储介质 (Network request sending method and device, electronic equipment and storage medium ) 是由 胡浩 于 2021-08-02 设计创作,主要内容包括:本公开关于一种网络请求的发送方法、装置、电子设备及存储介质,属于数据处理技术领域,其中,该方法包括:获取待发送的网络请求;其中,网络请求携带有请求参数;在存在与请求参数匹配的网络请求发送记录时,对网络请求发送记录对应的已发送网络请求进行取消处理;发送待发送的网络请求,该方法通过在发送网络请求之前,确定是否存在与请求参数匹配的网络请求发送记录,在存在与请求参数匹配的网络请求发送记录时,对网络请求发送记录对应的已发送网络请求进行取消处理,由此,可自动取消重复的网络请求,解决了页面数据时序错乱,并发过多引起请求阻塞以及手动维护调用过程繁琐的问题。(The disclosure relates to a network request sending method, a network request sending device, electronic equipment and a storage medium, and belongs to the technical field of data processing, wherein the method comprises the following steps: acquiring a network request to be sent; wherein, the network request carries request parameters; when a network request sending record matched with the request parameter exists, canceling a sent network request corresponding to the network request sending record; the method comprises the steps of determining whether a network request sending record matched with a request parameter exists or not before sending the network request, and canceling the sent network request corresponding to the network request sending record when the network request sending record matched with the request parameter exists.)

1. A method for sending a network request, comprising:

acquiring a network request to be sent, wherein the network request carries a request parameter;

when a network request sending record matched with the request parameter exists, canceling a sent network request corresponding to the network request sending record;

and sending the network request to be sent.

2. The method according to claim 1, wherein when there is a network request transmission record matching the request parameter, before canceling a transmitted network request corresponding to the network request transmission record, the method further comprises:

determining parameters to be matched of the network request according to a request mode in the request parameters;

inquiring a data structure according to the parameters to be matched, and determining whether a network request sending record comprising the parameters to be matched exists in the data structure;

when the network request sending record exists in the data structure, determining that a network request sending request matched with the request parameter exists;

and when the network request sending record does not exist in the data structure, determining that the network request sending record matched with the request parameter does not exist.

3. The method according to claim 2, wherein the determining the parameters to be matched of the network request according to the request mode in the request parameters comprises:

when the request mode is a get mode, determining the parameter to be matched as a source address in the request parameter;

alternatively, the first and second electrodes may be,

and when the request mode is a post mode, determining the parameters to be matched as a source address and a request body in the request parameters.

4. The method according to claim 1, wherein the canceling processing of the sent network request corresponding to the network request sending record includes:

acquiring a cancel function in the network request sending record;

and calling the canceling function to cancel the sent network request.

5. The method according to claim 2, further comprising, after canceling the sent network request corresponding to the network request sending record, the step of:

generating a network request sending record corresponding to the network request according to the parameter to be matched and a cancellation function of the network request;

and updating a network request sending record corresponding to the network request into the data structure.

6. The method of claim 5, after sending the network request, further comprising:

and when the reply content corresponding to the network request is received, releasing the network request sending record corresponding to the network request in the data structure.

7. An apparatus for transmitting a network request, comprising:

the system comprises an acquisition module, a sending module and a receiving module, wherein the acquisition module is configured to execute acquisition of a network request to be sent, and the network request carries a request parameter;

a cancellation module configured to perform cancellation processing on a sent network request corresponding to a network request sending record when the network request sending record matching the request parameter exists;

a sending module configured to execute sending the network request to be sent.

8. An electronic device, comprising:

a processor;

a memory for storing the processor-executable instructions;

wherein the processor is configured to execute the instructions to implement the method of network request transmission according to any of claims 1-6.

9. A storage medium in which instructions, when executed by a processor of an electronic device, enable the electronic device to perform the method of transmitting a network request of any one of claims 1-6.

10. A computer program product, comprising a computer program which, when executed by a processor of an electronic device, enables the electronic device to perform the method of transmitting a network request according to any one of claims 1-6.

Technical Field

The present disclosure relates to the field of data processing technologies, and in particular, to a method and an apparatus for sending a network request, an electronic device, and a storage medium.

Background

At present, in a network application with big data And multiple concurrent scenes, such as form query, time consumption of Asynchronous JavaScript And XML (Asynchronous JavaScript And XML And HTML, AJAX for short) requests at the front end And the back end is long, network requests for repeated addresses are more, And incorrect data acquisition in a page can be caused if the problem that the time sequence of response data is not consistent with the time sequence of the requests is not considered.

In the related art, for the problem that the data obtained from the page may be incorrect due to the fact that the timing sequence of the response data is not consistent with the request timing sequence, the data requested last time is selected as correct data mainly in the service code through a manual writing logic, for example, an independent identifier is set for each request, and only the data corresponding to the latest identifier is used.

However, the current problem is that although the latest data result can be obtained by manually writing logic, the network request is still repeatedly sent out, which results in repeated calculation at the back end, and if the response time is long, the maximum concurrency limit of the browser is easily triggered; and the manual code compiling process is complicated and difficult to control.

Disclosure of Invention

The disclosure provides a network request sending method, a network request sending device, electronic equipment and a storage medium, which are used for at least solving the problems that in a scene of large data concurrency in the related art, the network request response is slow, the page data time sequence disorder is easily caused, the maximum page concurrency limit is easily caused, the request blocking is caused, and the manual maintenance calling process is complicated. The technical scheme of the disclosure is as follows:

according to a first aspect of the embodiments of the present disclosure, a method for sending a network request is provided, including: acquiring a network request to be sent, wherein the network request carries a request parameter; when a network request sending record matched with the request parameter exists, canceling a sent network request corresponding to the network request sending record; and sending the network request to be sent.

According to a second aspect of the embodiments of the present disclosure, there is provided a device for sending a network request, including: the system comprises an acquisition module, a sending module and a receiving module, wherein the acquisition module is configured to execute acquisition of a network request to be sent, and the network request carries a request parameter; a cancellation module configured to perform cancellation processing on a sent network request corresponding to a network request sending record when the network request sending record matching the request parameter exists; a sending module configured to execute sending the network request to be sent.

According to a third aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including: a processor; a memory for storing the processor-executable instructions; wherein the processor is configured to execute the instructions to implement the network request transmission method as described above.

According to a fourth aspect of the embodiments of the present disclosure, there is provided a storage medium, wherein instructions that, when executed by a processor of an electronic device, enable the electronic device to perform the method for transmitting a network request as described above.

According to a fifth aspect of embodiments of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor of an electronic device, enables the electronic device to perform a method of transmitting a network request as described above.

The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects: by judging whether a network request sending record matched with the request parameter exists or not before sending the network request and canceling the sent network request corresponding to the network request sending record when the network request sending record matched with the request parameter exists, repeated network requests can be automatically canceled, and the problems of disordered page data time sequence, excessive request blocking and complicated manual maintenance calling process are solved.

It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.

Drawings

The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.

FIG. 1 is a flow chart illustrating a method of transmitting a network request in accordance with an exemplary embodiment;

FIG. 2 is a flow chart illustrating a method of transmitting a network request according to an example embodiment;

FIG. 3 illustrates a form query page corresponding to different requestors for the same url in accordance with an exemplary embodiment;

FIG. 4 illustrates a form query page corresponding to the same url same requestor in accordance with an exemplary embodiment;

FIG. 5 is a flow chart illustrating a method of transmitting a network request according to an example embodiment;

FIG. 6 is a storage diagram illustrating a data structure in accordance with an exemplary embodiment;

FIG. 7 is a storage diagram illustrating a data structure in accordance with an exemplary embodiment;

FIG. 8 is a flow chart illustrating a method of transmitting a network request according to an example embodiment;

fig. 9 is a schematic diagram illustrating a structure of a network request transmitting apparatus according to an example embodiment;

FIG. 10 is a block diagram illustrating an electronic device for transmission of a network request in accordance with an example embodiment.

Detailed Description

In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.

It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.

Fig. 1 is a flowchart illustrating a method for transmitting a network request according to an exemplary embodiment, as shown in fig. 1, including the following steps.

In step 101, a network request to be sent is obtained, where the network request carries a request parameter.

The main execution unit of the network request transmission method according to the present disclosure is a network request transmission device. The network request sending method according to the embodiment of the present disclosure may be executed by the network request sending apparatus according to the embodiment of the present disclosure, and the network request sending apparatus according to the embodiment of the present disclosure may be configured in any electronic device to execute the network request sending method according to the embodiment of the present disclosure.

For example, after a website is input in the browser and a connection is established between the browser and the server, the browser may send a network request to the server, and before the browser sends the network request to the server, the sending device of the network request may obtain the network request and use the network request as a network request to be sent.

For another example, after determining the filtering condition on the form query page, when the query button is clicked, the browser may send an Xmlhttrequest (XHR) network request to the server, and before the browser sends the network request to the server, the network request sending device may obtain the XHR network request, and use the XHR network request as the network request to be sent.

It is understood that, in order to enable the server to perform data response according to the network request, the network request may carry request parameters. In the disclosed embodiment, the request parameters may include, but are not limited to, request mode, request body, source address, and the like.

In the embodiment of the disclosure, the request mode may be a get mode or a Post mode, the requestor in the get mode may be param, and the requestor in the Post mode may be body. For example, a "new year" is entered in the page search box, and the requesting entity may be the "new year". The source address may be a network address in a request parameter, such as a uniform resource locator (url) address.

In step 102, when there is a network request transmission record matching the request parameter, a cancellation process is performed on a transmitted network request corresponding to the network request transmission record.

In order to cancel a network request repeated with a network request before sending the network request to be sent, in the embodiment of the present disclosure, it may be determined whether a network request sending record matching a request parameter exists in a preset data structure, and when a network request sending record matching the request parameter exists in the preset data structure, a sent network request corresponding to the network request sending record is cancelled. The preset data structure may be, for example, a map data structure (key-value pair manner) established in the browser environment.

In addition, when the network request sending record matched with the request parameter does not exist in the preset data structure, the fact that the sent network request which is repeated with the network request does not exist is indicated, and cancellation processing is not performed.

In step 103, a network request to be sent is sent.

Then, after canceling the sent network request corresponding to the network request sending record, the network request to be sent may be sent.

In summary, before the network request is sent, whether a network request sending record matched with the request parameter exists in the preset data structure is determined, and when the network request sending record matched with the request parameter exists in the preset data structure, the sent network request corresponding to the network request sending record is cancelled, so that repeated network requests can be cancelled automatically, and the problems of request blocking and complicated manual maintenance calling process caused by page data time sequence disorder and excessive requests are solved.

In order to accurately cancel a network request repeated with the network request, as shown in fig. 2, fig. 2 is a flowchart illustrating a further method for sending a network request according to an exemplary embodiment, in an embodiment of the present disclosure, before a sent network request corresponding to a network request sending record is cancelled, it may be determined whether a network request sending record including a parameter to be matched exists in a data structure, and when a network request sending record matching a request parameter exists, the sent network request corresponding to the network request sending record is cancelled, which is implemented as follows:

in step 201, a network request to be sent is obtained, where the network request carries a request parameter.

In step 202, according to the request mode in the request parameters, the parameters to be matched of the network request are determined.

In order to accurately determine the network request sending record matched with the request parameter, in the embodiment of the disclosure, the parameter to be matched of the network request may be determined according to the request mode in the request parameter.

As an example, when the request mode is the get mode, the parameter to be matched is determined to be the source address in the request parameter.

That is to say, in the embodiment of the present disclosure, the determination of the request mode may be performed according to a parameter in the request parameter, and when the request mode is the get mode, the source address in the request parameter may be used as the parameter to be matched. For example, in the get mode, the source address "www.xx.com" in the request parameter can be used as the parameter to be matched.

As another example, when the request mode is the post mode, the parameters to be matched are determined as the source address in the request parameters and the request body.

That is to say, in the embodiment of the present disclosure, the determination of the request mode may be performed according to a parameter in the request parameter, and when the request mode is the post mode, the source address and the request body in the request parameter may be used as the parameters to be matched. It should be noted that, in the post mode, the requesting entity may be a body.

For example, when performing form query according to the screening condition, the request mode may be determined to be the post mode according to the request parameter, and the website in the request parameter and the screening condition may be used as the parameter to be matched. For example, the parameters to be matched are "xxx.com/pageB/query" and "{ ' polymeric ': { ' a }: xxx, ' b ': xxx }", wherein "xxx.com/pageB/query" is the url address and "{ ' polymeric ': a }: xxx, ' b ': xxx }" is the request body.

In step 203, the data structure is queried according to the parameters to be matched, and it is determined whether a network request sending record including the parameters to be matched exists in the data structure.

Furthermore, a preset data structure can be queried according to the parameters to be matched of the network request, and whether the network request sending record comprising the parameters to be matched exists in the data structure can be judged according to the query result.

For example, a preset data structure may be queried according to the source address in the request parameter, and whether a network request transmission record including the source address exists in the data structure is determined.

For another example, a preset data structure may be queried according to the source address and the request body in the request parameter, and whether a network request transmission record including the source address and the request body exists in the data structure may be determined.

In step 204, when a network request transmission record exists in the data structure, it is determined that a network request transmission request matching the request parameter exists.

Further, when a network request sending record exists in the data structure, the network request sending request matched with the request parameter can be determined to exist in the data structure; and when the network request sending record does not exist in the data structure, determining that the network request sending record matched with the request parameter does not exist.

In step 205, when there is a network request transmission record matching the request parameter, a cancellation process is performed on the transmitted network request corresponding to the network request transmission record.

Optionally, a cancel function in the network request sending record is obtained, the cancel function is called, and the sent network request is cancelled.

That is, when the network request sending record matched with the request parameter is inquired in the preset data structure, the sent network request can be cancelled according to the cancellation function in the network request sending record. In a preset data structure, each network request sending record can be provided with a corresponding cancellation function, and parameters in the cancellation functions corresponding to different network request sending records can be different.

In the embodiment of the present disclosure, the parameter matching method can be divided into a default mode and a url mode according to different parameters to be matched.

As an example, when the parameter to be matched is the source address in the request parameter, it may be queried whether a network request transmission record matching the source address exists in a preset data structure, and when the network request transmission record matching the source address is queried in the preset data structure, the transmitted network request may be cancelled according to a cancellation function in the network request transmission record. In embodiments of the present disclosure, the mode may be a "url" mode.

For example, in the form query page, the form a parameter is queried for the first time, the form B parameter is queried for the second time, if the data query quantity of the query form a parameter is large, the back end may return the result of querying the form B first, and then the result of querying the form a parameter is returned, and in the page, the result of querying the form a parameter covers the result of querying the form B, so that the request for querying the form a is cancelled, and the form data related to the form B parameter is acquired.

For example, as shown in fig. 3, in the form query page, when a query is performed for the first time, the screening condition corresponding to 1 is selected, a query is required to be transmitted to the url address "xxx.com/pagea/options" for the object "{ options: ' page ' }", when a query is performed for the second time, the screening condition corresponding to 2 is selected, a query is required to be transmitted to the url address "xxx.com/pagea/options" for the object "{ options: ' play ' }", when a query is performed for the third time, the screening condition corresponding to 3 is selected, a query is required to be transmitted to the object "xxx.com/pagea/options" for the object "{ options: ' version ' }", when a query is performed for the fourth time, the screening condition corresponding to 4 is selected, and the screening condition: ' bucket ' } ' is required to be transmitted to the object "xxx.com/pagea/options", that is the same, and the query objects are different, and the query is called the same "different request objects," and the same "url" different "request modes". When the form page is queried for the second time, the network request sending record matched with the url address in the second query can be queried in the preset data structure, the first query request can be cancelled according to the cancellation function in the second query request sending record, and so on, the second query request can be cancelled in the third query, and the third query can be cancelled in the fourth query.

As another example, when the parameter to be matched is the source address and the request body in the request parameter, it may be queried whether a network request transmission record matching the source address and the request body exists in a preset data structure, and when the network request transmission record matching the source address and the request body is queried in the preset data structure, the transmitted network request may be cancelled according to a cancellation function in the network request transmission record. In the disclosed embodiment, the mode may be a default mode.

For example, as shown in fig. 4, a user selects a filtering condition and then clicks a query, at this time, a browser initiates a request to a server, a url address is "xxx.com/pageB/query", a request body is "{ 'commercial': a }: xxx, 'b': xxx }", the user does not change the filtering condition, the user continuously clicks a query button, at this time, the url address and the request body of the issued request are the same and unchanged, that is, the same url and the same request body, and when the query button is clicked for the second time, a cancellation function in a record is sent according to a network request matched with the url and the request body, so as to cancel the first query request.

In step 206, a network request to be sent is sent.

In the embodiment of the present disclosure, the detailed description of steps 201 and 206 may refer to steps 101 and 103 in the embodiment described in fig. 1, and the detailed description of the present disclosure is omitted.

In summary, different parameters to be matched of the network request are determined according to different request modes in the request parameters, and then the data structure is queried according to the parameters to be matched, whether a network request sending record including the parameters to be matched exists in the data structure is determined, and when the network request sending record matched with the request parameters exists in the preset data structure, the sent network request corresponding to the network request sending record is cancelled, so that repeated network requests can be automatically cancelled, and the problems of request blocking and complicated manual maintenance calling process caused by page data time sequence disorder and excessive requests are solved.

In order to facilitate querying a preset data structure when a subsequent network request is sent to cancel a repeated network request, as shown in fig. 5, fig. 5 is a flowchart illustrating a further network request sending method according to an exemplary embodiment, and in the embodiment of the present disclosure, after a corresponding sent network request is cancelled, the preset data structure may be updated, where the specific implementation process is as follows:

in step 501, a network request to be sent is obtained, where the network request carries a request parameter.

In step 502, when there is a network request transmission record matching the request parameter, a cancellation process is performed on a transmitted network request corresponding to the network request transmission record.

In step 503, a network request sending record corresponding to the network request is generated according to the parameter to be matched and the cancellation function of the network request.

In order to facilitate querying a preset data structure when a subsequent network request is sent to cancel a repeated network request, in the embodiment of the present disclosure, a network request sending record corresponding to the network request may be generated according to a parameter to be matched and a cancellation function of the network request.

As an example, in order to accurately cancel a sent network request corresponding to a network request sending record, parameters to be matched and a cancellation function are stored in a data structure in a key value pair manner.

For example, the parameter to be matched may be used as a Key Value, and the cancellation function of the network request may be used as Value, so as to generate a network request sending record corresponding to the network request.

As an example, as shown in fig. 6, the url of the request is serialized (e.g., using json. striping) as a key value, and the abort method setting of the object is put into the value corresponding to the key value.

As another example, as shown in FIG. 7, the url and the request body of the request are serialized and merged as a key value, and the abort method setting of the object is put into the value corresponding to the key value.

In step 504, the network request transmission record corresponding to the network request is updated into the data structure.

Then, the parameters to be matched and the cancellation function in the network request sending record corresponding to the network request can be updated to the data structure in a key value pair mode, so that the preset data structure can be inquired when the subsequent network request is sent, and repeated network requests can be cancelled.

In step 505, a network request to be sent is sent.

In the embodiment of the present disclosure, the details of steps 501, 502 and step 505 can refer to step 101 and step 103 in the embodiment described in fig. 1, and are not described in detail in this application.

In summary, after the corresponding sent network request is cancelled, the data structure can be updated, so that the preset data structure can be conveniently queried when the subsequent network request is sent, repeated network requests can be cancelled, and the problems of request blocking and complicated manual maintenance calling process caused by page data time sequence disorder and excessive requests can be solved.

In order to save related resources, as shown in fig. 8, fig. 8 is a sending method of a network request according to an exemplary embodiment, in this disclosure, after sending the network request, when receiving a reply content corresponding to the network request, a network request sending record corresponding to the network request in a data structure may be released, which is implemented as follows:

in step 801, a network request to be sent is obtained, where the network request carries a request parameter.

In step 802, when there is a network request transmission record matching the request parameter, a cancellation process is performed on a transmitted network request corresponding to the network request transmission record.

In step 803, a network request to be sent is sent.

In the embodiment of the present disclosure, the details of steps 801-803 can be referred to as steps 101-103, which are not described in detail herein.

In step 804, when the reply content corresponding to the network request is received, the network request transmission record corresponding to the network request in the data structure is released.

That is to say, after sending the network request, the server makes the corresponding reply content according to the network request, and further, can release the network request sending record corresponding to the network request in the data structure, so as to avoid wasting relevant resources when the subsequent network request queries the data structure. For example, in the state of success of abort () and error in response, the network request transmission record corresponding to the network request in the data structure may be deleted to be released.

In summary, after the network request is sent, when the reply content corresponding to the network request is received, the network request sending record corresponding to the network request in the data structure can be released, thereby saving related resources.

In order that the present disclosure may be more clearly understood by those skilled in the art, the description will now be given by way of example.

For example, taking the request mode as the get mode:

1. in a browser environment, establishing a map data structure;

2. a setting interceptor, which rewrites an open method of an XHR class (XHR is a built-in class in a browser, and each request corresponds to an XHR object when the request is initiated), and before the open method is executed, as shown in fig. 4, serializes a url of the request (for example, using json. striping) as a key value, and puts the abort method setting of the object into a value corresponding to the key value;

3. judging in a packaged http method, if the configuration parameter is url which is finally transmitted, entering into url mode logic of the rewritten XHR object, and if the configuration parameter which is finally transmitted is default, entering into default mode logic of the rewritten XHR object; for example, it is possible to perform a package once on the Axios class, and use axio.

3. Calling an abort method corresponding to the key in the map data structure, and canceling the last repeated request;

4. sending a network request;

5. the record in the map data structure is released, for example, in the states of abort success and response error, the corresponding record in the map is judged and deleted.

The method for sending the network request of the embodiment of the disclosure obtains the network request to be sent, wherein the network request carries request parameters; when a network request sending record matched with the request parameter exists, canceling a sent network request corresponding to the network request sending record; and sending the network request to be sent. According to the method, before the network request is sent, whether the network request sending record matched with the request parameter exists or not is judged, and when the network request sending record matched with the request parameter exists, the sent network request corresponding to the network request sending record is cancelled, so that repeated network requests can be automatically cancelled, and the problems of disordered page data time sequence, excessive request blocking and complicated manual maintenance calling process are solved.

In order to implement the foregoing embodiments, the present disclosure provides a device for sending a network request.

Fig. 9 is a schematic structural diagram illustrating a network request transmitting apparatus according to an exemplary embodiment, and referring to fig. 9, the network request transmitting apparatus 900 may include: an acquisition module 910, a cancellation module 920, and a sending module 930.

The obtaining module 910 is configured to perform obtaining a network request to be sent, where the network request carries a request parameter; a cancellation module 920 configured to perform cancellation processing on a sent network request corresponding to a network request sending record when the network request sending record matching the request parameter exists; a transmitting module 930 configured to perform transmitting the network request to be transmitted.

As a possible implementation manner of the embodiment of the present disclosure, the apparatus 900 for sending a network request further includes: the device comprises a first determination module, a query module and a second determination module.

The first determining module is configured to determine the parameters to be matched of the network request according to the request mode in the request parameters; the query module is configured to execute querying a data structure according to the parameters to be matched and determine whether a network request sending record comprising the parameters to be matched exists in the data structure; a second determining module configured to determine that a network request transmission request matching the request parameter exists when a network request transmission record exists in the data structure; and the second determination module is configured to determine that no network request sending record matched with the request parameter exists when no network request sending record exists in the data structure.

As a possible implementation manner of the embodiment of the present disclosure, the first determining module includes: a determination unit.

The determining unit is configured to determine that the parameter to be matched is the source address in the request parameter when the request mode is the get mode; or when the request mode is the post mode, determining the parameters to be matched as the source address and the request body in the request parameters.

As a possible implementation manner of the embodiment of the present disclosure, the cancellation module includes: an acquisition unit and a cancellation unit.

The acquisition unit is configured to execute a cancel function in the acquisition network request sending record; and the canceling unit is configured to execute a call canceling function to cancel the sent network request.

As a possible implementation manner of the embodiment of the present disclosure, the apparatus 900 for sending a network request further includes: the device comprises a generating module and an updating module.

The generating module is configured to execute a cancellation function according to the parameters to be matched and the network request, and generate a network request sending record corresponding to the network request; and the updating module is configured to update the network request sending record corresponding to the network request into the data structure.

As a possible implementation manner of the embodiment of the present disclosure, the apparatus 900 for sending a network request further includes: and releasing the module.

And the releasing module is configured to release the network request sending record corresponding to the network request in the data structure when the reply content corresponding to the network request is received.

As a possible implementation manner of the embodiment of the present disclosure, the update module is configured to perform: and updating the parameters to be matched and the cancellation function in a network request sending record corresponding to the network request into the data structure in a key value pair mode. With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.

The network request sending device of the embodiment of the disclosure obtains a network request to be sent, wherein the network request carries a request parameter; when a network request sending record matched with the request parameter exists, canceling a sent network request corresponding to the network request sending record; and sending the network request to be sent. The device can determine whether the network request sending records matched with the request parameters exist or not before the network request is sent, and when the network request sending records matched with the request parameters exist in the preset data structure, the sent network requests corresponding to the network request sending records are cancelled, so that repeated network requests can be automatically cancelled, and the problems of request blocking and complicated manual maintenance calling process caused by page data time sequence disorder and excessive requests are solved.

Fig. 10 is a block diagram illustrating an electronic device for a method of transmitting a network request according to an example embodiment.

As shown in fig. 10, the electronic device 1000 includes:

a memory 1010 and a processor 1020, a bus 1030 connecting different components (including the memory 1010 and the processor 1020), wherein the memory 1010 stores a computer program, and the processor 1020 executes the computer program to implement the network request sending method according to the embodiment of the disclosure.

Bus 1030 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.

The electronic device 1000 typically includes a variety of electronic device readable media. Such media may be any available media that is accessible by electronic device 1000 and includes both volatile and nonvolatile media, removable and non-removable media.

Memory 1010 may also include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)1040 and/or cache memory 1050. The electronic device 1000 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 1060 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 10, commonly referred to as a "hard disk drive"). Although not shown in FIG. 10, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In such cases, each drive may be connected to bus 1030 by one or more data media interfaces. Memory 1010 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the disclosure.

Program/utility 1080 having a set (at least one) of program modules 1070 may be stored, for example, in memory 1010, such program modules 1070 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 1070 generally perform the functions and/or methods of the embodiments described in this disclosure.

The electronic device 1000 may also communicate with one or more external devices 1090 (e.g., keyboard, pointing device, display 1091, etc.), with one or more devices that enable a user to interact with the electronic device 1000, and/or with any devices (e.g., network card, modem, etc.) that enable the electronic device 1000 to communicate with one or more other computing devices. Such communication may occur through an input/output (I/O) interface 1092. Also, the electronic device 1000 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network such as the internet) via the network adapter 1093. As shown in FIG. 10, the network adapter 1093 communicates with the other modules of the electronic device 800 via the bus 1030. It should be appreciated that although not shown in FIG. 10, other hardware and/or software modules may be used in conjunction with the electronic device 1000, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.

The processor 1020 executes various functional applications and data processing by executing programs stored in the memory 1010.

It should be noted that, for the implementation process and the technical principle of the electronic device of this embodiment, reference is made to the foregoing explanation of the method for sending a network request according to the embodiment of the present disclosure, and details are not described herein again.

The electronic device provided by the embodiment of the present disclosure may execute the sending method of the network request as described above, by acquiring a network request to be sent, where the network request carries a request parameter; when a network request sending record matched with the request parameter exists in a preset data structure, canceling a sent network request corresponding to the network request sending record; a network request is sent. The method and the device can determine whether the network request sending record matched with the request parameter exists in the preset data structure before the network request is sent, and cancel the sent network request corresponding to the network request sending record when the network request sending record matched with the request parameter exists in the preset data structure, so that repeated network requests can be automatically cancelled, and the problems of request blocking and complicated manual maintenance calling process caused by page data time sequence disorder and excessive request blocking are solved.

In order to implement the above embodiments, the present disclosure also provides a storage medium.

Wherein the instructions in the storage medium, when executed by a processor of the electronic device, enable the electronic device to perform the method of transmitting the network request as previously described.

To implement the above embodiments, the present disclosure also provides a computer program product comprising a computer program, which, when executed by a processor of an electronic device, enables the electronic device to perform the method for sending a network request as described above.

Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.

It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

18页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种运营数据处理方法及相关装置

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!