CN115242862A - Network request control method, device, medium and electronic equipment - Google Patents

Network request control method, device, medium and electronic equipment Download PDF

Info

Publication number
CN115242862A
CN115242862A CN202210900155.5A CN202210900155A CN115242862A CN 115242862 A CN115242862 A CN 115242862A CN 202210900155 A CN202210900155 A CN 202210900155A CN 115242862 A CN115242862 A CN 115242862A
Authority
CN
China
Prior art keywords
interception
target page
network request
network
page
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210900155.5A
Other languages
Chinese (zh)
Inventor
周培玉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Yancheng Tianyanchawei Technology Co ltd
Original Assignee
Yancheng Jindi Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Yancheng Jindi Technology Co Ltd filed Critical Yancheng Jindi Technology Co Ltd
Priority to CN202210900155.5A priority Critical patent/CN115242862A/en
Publication of CN115242862A publication Critical patent/CN115242862A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/2866Architectures; Arrangements
    • H04L67/30Profiles
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention relates to a network request control method, a device, a medium and an electronic device, wherein the method comprises the following steps: acquiring a network request of a target page, wherein the target page is any page in an application program; determining switch control parameters of the network request of the target page under the condition that the target page belongs to a preset type, wherein the switch control parameters comprise opening or closing, and the opening or the closing respectively represents that the network request of the target page needs to be opened or closed to be intercepted; responsive to the target page being turned on, turning on or off interception of the network request of the target page according to the switch control parameter. The invention can realize interception control of the network request at the page level.

Description

Network request control method, device, medium and electronic equipment
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, a medium, and an electronic device for controlling a network request.
Background
With the ecological development of the application programs, more and more application programs require characteristics of high configurability, high dynamic degree and the like. Therefore, a hybrid development mode is usually adopted for the demand development of the application program. In the hybrid development mode, an offline scheme is adopted to accelerate the display of the page, and in the process of accelerating the display of the page, the network requests of all pages in the application program need to be intercepted to replace the corresponding resources. However, intercepting network requests within all pages can cause some unknown errors to the application.
Disclosure of Invention
This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
In a first aspect, the present invention provides a network request control method, including:
acquiring a network request of a target page, wherein the target page is any page in an application program;
determining switch control parameters of the network request of the target page under the condition that the target page belongs to a preset type, wherein the switch control parameters comprise opening or closing, and the opening or the closing respectively represents that the network request of the target page needs to be opened or closed to be intercepted;
responsive to the target page being turned on, turning on or off interception of the network request of the target page according to the switch control parameter.
Optionally, the turning on or turning off the interception of the network request to the target page according to the switch control parameter includes:
and starting or closing the interception of the network request of the target page according to the switch control parameter and the network interception state of the target page, wherein the network interception state comprises interception or non-interception, and the interception or the non-interception respectively represents that the network request of the target page is intercepted or not intercepted.
Optionally, the method further comprises:
responding to starting or closing the interception of the network request of a previous page or a next page of the target page in the application program, and respectively determining the network interception state of the target page as the interception or the non-interception.
Optionally, the turning on or turning off the interception of the network request to the target page according to the switch control parameter includes:
starting the interception of the network request of the target page under the conditions that the switch control parameter is started and the network interception state is not intercepted, and determining the network interception state of the target page as interception at a preset stage of the life cycle of the target page;
and when the switch control parameter is closed and the network interception state is interception, closing the interception of the network request of the target page, and determining the network interception state of the target page as non-interception at the preset stage of the life cycle of the target page.
Optionally, the turning on or off the interception of the network request to the target page includes:
and calling an interception method or an interception cancellation method in a preset class provided by an operating system to start or close interception of the network request of the target page, wherein the interception method is used for starting interception of the network requests of all pages in the application program, and the interception cancellation method is used for closing interception of the network requests of all pages.
Optionally, the invoking an interception method or an interception cancellation method in a preset class provided by an operating system includes:
respectively sequencing and splicing the obtained first characters and the second characters to obtain first character strings and second character strings, and calling the interception method in the preset class through the first character strings and the second character strings; or
Respectively sequencing and splicing the obtained first characters and the third characters to obtain first character strings and third character strings, and calling the interception canceling method in the preset class of the operating system through the first character strings and the third character strings;
the first character string is the character string of the preset class, the second character string is the character string of the interception method, and the third character string is the character string of the interception cancellation method.
Optionally, after the network request for obtaining the target page, the method further includes:
searching a network request of the target page in a preset network request set, wherein the preset network request set comprises a plurality of network requests belonging to the preset type;
and determining that the network request of the target webpage belongs to the preset type under the condition that the network request of the target webpage is found in the preset network request set.
In a second aspect, the present invention provides a network request control apparatus, comprising:
the acquisition module is configured to acquire a network request of a target page, wherein the target page is any page in an application program;
a first determining module, configured to determine, when the target page belongs to a preset type, a switch control parameter of the network request of the target page, where the switch control parameter includes an on state or an off state, and the on state or the off state represents that interception of the network request of the target page needs to be turned on or turned off, respectively;
a control module configured to turn on or off interception of the network request of the target page according to the switch control parameter in response to the target page being turned on.
In a third aspect, the present invention provides a computer-readable medium having stored thereon a computer program which, when executed by a processing device, performs the steps of the network request control method of the first aspect.
In a fourth aspect, the present invention provides an electronic device, comprising:
a storage device having a computer program stored thereon;
processing means for executing the computer program in the storage means to implement the steps of the network request control method of the first aspect.
According to the technical scheme, when the target page is started, the interception of the network request of the target page is started or closed according to the switch control parameters, so that the interception control of the network request of the page level can be realized, and the problem of network request risk caused by network interception of partial pages which do not need network interception is avoided. And the network request of the page to be intercepted can be intercepted more accurately by the interception control of the network request of the page level.
Additional features and advantages of the invention will be set forth in the detailed description which follows.
Drawings
The above and other features, advantages and aspects of various embodiments of the present invention will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale. In the drawings:
FIG. 1 is a flow chart illustrating a network request control method according to an exemplary embodiment;
FIG. 2 is a block diagram illustrating a network request control device in accordance with an exemplary embodiment;
fig. 3 is a schematic diagram of a structure of an electronic device according to an exemplary embodiment.
Detailed Description
Embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present invention are shown in the drawings, it should be understood that the present invention may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present invention. It should be understood that the drawings and the embodiments of the present invention are illustrative only and are not intended to limit the scope of the present invention.
It should be understood that the various steps recited in method embodiments of the present invention may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the invention is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present invention are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in the present invention are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that reference to "one or more" unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present invention are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
As background art shows, with the ecological development of applications, more and more applications require characteristics such as high configurability and high degree of dynamism. Therefore, a hybrid development mode is usually adopted for the demand development of the application program. In the hybrid development mode, an offline scheme is adopted to accelerate the display of the page, and in the process of accelerating the display of the page, the network requests of all pages in the application program need to be intercepted to replace the corresponding resources. However, intercepting network requests within all pages can cause some unknown errors to the application.
Illustratively, the whole application program is composed of not only business Web pages, but also native pages, RN pages, third-party Web pages and the like. Intercepting the network requests of all the pages in the application program means intercepting the network requests in all the pages, so that some unknown errors can occur after the network requests of some Web pages which are not self-service are intercepted.
Fig. 1 is a flowchart illustrating a network request control method, which may be applied to an electronic device, according to an exemplary embodiment. As shown in fig. 1, the method comprises the steps of:
step 110, acquiring a network request of a target page, wherein the target page is any page in an application program;
in some embodiments, the application may include at least one of the following pages: native pages, web pages (i.e., world wide Web pages), and read Native pages (hereinafter referred to as RN pages).
In some embodiments, the native page may be an application page developed based on a local operating system (i.e., native system) of the terminal, for example, an application page developed based on a development language, a development class library, and a development tool provided by a local operating system of the mobile phone, such as IOS, android (Android).
In some embodiments, the Web pages are Web pages written based on HyperText Markup Language (HTML), java Language, and/or other programming languages. Usually, a Web page is presented through a browser, that is, a source code of the Web page is converted into the Web page through a kernel of the browser.
In some embodiments, the RN page may be a page written by read Native technology. The fact Native technology is a cross-platform development technology, and a JavaScript library of a Web-based interactive interface is constructed.
In some embodiments, the target page may be a page to be launched that initiates a network request, and the page may be any one of a native page, a Web page, and an RN page. For specific details of the native page, the Web page, and the RN page, reference may be made to the related description, and details are not repeated here. In some embodiments, the network request for the target page may be initiated automatically by the application.
Step 120, determining on-off control parameters of the network request of the target page under the condition that the target page belongs to a preset type, wherein the on-off control parameters comprise opening or closing, and the opening or closing respectively represents that the network request of the target page needs to be opened or closed to be intercepted;
in some embodiments, the preset type may be a page type that requires network interception, and the preset type may be flexibly determined according to actual requirements. In some embodiments, it may be determined whether the target page is of a preset type through a network request of the target page. For example, it may be determined that the target page belongs to the preset type in a case that the network request of the target page includes a URL (Uniform resource Locator) address; and under the condition that the network request of the target page does not comprise the URL address, determining that the target page does not belong to the preset type. The invention only carries out the opening or closing of the interception of the network request on the target page belonging to the preset type, namely, only carries out the network interception control on the target page belonging to the preset type, thereby avoiding the resource waste caused by carrying out the network interception control on all types of pages and further improving the interception control efficiency of the network request of the target page.
In some embodiments, it may also be determined whether the network request of the target page belongs to a preset type according to a preset network request set. Correspondingly, in some embodiments, after obtaining the network request of the target page, the method further includes: searching a network request of a target page in a preset network request set, wherein the preset network request set comprises a plurality of network requests belonging to a preset type; and under the condition that the network request of the target page is searched in the preset network request set, determining that the network request of the target page belongs to a preset type.
In some embodiments, the preset set of network requests may include a plurality of network requests belonging to a Web page. In some embodiments, the network request of the Web page may include a URL address of the Web page, that is, a Web address, and correspondingly, the plurality of network requests in the preset network request set may refer to a plurality of URL addresses. Illustratively, the pre-defined set of network requests may include network request 1 http:// www.AAA.com/xxx1", network request 2 ″ -http:// www.AAA.com/xxx2", and network request 3 ″ -http:// www.AAA.com/xxx3", and so on.
In some embodiments, the URL address in the preset network request set may be flexibly set according to actual requirements, for example, the URL address in the preset network request set may be determined according to service requirements, that is, the preset network request set includes a Web page in a service layer, and by performing interception control only on the network request of the Web page in the service layer, an error occurring inside the third-party Web page due to interception of the third-party Web page included in the Web page may be avoided. The network request of the page to be intercepted can be customized through the preset network request, and the interception control of the network request of the page level can be flexibly and cooperatively realized.
In some embodiments, the preset network request set may be obtained from a configuration file acquired by the terminal, and the configuration file may be automatically acquired by the terminal at the time of startup. The preset network request set is obtained through the configuration file, the terminal can automatically load the preset network request set, and the acquisition efficiency of the preset network request set is improved.
In some embodiments, the switch control parameter in the network request may be characterized by an identification, for example, the switch control parameter may include "network policy = Yes" and "network policy = No", where "network policy = Yes" characterizes the switch control parameter as on and "network policy = No" characterizes the switch control parameter as off.
As previously described, the network request may include a URL address, and in some embodiments, the switch control parameters may be concatenated after the URL address in the network request. For example, taking the example that the network request of the target page is "http:// www.aaa. Com/xxx1network policy = Yes", it is known from the network request of the target page that the switch control parameter of the target page is turned on, and at this time, the interception of the network request of the target page needs to be turned on.
Step 130, in response to the target page being turned on, turning on or off interception of the network request of the target page according to the switch control parameter.
According to the embodiment of the invention, when the target page is started, the interception of the network request of the target page is started or closed according to the switch control parameter, so that the interception control of the network request of the page level can be realized, and the problem of network request risk caused by network interception of partial pages which do not need network interception is avoided. And because the network request of the target page is intercepted when the target page is opened, from the perspective of the user, the user can only sense the interception control of the network request of the target page and cannot sense the interception control of the network requests of other pages, so that even if the target page is subjected to network interception in a global interception mode, the user does not sense the interception control of the page-level network request sensed by the user.
In some embodiments, turning on or off interception of a network request for a target page may include: and calling an interception method or an interception cancellation method in a preset class provided by the operating system to start or close the interception of the network request of the target page, wherein the interception method is used for starting the interception of the network requests of all pages in the application program, and the interception cancellation method is used for closing the interception of the network requests of all pages.
In some embodiments, the operating system may be an IOS system, the preset class may be a WK Browsing control Controller class, the interception method may be a register Scheme For Custom Protocol method in the WK Browsing control Controller class, and the interception cancellation method may be an unregister Scheme For Custom Protocol method in the WK Browsing control Controller class. For specific details of the WK Browsing Context Controller class, the register Scheme For Custom Protocol method and the unregister Scheme For Custom Protocol method, reference may be made to related technologies, and details thereof are not repeated herein.
The method comprises the steps of calling an interception method or an interception cancellation method in a preset class provided by an operating system to perform network interception on the page, directly calling the existing interception method or interception cancellation method in the operating system, and improving the interception control efficiency of the page without compiling the interception method or interception cancellation method again by developers.
In some embodiments, invoking an interception method or an interception cancellation method in a preset class provided by an operating system includes: respectively sequencing and splicing the obtained first characters and the second characters to obtain first character strings and second character strings, and calling an interception method in a preset class through the first character strings and the second character strings; or sequencing and splicing the obtained first characters and the third characters respectively to obtain first character strings and third character strings, and calling a interception canceling method in the preset class of the operating system through the first character strings and the third character strings; the first character string is a preset character string, the second character string is a character string of an interception method, and the third character string is a character string of a cancellation interception method.
In some embodiments, the first character may be a character included in a character string of a preset class, and may include, for example, "W", "K", "Browsing", "Context", and "Controller". The second character may be a character included in the character string of the interception method, and may include, for example, "register", "Scheme", "For", "Custom", and "Protocol". The third character may be a character included in a character string of the interception cancellation method, and may include, for example, "unregister", "Scheme", "For", "Custom", and "Protocol". It should be noted that, here, the examples are only schematic examples, and in an actual scenario, the respective orders of the obtained multiple first characters, multiple second characters, or multiple third characters may be random, and are not in the order shown in the examples.
In some embodiments, the obtained plurality of first characters may be sorted according to an order of the first characters in the character string of the preset class. Illustratively, when the first characters "W", "K", "Browsing", "Context" and "Controller" are obtained, the first characters in the character string "W K Browsing Context Controller" of the preset type are sorted and spliced according to the sequence of the first characters, so as to obtain a first character string "W K Browsing Context Controller". It is understood that the manner of obtaining the second string and the third string is similar to the first string, and is not described herein again.
The method comprises the steps that a first character string of a preset class, a second character string of an interception method and a third character string of an interception canceling method are respectively split into a plurality of first characters, a plurality of second characters and a plurality of third characters, when the interception method or the interception canceling method in the preset class is called, the first characters are sequenced and spliced, the corresponding interception method or interception canceling method is called through the complete character string obtained through splicing, and the interception method or interception canceling method in the preset class provided by an operating system can be successfully called.
In some embodiments, the first character, the second character, and the third character may be pre-split and stored in the target storage area. The target storage area may be an area in the terminal, for example, an area in an application of the terminal.
In addition, when the first character, the second character and the third character are stored in the target storage area, in order to avoid the interception limitation caused by other application programs, the first character, the second character and the third character may be stored in a reverse order of the first characters in the character strings in the preset class, for example: the preset character string is 'W K Browsing Context Controller', when stored, the character string can be stored according to the sequence of 'Controller, context, browsing, K and W', when in use, the array is reversed, and then the character string is spliced into the W K Browsing Context Controller after being reversed.
Since the interception method intercepts the network requests of all pages, and the interception cancellation method cancels the interception of the network requests of all pages, the start or stop of the interception of the network requests of the target page can also be related to the network interception state of the target page.
In some embodiments, turning on or off interception of a network request for a target page according to a switch control parameter includes: and starting or closing the interception of the network request of the target page according to the switch control parameter and the network interception state of the target page, wherein the network interception state comprises interception or non-interception, and the interception or non-interception respectively represents that the network request of the target page is intercepted or not intercepted.
In some embodiments, the network intercept state is to reflect that a network request for the target page is currently already intercepted or is not currently intercepted. As described above, the interception method intercepts the network requests of all pages, and the interception cancellation method cancels the interception of the network requests of all pages, so that the interception status of the target page may be related to a page before or after the target page.
In some embodiments, the method further comprises: and in response to starting or closing the interception of the network request of a previous page or a next page of a target page in the application program, determining the network interception state of the target page as interception or non-interception respectively.
For example, taking a target page as a page B, a previous page of the target page as a page a, and a next page of the target page as a page C, if the interception of the network request of the previous page "page a" is started, the network requests of all pages are intercepted at this time, so that the network request state of the page B is intercepted, and similarly, if the interception of the network request of the previous page "page a" is closed, the network requests of all pages are intercepted at this time, so that the network request state of the page B is not intercepted. Similarly, the influence of the subsequent page "page C" on the network interception state of the target page "page B" is the same as that of the previous page, and is not described herein again.
In some embodiments, the network interception status of the target page may be characterized by a variable carried by the target page. Illustratively, the network intercept state of the target page may be characterized by a variable a. In some embodiments, the variable may be a boolean (boolean) variable that includes only 0 or 1, e.g., 0 may characterize no interception and 1 may characterize interception. The network interception state of the target page is judged through the Boolean type variable, and the logic judgment process is simple and efficient.
For example, still taking the target page as the page B as an example, if the page B jumps to the next page "page C", since the page B is not destroyed, that is, the variable of the page B still exists, the network interception state of the page B can be determined by the variable of the page B at this time.
In some embodiments, turning on or off interception of a network request for a target page according to a switch control parameter includes: starting interception of a network request of a target page under the conditions that a switch control parameter is started and a network interception state is not intercepted, and determining the network interception state of the target page as interception at a preset stage of a life cycle of the target page; and under the condition that the switch control parameter is closed and the network interception state is intercepted, the interception of the network request of the target page is closed, and the network interception state of the target page is determined as non-interception at the preset stage of the life cycle of the target page.
Exemplarily, taking a target page as the page B, when a network request control parameter of the page B is on and a network interception state is not intercepted, intercepting the network request of the page B is turned on, and since the interception of turning on the network request is global interception, the network interception state of the page B should be changed from non-interception to interception, and correspondingly, the network interception state of the page B is determined as interception from non-interception at a preset stage of a life cycle of the page B. Similarly, the manner of determining the network state of the target page as non-interception is the same as the manner of determining as interception, and is not described herein again.
In some embodiments, the life cycle of the target page may be generated according to the operation of the user, and the life cycle of the page may be different according to different user operations. The preset stage of the life cycle of the target page can be a View Did apply stage of the target page.
For example, taking a target page as a page B, if the page C returns to the page B during the operation of the current user, a life cycle of the page B may be generated, for example, the life cycle is as follows: c [ View wild Apper ] → B [ View wild Apper ] → C [ View Did Apper ] → B [ View Did Apper ], wherein C [ View wild Apper ] represents a View wild Apper phase in the lifecycle of page C, B [ View wild Apper ] represents a View wild Apper phase in the lifecycle of page B, C [ View Did Apper ] represents a View Did Apper phase in the lifecycle of page C, and B [ View Did Apper ] represents a View Did Apper phase in the lifecycle of page B. The network intercept status of page B may be re-determined at this point in the View Did apply phase of page B. For specific details of the View wild application stage, the View Did application stage, and the View Did application stage, reference may be made to the related art, and details are not repeated herein.
Fig. 2 is a block diagram illustrating a network request control device according to an example embodiment. As shown in fig. 2, the network request control apparatus 200 may include:
an obtaining module 210 configured to obtain a network request of a target page, where the target page is any page in an application;
a first determining module 220, configured to determine, when the target page belongs to a preset type, a switch control parameter of the network request of the target page, where the switch control parameter includes on or off, and the on or off respectively represents that the network request of the target page needs to be intercepted;
a control module 230 configured to turn on or off interception of the network request of the target page according to the switch control parameter in response to the target page being turned on.
In some embodiments, the control module 230 is further configured to:
and starting or closing the interception of the network request of the target page according to the switch control parameter and the network interception state of the target page, wherein the network interception state comprises interception or non-interception, and the interception or the non-interception respectively represents that the network request of the target page is intercepted or not intercepted.
In some embodiments, the apparatus further comprises:
a response module configured to determine the network interception status of the target page as the interception or the non-interception, respectively, in response to turning on or off interception of the network request of a page preceding or succeeding the target page in the application.
In some embodiments, the control module 230 is further configured to:
when the switch control parameter is on and the network interception state is not intercepted, starting interception of the network request of the target page, and determining the network interception state of the target page as interception at a preset stage of the life cycle of the target page;
and when the switch control parameter is closed and the network interception state is interception, closing the interception of the network request of the target page, and determining the network interception state of the target page as non-interception at the preset stage of the life cycle of the target page.
In some embodiments, the control module 230 is further configured to:
and calling an interception method or an interception cancellation method in a preset class provided by an operating system to start or close the interception of the network request of the target page, wherein the interception method is used for starting the interception of the network requests of all pages in the application program, and the interception cancellation method is used for closing the interception of the network requests of all pages.
In some embodiments, the control module 230 is further configured to:
respectively sequencing and splicing the obtained first characters and the second characters to obtain first character strings and second character strings, and calling the interception method in the preset class through the first character strings and the second character strings; or
Respectively sequencing and splicing the obtained first characters and the third characters to obtain first character strings and third character strings, and calling the interception canceling method in the preset class of the operating system through the first character strings and the third character strings;
the first character string is the character string of the preset class, the second character string is the character string of the interception method, and the third character string is the character string of the interception cancellation method.
In some embodiments, the apparatus further comprises:
a searching module configured to search a preset network request set for the network request of the target page, wherein the preset network request set comprises a plurality of network requests belonging to the preset type;
a second determining module configured to determine that the network request of the target webpage belongs to the preset type under the condition that the network request of the target webpage is found in the preset network request set.
It should be noted that the apparatus in the embodiment of the present invention corresponds to the method in the embodiment of the present invention, and other descriptions may refer to the description of the method in the embodiment of the present invention, which is not described herein again.
Referring now to FIG. 3, a block diagram of an electronic device (e.g., terminal device of FIG. 1) 300 suitable for use in implementing embodiments of the present invention is shown. The terminal device in the embodiments of the present invention may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 3 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 3, electronic device 300 may include a processing device (e.g., central processing unit, graphics processor, etc.) 301 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM) 302 or a program loaded from a storage device 308 into a Random Access Memory (RAM) 303. In the RAM 303, various programs and data necessary for the operation of the electronic apparatus 300 are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input/output (I/O) interface 305 is also connected to bus 304.
Generally, the following devices may be connected to the I/O interface 305: input devices 306 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 307 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage devices 308 including, for example, magnetic tape, hard disk, etc.; and a communication device 309. The communication means 309 may allow the electronic device 300 to communicate wirelessly or by wire with other devices to exchange data. While fig. 3 illustrates an electronic device 300 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may be alternatively implemented or provided.
In particular, according to an embodiment of the present invention, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, an embodiment of the invention includes a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication means 309, or installed from the storage means 308, or installed from the ROM 302. The computer program, when executed by the processing device 301, performs the above-described functions defined in the methods of embodiments of the present invention.
It should be noted that the computer readable medium of the present invention mentioned above can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present invention, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some implementations, the clients may communicate using any currently known or future developed network Protocol, such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may be separate and not incorporated into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: acquiring a network request of a target page, wherein the target page is any page in an application program; determining switch control parameters of the network request of the target page under the condition that the target page belongs to a preset type, wherein the switch control parameters comprise opening or closing, and the opening or the closing respectively represents that the network request of the target page needs to be opened or closed to be intercepted; responsive to the target page being turned on, turning on or off interception of the network request of the target page according to the switch control parameter.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. Wherein the name of a module in some cases does not constitute a limitation on the module itself.
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), system on a chip (SOCs), complex Programmable Logic Devices (CPLDs), and the like.
In the context of the present invention, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The foregoing description is only exemplary of the preferred embodiments of the invention and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents is encompassed without departing from the spirit of the disclosure. For example, the above features and the technical features (but not limited to) having similar functions disclosed in the present invention are mutually replaced to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the invention. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims. 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.

Claims (10)

1. A network request control method, the method comprising:
acquiring a network request of a target page, wherein the target page is any page in an application program;
determining switch control parameters of the network request of the target page under the condition that the target page belongs to a preset type, wherein the switch control parameters comprise opening or closing, and the opening or the closing respectively represents that the network request of the target page needs to be opened or closed to be intercepted;
responsive to the target page being turned on, turning on or off interception of the network request of the target page according to the switch control parameter.
2. The method according to claim 1, wherein the turning on or off the interception of the network request to the target page according to the switch control parameter comprises:
and starting or closing the interception of the network request of the target page according to the switch control parameter and the network interception state of the target page, wherein the network interception state comprises interception or non-interception, and the interception or the non-interception respectively represents that the network request of the target page is intercepted or not intercepted.
3. The network request control method of claim 2, further comprising:
responding to starting or closing the interception of the network request of a previous page or a next page of the target page in the application program, and respectively determining the network interception state of the target page as the interception or the non-interception.
4. The method according to claim 2, wherein the turning on or off the interception of the network request to the target page according to the switch control parameter comprises:
when the switch control parameter is on and the network interception state is not intercepted, starting interception of the network request of the target page, and determining the network interception state of the target page as interception at a preset stage of the life cycle of the target page;
and when the switch control parameter is closed and the network interception state is interception, closing the interception of the network request of the target page, and determining the network interception state of the target page as non-interception at the preset stage of the life cycle of the target page.
5. The method according to any one of claims 1 to 4, wherein the turning on or off of the interception of the network request to the target page comprises:
and calling an interception method or an interception cancellation method in a preset class provided by an operating system to start or close the interception of the network request of the target page, wherein the interception method is used for starting the interception of the network requests of all pages in the application program, and the interception cancellation method is used for closing the interception of the network requests of all pages.
6. The method according to claim 3, wherein the invoking of the interception method or the interception cancellation method in the preset class provided by the operating system comprises:
respectively sequencing and splicing the obtained first characters and the second characters to obtain first character strings and second character strings, and calling the interception method in the preset class through the first character strings and the second character strings; or alternatively
Respectively sequencing and splicing the obtained first characters and the third characters to obtain first character strings and third character strings, and calling the interception canceling method in the preset class of the operating system through the first character strings and the third character strings;
the first character string is the character string of the preset class, the second character string is the character string of the interception method, and the third character string is the character string of the interception cancellation method.
7. The method of claim 1, wherein after the network request to obtain the target page, the method further comprises:
searching a network request of the target page in a preset network request set, wherein the preset network request set comprises a plurality of network requests belonging to the preset type;
and determining that the network request of the target webpage belongs to the preset type under the condition that the network request of the target webpage is found in the preset network request set.
8. A network request control apparatus, the apparatus comprising:
the acquisition module is configured to acquire a network request of a target page, wherein the target page is any page in an application program;
a first determining module, configured to determine, when the target page belongs to a preset type, a switch control parameter of the network request of the target page, where the switch control parameter includes an on state or an off state, and the on state or the off state represents that interception of the network request of the target page needs to be turned on or turned off, respectively;
a control module configured to turn on or off interception of the network request of the target page according to the switch control parameter in response to the target page being turned on.
9. A computer-readable medium, characterized in that a computer program is stored thereon which, when being executed by a processing means, carries out the steps of the network request control method of any one of claims 1 to 7.
10. An electronic device, characterized in that the electronic device comprises:
a storage device having a computer program stored thereon;
processing means for executing said computer program in said storage means to implement the steps of the network request control method of any of claims 1-7.
CN202210900155.5A 2022-07-28 2022-07-28 Network request control method, device, medium and electronic equipment Pending CN115242862A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210900155.5A CN115242862A (en) 2022-07-28 2022-07-28 Network request control method, device, medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210900155.5A CN115242862A (en) 2022-07-28 2022-07-28 Network request control method, device, medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN115242862A true CN115242862A (en) 2022-10-25

Family

ID=83677697

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210900155.5A Pending CN115242862A (en) 2022-07-28 2022-07-28 Network request control method, device, medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN115242862A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104111944A (en) * 2013-04-19 2014-10-22 阿里巴巴集团控股有限公司 Page processing method and device and page generating method and device
CN105812476A (en) * 2016-04-05 2016-07-27 深圳市深信服电子科技有限公司 Method and device for accessing rejected website
CN111428163A (en) * 2020-03-20 2020-07-17 吉林亿联银行股份有限公司 Page access method and device
EP3796160A1 (en) * 2019-09-20 2021-03-24 Beijing Xiaomi Mobile Software Co., Ltd. Application page interception method and device
CN112637185A (en) * 2020-12-18 2021-04-09 北京小米移动软件有限公司 Webpage protection method and device and browser
CN113542185A (en) * 2020-04-13 2021-10-22 北京沃东天骏信息技术有限公司 Method and device for preventing page hijacking, electronic equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104111944A (en) * 2013-04-19 2014-10-22 阿里巴巴集团控股有限公司 Page processing method and device and page generating method and device
CN105812476A (en) * 2016-04-05 2016-07-27 深圳市深信服电子科技有限公司 Method and device for accessing rejected website
EP3796160A1 (en) * 2019-09-20 2021-03-24 Beijing Xiaomi Mobile Software Co., Ltd. Application page interception method and device
CN111428163A (en) * 2020-03-20 2020-07-17 吉林亿联银行股份有限公司 Page access method and device
CN113542185A (en) * 2020-04-13 2021-10-22 北京沃东天骏信息技术有限公司 Method and device for preventing page hijacking, electronic equipment and storage medium
CN112637185A (en) * 2020-12-18 2021-04-09 北京小米移动软件有限公司 Webpage protection method and device and browser

Similar Documents

Publication Publication Date Title
CN111581563A (en) Page response method and device, storage medium and electronic equipment
CN111400625B (en) Page processing method and device, electronic equipment and computer readable storage medium
US20210200806A1 (en) Method and apparatus for parallel processing of information
CN112214408A (en) Dependency conflict detection method and device, electronic equipment and computer readable medium
CN111309304B (en) Method, device, medium and electronic equipment for generating IDL file
CN110960855A (en) Communication protocol code updating method and device, electronic equipment and storage medium
CN114595065A (en) Data acquisition method and device, storage medium and electronic equipment
CN111400068B (en) Interface control method and device, readable medium and electronic equipment
CN111338666A (en) Method, device, medium and electronic equipment for realizing application program upgrading
CN112416303B (en) Software development kit hot repair method and device and electronic equipment
CN111506904B (en) Method and device for online bug repair
CN115242862A (en) Network request control method, device, medium and electronic equipment
CN111459893B (en) File processing method and device and electronic equipment
CN114741686A (en) Method and device for detecting program white list and related equipment
CN114428925A (en) Page rendering method and device, electronic equipment and computer readable medium
CN113138883A (en) Message processing method and device, storage medium and electronic equipment
CN111309323A (en) Parameter initialization method and device and electronic equipment
CN112835671A (en) Application page scene switching method, device and equipment
CN111562913B (en) Method, device and equipment for pre-creating view component and computer readable medium
CN111797009A (en) Method and device for detecting code compatibility and electronic equipment
CN112486826B (en) Test method, test device, electronic equipment and computer readable medium
CN111367555B (en) Assertion method, assertion device, electronic equipment and computer readable medium
CN114398098B (en) Application script execution method, device, electronic equipment and computer readable medium
CN111209042B (en) Method, device, medium and electronic equipment for establishing function stack
CN111310483B (en) Translation method, translation device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20230728

Address after: 224008 Rooms 404-405 and 504, Building B-17-1, Big data Industrial Park, Kecheng Street, Yannan High tech Zone, Yancheng, Jiangsu Province

Applicant after: Yancheng Tianyanchawei Technology Co.,Ltd.

Address before: 224008 room 501-503, building b-17-1, Xuehai road big data Industrial Park, Kecheng street, Yannan high tech Zone, Yancheng City, Jiangsu Province (CNK)

Applicant before: Yancheng Jindi Technology Co.,Ltd.