CN114301892B - Method, device and system for simulating Web application to realize example function - Google Patents

Method, device and system for simulating Web application to realize example function Download PDF

Info

Publication number
CN114301892B
CN114301892B CN202111631142.4A CN202111631142A CN114301892B CN 114301892 B CN114301892 B CN 114301892B CN 202111631142 A CN202111631142 A CN 202111631142A CN 114301892 B CN114301892 B CN 114301892B
Authority
CN
China
Prior art keywords
request
login
web
receiving
setting
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111631142.4A
Other languages
Chinese (zh)
Other versions
CN114301892A (en
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.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent 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 Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202111631142.4A priority Critical patent/CN114301892B/en
Publication of CN114301892A publication Critical patent/CN114301892A/en
Application granted granted Critical
Publication of CN114301892B publication Critical patent/CN114301892B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application belongs to the technical field of Web application display, and particularly provides a method, a device and a system for simulating a Web application to realize an example function, wherein the method comprises the following steps: receiving a request and forwarding the request to an address of a Web service needing to realize an example, intercepting resources of a Web service response and caching the resources to a local service; setting identity information to simulate the login of Web; reading access of cache simulation Web of local service; and after the access is completed, setting the identification information to simulate the logout of the Web to realize the access of the whole application example. The application can realize the caching of resources and data directly through the local forwarding interception without modifying Web engineering; the login and logout simulation is realized by setting the identity information, and the access of the whole application example is realized for any Web application by accessing the local cache.

Description

Method, device and system for simulating Web application to realize example function
Technical Field
The application relates to the technical field of Web application display, in particular to a method, a device and a system for simulating a Web application to realize an example function.
Background
When the product is initially oriented to the customer, the Demo can quickly and accurately display the product function to the customer. Example production has been an important part of the project. Example productions are closely related to the implementation technology of the project. At the end of the project, the project is typically manufactured as Demo for display to the outside. A good Demo should be able to have the same functionality as the source program.
There are many ways of making Demo for the current Web application, but most of them need to be modified for the current Web application itself, but if the Web application is upgraded or a new Web application is newly developed, it is still necessary to modify again to generate Demo, which is very troublesome. There is provided a method by which example functions can be implemented directly for any Web application without modification of the Web engineering.
Disclosure of Invention
The method, the device and the system for simulating the Web application to realize the example function are provided.
The technical scheme of the application is as follows:
in a first aspect, the present application provides a method for simulating a Web application to implement an example function, including the following steps:
receiving a request and forwarding the request to an address of a Web service needing to realize an example, intercepting resources of a Web service response and caching the resources to a local service;
setting identity information to simulate the login of Web;
reading access of cache simulation Web of local service;
and after the access is completed, setting the identification information to simulate the logout of the Web to realize the whole application example.
According to the application, the request is forwarded to the address of the Web service to be exemplified, after the Web service receives the request, response information is returned, and the returned response information is intercepted and cached in the local service; wherein the response information includes corresponding resources and data; the method comprises the steps of setting an identification mark to simulate Web login, receiving an access request of a browser, reading a resource or data return value browser of a local service cache, setting identification mark information to simulate Web login, and displaying the application process of the Web in the whole process.
Preferably, the steps of receiving the request and forwarding the request to an address where the example Web service is to be implemented, intercepting the resources of the Web service response and caching to the local service include:
receiving an access request;
judging whether the local service has the requested resource or not;
if yes, executing the steps: simulating Web login by setting identity information;
if not, forwarding the request to an address where the example Web service needs to be implemented;
intercepting response resources of Web services and judging and checking the response resource types;
and creating a corresponding file in the local service according to the verification result, and writing the response resource into the corresponding file.
And the responsive information is classified and stored according to the request type of the browser, so that when the later access is convenient, the data of the corresponding position can be read according to the request type and sent back to the browser.
Preferably, the step of creating a corresponding file at the local service according to the verification result and writing the response resource into the corresponding file includes:
if the response resource is a static resource, creating a static resource folder in the local service;
sequentially creating file directories of corresponding path names downwards under a static resource folder according to the complete request path of the current request, and creating a static resource file in the lowest layer directory;
the content of the response resource is written to the static resource file.
Preferably, the step of creating a corresponding file at the local service according to the verification result and writing the response resource into the corresponding file includes:
if the response resource is interface data, creating an interface data folder in the local service;
if the request type is the first request type, creating a request type file directory under the interface data folder;
sequentially creating file directories with corresponding path names downwards under the request type file directory according to the complete request path of the current request, and creating interface data files in the lowest layer directory;
and writing the responsive interface data into an interface data file.
And creating corresponding file village related data according to the request type and the set path, so that subsequent searching and reading are facilitated.
Preferably, the step of setting the identification information to simulate the login of the Web includes:
receiving a request and acquiring a login field in the request identity information;
if no login field or the login field value is false, redirecting the current request to the login page;
inputting an account password for login on a login page, setting the value of a login field in identity identification information as true after receiving a request, and redirecting the current request to a home page;
and if the login field exists and the value of the login field is true, redirecting the current request to the home page.
And setting the value of a login field in the identity information to redirect the position of the current request, so as to simulate the login of Web.
Preferably, the step of reading access of the cached analog Web of the local service enables access of the entire application instance, comprising:
receiving a request and judging the type of the request;
if the request type is static resources, reading static resource files cached by the local service and returning the static resource files to the browser;
and if the request type is interface data, reading the interface data file cached by the local service and returning to the browser.
Preferably, the step of setting the identification information to simulate the logout of the Web comprises:
after receiving the log-out request, clearing a login field in the identity information, and redirecting the current request to a login page. And setting the value of a login field in the identity information to redirect the position of the current request, so as to simulate the logout of the Web.
In a second aspect, the present application provides a device for simulating a Web application to implement an example function, including a cache module, a login-simulating module, a cache reading module, and a login-simulating module;
the caching module is used for receiving a request, forwarding the request to an address of the Web service to be implemented as an example, intercepting resources of the Web service response and caching the resources to the local service;
the imitation login module is used for setting the login of the identity information imitation Web;
the cache reading module is used for reading access of cache simulation Web of local service;
and the imitation logout module is used for setting the logout of the identity information simulation Web so as to realize the access of the whole application example.
Preferably, the cache module comprises a first receiving unit, a cache judging unit, a request forwarding unit, a response resource checking unit and a cache unit;
a first receiving unit configured to receive an access request;
the cache judging unit is used for judging whether the local service has the requested resource or not;
a request forwarding unit, configured to forward a request to an address where an example Web service needs to be implemented;
the response resource verification unit is used for intercepting response resources of the Web service and judging and verifying the types of the response resources;
and the cache unit is used for creating a corresponding file at the local service according to the verification result and writing the response resource into the corresponding file.
Preferably, the cache unit comprises a creation sub-module and a writing sub-module;
the creation sub-module is used for creating a static resource folder in the local service when the response resource checking unit judges that the response resource is a static resource; sequentially creating file directories of corresponding path names downwards under a static resource folder according to the complete request path of the current request, and creating a static resource file in the lowest layer directory; when the response resource checking unit judges that the response resource is interface data, creating an interface data folder in the local service; creating a request type file directory under the interface data folder according to the request type; sequentially creating file directories with corresponding path names downwards under the request type file directory according to the complete request path of the current request, and creating interface data files in the lowest layer directory;
and the writing sub-module is used for writing the content of the response resource into the static resource file and writing the response interface data into the interface data file.
Preferably, the login-imitation module comprises an acquisition unit, a request redirection unit and a setting unit;
the acquisition unit is used for receiving the request and acquiring a login field in the request identity information;
the request redirection unit is used for redirecting the current request to the login page when the acquisition unit outputs no login field or the login field value is false; and when the acquisition unit outputs a login field and the value of the login field is true, redirecting the current request to the home page.
The setting unit is used for inputting an account number and a password to log in through a login page, and setting the value of a login field in the identity identification information as true after receiving a request; after the setting is completed, the request redirection unit redirects the current request to the home page.
Preferably, the log-out simulating module is specifically configured to clear a login field in the identity information after receiving the log-out request, and redirect the current request to a login page.
Preferably, the cache reading module is specifically configured to receive a request and determine a request type; if the request type is static resources, reading static resource files cached by the local service and returning the static resource files to the browser; and if the request type is interface data, reading the interface data file cached by the local service and returning to the browser.
In a third aspect, the present application further provides a system for simulating a Web application to implement an example function, including a Web terminal and a local server in communication with the Web terminal;
the local server is used for receiving the request of the browser and forwarding the request to the Web terminal needing to realize the example; the method is also used for intercepting response resources of the Web terminal, judging and checking the response resource types and caching the response resources to the local according to the checking result; the method is also used for receiving the request of the browser and simulating the login of Web by setting the identity information; the method is also used for reading local access of the cache simulation Web after receiving the request of the browser, and is also used for receiving the request of the browser and simulating the logout of the Web by setting the identity information so as to realize the access of the whole application example;
and the Web terminal responds to the request and returns a response resource.
Preferably, the local server is configured with a first port and a second port; the local server also comprises a cache setting module, a redirection login module, an access module and a redirection logout module;
the first port is used for receiving a request of the browser and forwarding the request to the Web terminal needing to realize the example; the system is also used for intercepting and receiving response resources;
the cache setting module is used for judging and checking the response resource category received by the first port and caching the response resource to the local according to the checking result;
a second port, configured to receive a request from a browser; the request includes a login request, a logout request and a read request;
the redirection login module is used for acquiring a login field in the request identity identification information when the second port receives a login request; if no login field or the login field has a false value, redirecting the current request to a login page, inputting an account password to login on the login page, and setting the login field in the identity information to have a true value after receiving the login request; after the setting is completed, redirecting the current request to the home page; if the login field exists and the value of the login field is true, redirecting the current request to the home page;
the access module is used for judging the request type when the second port receives the reading request; if the request type is static resources, reading a locally cached static resource file and returning to the browser; if the request type is interface data, reading a locally cached interface data file and returning to the browser;
and the redirection logout module is used for clearing a login field in the identity identification information when the second port receives the logout request, and redirecting the current request to the login page.
From the above technical scheme, the application has the following advantages: the application can realize the caching of resources and data directly through the local forwarding interception without modifying Web engineering; the login and logout simulation is realized by setting the identity information, and the access of the whole application example is realized for any Web application by accessing the local cache.
In addition, the application has reliable design principle, simple structure and very wide application prospect.
It can be seen that the present application has outstanding substantial features and significant advances over the prior art, as well as its practical advantages.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the description of the embodiments or the prior art will be briefly described below, and it will be obvious to those skilled in the art that other drawings can be obtained from these drawings without inventive effort.
FIG. 1 is a schematic flow chart of a method of one embodiment of the application.
FIG. 2 is a schematic flow diagram of resource caching of a method of one embodiment of the application.
FIG. 3 is a schematic flow chart of simulated login for a method of one embodiment of the application.
FIG. 4 is a schematic flow chart of a simulated logout of a method of one embodiment of the application.
FIG. 5 is a schematic flow chart diagram of a read cache of a method of one embodiment of the present application.
Fig. 6 is a schematic block diagram of an apparatus of one embodiment of the present application.
Detailed Description
In order to make the technical solution of the present application better understood by those skilled in the art, the technical solution of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present application without making any inventive effort, shall fall within the scope of the present application.
As shown in fig. 1, an embodiment of the present application provides a method for simulating a Web application to implement an example function, including the following steps:
step 1: receiving a request and forwarding the request to an address of a Web service needing to realize an example, intercepting resources of a Web service response and caching the resources to a local service;
step 2: setting identity information to simulate the login of Web;
step 3: reading access of cache simulation Web of local service;
step 4: and after the access is completed, setting the identification information to simulate the logout of the Web to realize the access of the whole application example.
In some embodiments, in step 1, the steps of receiving a request and forwarding the request to an address where an example Web service needs to be implemented, intercepting a resource of a Web service response, and caching the resource to a local service include:
step 11: receiving an access request;
step 12: judging whether the local service has the requested resource or not;
if yes, executing the step 2; if not, executing the step 13;
step 13: forwarding the request to an address where the example Web service needs to be implemented;
step 14: receiving response resources of the Web service and judging and checking the response resource types;
step 15: and creating a corresponding file in the local service according to the verification result, and writing the response resource into the corresponding file.
It should be noted that, the application creates a project with functions of forwarding request, intercepting response, buffering response, reading buffering, etc.; suppose that the addresses of the web services that need to be exemplified are: lovecloud.com; as shown in fig. 2, a local service is started, and a service port is configured (e.g., 8080); the browser accesses localhost 8080; the local service forwards the request to the address lovecloud.com that needs to generate the example web service; the local service intercepts the response of the web service, reads response information, distinguishes response resource types according to the content-type in the header, and caches the resources.
Specifically, in step 15, the steps of creating a corresponding file in the local service according to the verification result, and writing the response resource into the corresponding file include:
if the response resource is a static resource (e.g., html, js, css, jpg, png, etc.), step 151 is performed;
step 151: creating a static resource folder, namely a static folder, at a local service;
step 152: sequentially creating file directories of corresponding path names downwards under a static resource folder according to the complete request path of the current request, and creating a static resource file in the lowest layer directory; if the complete request path of the current request is/lovecond/js/hello.js, sequentially creating a lovecond and js file directory downwards under the static folder, and creating hello.js files in the lowermost directory js;
step 153: writing the content of the response resource into a static resource file; that is, the content of the response resource is directly written to the hello.js file.
If the response resource is interface data, executing step 154;
step 154: creating an interface data folder, namely a mockData folder, at the local service;
step 155: if the request type is the first request type, creating a request type file directory under the interface data folder;
step 156: sequentially creating file directories with corresponding path names downwards under the request type file directory according to the complete request path of the current request, and creating interface data files in the lowest layer directory;
it should be noted that, if the current complete request path of the request is/api/locked/getusername=zhangsan, and the request type is get request, then a get, api, lovecloud, getUsers file directory is created downward in sequence under the mockData folder, and a data.json file is created in the lowest-layer directory getUsers;
at this time, the folder name under mockData is the interface request type (get, post, delete, put, etc.);
step 157: and writing the responsive interface data into an interface data file.
Assuming the interface data of the response is [ { name: 'zhangsan', age: '30' } ], then it will be
{
“name=zhangsan”:[{name:’zhangsan’,age:’30’}]
}
Writing into a data.json file.
There is again a request for the same url, but the participation is different, if/api/loved/getusername=lisi, then the response data of this request is added in the above data. Json file as follows:
{
“name=zhangsan”:[{name:’zhangsan’,age:’30’}],
“name=lisi”:[{name:’lisi’,age:’40’}]
}。
in some embodiments, the step of setting the identification information to simulate the login of the Web in step 2 includes:
step 21: receiving a request and acquiring a login field in the request identity information;
step 22: if no login field or the login field value is false, redirecting the current request to the login page;
step 23: inputting an account password for login on a login page, setting the value of a login field in identity identification information as true after receiving a request, and redirecting the current request to a home page;
step 24: and if the login field exists and the value of the login field is true, redirecting the current request to the home page.
It should be noted that, the first request of the login page, such as/log/html;
a login request, such as/log-out/log;
after logging in, the homepage requests the first, such as/loved/index. The homepage can also be a home page;
log out requests, such as/locked/logo;
another web service is started locally, and a service port 8081 is configured; as shown in FIG. 3, the browser accesses the localhost 8081, the local service 8081 receives the request, obtains the logical field in the request cookie, and redirects the request to the login page/logical. Html if the logical does not exist or the logical is false; the user inputs an account number and a password on a login page, clicks the login, the local service receives a login request (/ locked/login), sets a cookie field locked as true, and redirects the current request to a home page/locked/index.
In some embodiments, in step 3, the step of reading access of the cached analog Web of the local service to enable access of the entire application instance includes:
step 31: receiving a request and judging the type of the request;
step 32: if the request type is static resources, reading static resource files cached by the local service and returning the static resource files to the browser;
step 33: and if the request type is interface data, reading the interface data file cached by the local service and returning to the browser.
As shown in FIG. 5, the browser accesses the local service localhost 8081, the local service receives the request, and reads the resource from the corresponding file path according to the request type and url
If the request type is static resource/lovencloud/js/hello.js, reading static resource file static/lovencloud/js/hello.js content of the local cache, and responding and returning to the browser;
if the request type is interface data/api/lovencloud/getusersname=zhangsan, reading the contents of the interface data file mockData/api/lovencloud/getUsers/data. Json, objectifying the contents json, reading the value of the key as 'name=zhangsan', and returning to the browser in response. Other requests are similar and will not be described in detail herein.
In some embodiments, in step 4, the step of setting the identification information to simulate the logout of the Web includes:
after receiving the log-out request, clearing a login field in the identity information, and redirecting the current request to a login page. The user clicks to log out and sends a request to the local service, as shown in fig. 4, the local service 8081 receives the log-out request/log-out sent by the browser, clears the log-in field in the cookie, and redirects the current request to the login page/log-out/log-in. It should be noted that, the cookie is identification information, and the logged field is a login field.
As shown in fig. 6, an embodiment of the present application provides a device for simulating a Web application to implement an example function, including a cache module, a login-simulating module, a cache reading module, and a login-simulating module;
the caching module is used for receiving a request, intercepting and forwarding the request to an address of the Web service needing to be implemented with the example, and caching resources responded by the Web service to the local;
the imitation login module is used for setting the login of the identity information imitation Web;
the cache reading module is used for reading local access of the cache simulation Web;
and the imitation logout module is used for setting the logout of the identity information simulation Web so as to realize the access of the whole application example.
In some embodiments, the buffer module includes a first receiving unit, a buffer judging unit, a request intercepting and forwarding unit, a response resource checking unit, and a buffer unit;
a first receiving unit configured to receive an access request;
the cache judging unit is used for judging whether the requested resource exists locally or not;
a request interception forwarding unit, configured to forward a request to an address where an example Web service needs to be implemented;
the response resource verification unit is used for receiving the response resource of the Web service and judging and verifying the response resource category;
and the cache unit is used for locally creating a corresponding file according to the verification result and writing the response resource into the corresponding file.
In some embodiments, the cache unit includes a creation sub-module, a write sub-module;
the creation sub-module is used for locally creating a static resource folder when the response resource checking unit judges that the response resource is a static resource; sequentially creating file directories of corresponding path names downwards under a static resource folder according to the complete request path of the current request, and creating a static resource file in the lowest layer directory; when the response resource checking unit judges that the response resource is interface data, an interface data folder is created locally; creating a request type file directory under the interface data folder according to the request type; sequentially creating file directories with corresponding path names downwards under the request type file directory according to the complete request path of the current request, and creating interface data files in the lowest layer directory;
and the writing sub-module is used for writing the content of the response resource into the static resource file and writing the response interface data into the interface data file.
In some embodiments of the present application, in some embodiments, the login-simulating module comprises an acquisition unit, a request redirection unit, a setting unit,
The acquisition unit is used for receiving the request and acquiring a login field in the request identity information;
the request redirection unit is used for redirecting the current request to the login page when the acquisition unit outputs no login field or the login field value is false; and when the acquisition unit outputs a login field and the value of the login field is true, redirecting the current request to the home page.
The setting unit is used for inputting an account number and a password to log in through a login page, and setting the value of a login field in the identity identification information as true after receiving a request; after the setting is completed, the request redirection unit redirects the current request to the home page.
In some embodiments, the log-out simulating module is specifically configured to clear a login field in the identity information after receiving the log-out request, and redirect the current request to a login page.
In some embodiments, the cache reading module is specifically configured to receive a request and determine a request type; if the request type is static resources, reading a locally cached static resource file and returning to the browser; and if the request type is interface data, reading the locally cached interface data file and returning to the browser.
The embodiment of the application also provides a system for simulating the Web application to realize the example function, which comprises a Web terminal and a local server communicated with the Web terminal;
the local server is used for receiving the request of the browser and intercepting and forwarding the request to the Web terminal needing to realize the example; the method is also used for judging and checking the response resource category and caching the response resource to the local according to the checking result; the method is also used for receiving the request of the browser and simulating the login of Web by setting the identity information; the method is also used for reading local access of the cache simulation Web after receiving the request of the browser, and is also used for receiving the request of the browser and simulating the logout of the Web by setting the identity information so as to realize the access of the whole application example;
and the Web terminal responds to the request and returns the response resource to the local server.
In some embodiments, the local server is configured with a first port and a second port; the local server also comprises a cache setting module, a redirection login module, an access module and a redirection logout module;
the first port is used for receiving a request of the browser and intercepting and forwarding the request to the Web terminal needing to realize the example; and is also configured to receive a response resource;
the cache setting module is used for judging and checking the response resource category received by the first port and caching the response resource to the local according to the checking result;
a second port, configured to receive a request from a browser; the request includes a login request, a logout request and a read request;
the redirection login module is used for acquiring a login field in the request identity identification information when the second port receives a login request; if no login field or the login field has a false value, redirecting the current request to a login page, inputting an account password to login on the login page, and setting the login field in the identity information to have a true value after receiving the login request; after the setting is completed, redirecting the current request to the home page; if the login field exists and the value of the login field is true, redirecting the current request to the home page;
the access module is used for judging the request type when the second port receives the reading request; if the request type is static resources, reading a locally cached static resource file and returning to the browser; if the request type is interface data, reading a locally cached interface data file and returning to the browser;
and the redirection logout module is used for clearing a login field in the identity identification information when the second port receives the logout request, and redirecting the current request to the login page.
The local server initiates the web service, configuring the first port 8080; the addresses of the Web services to be exemplified are set as follows: lovecloud.com;
the browser accesses localhost 8080, the first port receives the request, forwards the request to the address localroud.com of the Web service, the first port intercepts the returned resource to the local server, and the local server judges and checks the content-type in the response resource category (leader);
if the response resource is a static resource such as html, js, css, jpg, png, the local server creates a static folder, if the current complete request path of the request is/loved/js/hello.js, sequentially creating a loved file directory and a js file directory downwards under the static folder, creating hello.js files in the lowermost directory js, and directly writing the content of the response resource into the hello.js files; and the other types of resource caching modes are basically the same, and if the current resource is cached, the caching process is skipped.
If the response resource is interface data, the local server creates a mockData folder, and if the complete request path of the current request is/api/loved/getUsername=zhangsan and the request type is get request, a get, api, lovecloud, getUsers file directory is created downwards in sequence under the mockData folder, and a data.json file is created in the lowest-layer directory getUsers.
Note that: the folder name under mockData is the interface request type (get, post, delete, put, etc.).
Assuming the interface data of the response is [ { name: 'zhangsan', age: '30' } ], then it will be
{
“name=zhangsan”:[{name:’zhangsan’,age:’30’}]
Writing into a data.json file. There is again a request for the same url, but the participation is different, if/api/loved/getusername=lisi, then the response data of this request is added in the above data. Json file as follows:
{
“name=zhangsan”:[{name:’zhangsan’,age:’30’}],
“name=lisi”:[{name:’lisi’,age:’40’}]
}。
the caching modes of other requested interface data are basically the same, and if the data of the same request are cached, the caching process is skipped.
The local server starts another web service, a second port 8081 is configured, the browser accesses a localhost 8081, the local server receives a request, acquires a logic field in a request cookie, redirects the request to a login page if the logic does not exist or the logic is false, inputs an account number and a password in the login page by a user, clicks the login, the local server receives the login request, sets the logic of the cookie field as true, and redirects the current request to a first page. The user clicks out to send a request to the local service, the local service receives the logout request, clears the cookie field log, and redirects the current request to the login page.
The browser accesses localhost 8081, and after receiving the request, the local server reads the resource in the corresponding file path according to the request type and url:
if the request is a static resource, reading the content of a static resource file, and responding and returning to the browser;
if the request is interface data, reading the content of the interface data file, objectifying the content json, reading the value of the key, and returning the response to the browser.
Although the present application has been described in detail by way of preferred embodiments with reference to the accompanying drawings, the present application is not limited thereto. Various equivalent modifications and substitutions may be made in the embodiments of the present application by those skilled in the art without departing from the spirit and scope of the present application, and it is intended that all such modifications and substitutions be within the scope of the present application/be within the scope of the present application as defined by the appended claims. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (5)

1. A method for simulating a Web application to implement an example function, comprising the steps of:
receiving a request and forwarding the request to an address where an example Web service needs to be implemented; intercepting the resources responded by the Web service and caching the resources to the local service;
setting identity information to simulate the login of Web;
reading access of cache simulation Web of local service;
after the access is completed, setting identification information to simulate the logout of Web;
the steps of receiving and forwarding the request to an address where the example Web service is to be implemented, and intercepting the resources of the Web service response and caching to the local service include:
receiving an access request;
judging whether the local service has the requested resource or not;
if yes, executing the steps: simulating Web login by setting identity information;
if not, forwarding the request to an address where the example Web service needs to be implemented;
intercepting response resources of Web services and judging and checking the response resource types;
creating a corresponding file in the local service according to the verification result, and writing the response resource into the corresponding file;
the step of setting the identity information to simulate the login of the Web comprises the following steps:
receiving a request and acquiring a login field in the request identity information;
if no login field or the login field value is false, redirecting the current request to the login page;
inputting an account password for login on a login page, setting the value of a login field in identity identification information as true after receiving a request, and redirecting the current request to a home page;
if the login field exists and the value of the login field is true, redirecting the current request to the home page;
the step of reading access of the cache simulation Web of the local service to realize access of the whole application example comprises the following steps:
receiving a request and judging the type of the request;
if the request type is static resources, reading static resource files cached by the local service and returning the static resource files to the browser;
if the request type is interface data, reading an interface data file cached by the local service and returning to the browser;
the step of setting the identity information to simulate the logout of the Web comprises the following steps:
after receiving the log-out request, clearing a login field in the identity information, and redirecting the current request to a login page.
2. The method for implementing an example function for a simulated Web application of claim 1, wherein creating a corresponding file at a local service based on the verification result and writing the response resource to the corresponding file comprises:
if the response resource is a static resource, creating a static resource folder in the local service;
sequentially creating file directories of corresponding path names downwards under a static resource folder according to the complete request path of the current request, and creating a static resource file in the lowest layer directory;
the content of the response resource is written to the static resource file.
3. The method for implementing an example function for a simulated Web application of claim 2, wherein the steps of creating a corresponding file at the local service based on the verification result and writing the response resource to the corresponding file comprise:
if the response resource is interface data, creating an interface data folder in the local service;
if the request type is the first request type, creating a request type file directory under the interface data folder;
sequentially creating file directories with corresponding path names downwards under the request type file directory according to the complete request path of the current request, and creating interface data files in the lowest layer directory;
and writing the responsive interface data into an interface data file.
4. The device for simulating the Web application to realize the example function is characterized by comprising a cache module, a login simulating module, a cache reading module and a login simulating module;
the caching module is used for receiving a request, forwarding the request to an address of the Web service to be implemented as an example, intercepting resources of the Web service response and caching the resources to the local service;
the imitation login module is used for setting the login of the identity information imitation Web;
the cache reading module is used for reading access of cache simulation Web of local service; the method is particularly used for receiving the request and judging the type of the request; if the request type is static resources, reading static resource files cached by the local service and returning the static resource files to the browser; if the request type is interface data, reading an interface data file cached by the local service and returning to the browser;
the imitation logout module is used for setting identification information to simulate the logout of Web so as to realize the access of the whole application example; the method is particularly used for clearing a login field in the identity information after receiving the login request, and redirecting the current request to a login page;
the cache module comprises a first receiving unit, a cache judging unit, a request forwarding unit, a response resource checking unit and a cache unit;
a first receiving unit configured to receive an access request;
the cache judging unit is used for judging whether the local service has the requested resource or not;
a request forwarding unit, configured to forward a request to an address where an example Web service needs to be implemented;
the response resource verification unit is used for intercepting response resources of the Web service and judging and verifying the types of the response resources;
the cache unit is used for creating a corresponding file at the local service according to the verification result and writing the response resource into the corresponding file;
the login-simulating module comprises an acquisition unit, a request redirection unit and a setting unit;
the acquisition unit is used for receiving the request and acquiring a login field in the request identity information;
the request redirection unit is used for redirecting the current request to the login page when the acquisition unit outputs no login field or the login field value is false; when the acquisition unit outputs a login field and the value of the login field is true, redirecting the current request to the home page;
the setting unit is used for inputting an account number and a password to log in through a login page, and setting the value of a login field in the identity identification information as true after receiving a request; after the setting is completed, the request redirection unit redirects the current request to the home page.
5. A system for simulating a Web application to implement an example function, comprising a Web terminal and a local server in communication with the Web terminal;
the local server is used for receiving the request of the browser and forwarding the request to the Web terminal needing to realize the example; the method is also used for intercepting response resources of the Web terminal, judging and checking the response resource types and caching the response resources to the local according to the checking result; the method is also used for receiving the request of the browser and simulating the login of Web by setting the identity information; the method is also used for reading local access of the cache simulation Web after receiving the request of the browser, and is also used for receiving the request of the browser and simulating the logout of the Web by setting the identity information so as to realize the access of the whole application example;
the Web terminal responds to the request and returns response resources;
the local server is configured with a first port and a second port; the local server also comprises a cache setting module, a redirection login module, an access module and a redirection logout module;
the first port is used for receiving a request of the browser and forwarding the request to the Web terminal needing to realize the example; the system is also used for intercepting and receiving response resources;
the cache setting module is used for judging and checking the response resource category received by the first port and caching the response resource to the local according to the checking result;
a second port, configured to receive a request from a browser; the request includes a login request, a logout request and a read request;
the redirection login module is used for acquiring a login field in the request identity identification information when the second port receives a login request; if no login field or the login field has a false value, redirecting the current request to a login page, inputting an account password to login on the login page, and setting the login field in the identity information to have a true value after receiving the login request; after the setting is completed, redirecting the current request to the home page; if the login field exists and the value of the login field is true, redirecting the current request to the home page;
the access module is used for judging the request type when the second port receives the reading request; if the request type is static resources, reading a locally cached static resource file and returning to the browser; if the request type is interface data, reading a locally cached interface data file and returning to the browser;
and the redirection logout module is used for clearing a login field in the identity identification information when the second port receives the logout request, and redirecting the current request to the login page.
CN202111631142.4A 2021-12-28 2021-12-28 Method, device and system for simulating Web application to realize example function Active CN114301892B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111631142.4A CN114301892B (en) 2021-12-28 2021-12-28 Method, device and system for simulating Web application to realize example function

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111631142.4A CN114301892B (en) 2021-12-28 2021-12-28 Method, device and system for simulating Web application to realize example function

Publications (2)

Publication Number Publication Date
CN114301892A CN114301892A (en) 2022-04-08
CN114301892B true CN114301892B (en) 2023-08-15

Family

ID=80971184

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111631142.4A Active CN114301892B (en) 2021-12-28 2021-12-28 Method, device and system for simulating Web application to realize example function

Country Status (1)

Country Link
CN (1) CN114301892B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109587133A (en) * 2018-11-30 2019-04-05 武汉烽火众智智慧之星科技有限公司 A kind of single-node login system and method
CN110442524A (en) * 2019-08-09 2019-11-12 中国建设银行股份有限公司 It is a kind of for have Certificate Authority web service interface test method and device
CN113626063A (en) * 2021-07-24 2021-11-09 济南浪潮数据技术有限公司 Method, device and equipment for accessing static Demo and readable medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109587133A (en) * 2018-11-30 2019-04-05 武汉烽火众智智慧之星科技有限公司 A kind of single-node login system and method
CN110442524A (en) * 2019-08-09 2019-11-12 中国建设银行股份有限公司 It is a kind of for have Certificate Authority web service interface test method and device
CN113626063A (en) * 2021-07-24 2021-11-09 济南浪潮数据技术有限公司 Method, device and equipment for accessing static Demo and readable medium

Also Published As

Publication number Publication date
CN114301892A (en) 2022-04-08

Similar Documents

Publication Publication Date Title
JP5443513B2 (en) Method and system for handling cookies across domains
US8131799B2 (en) User-transparent system for uniquely identifying network-distributed devices without explicitly provided device or user identifying information
US7509397B1 (en) Web portholes: using web proxies to capture and enhance display real estate
US6954783B1 (en) System and method of mediating a web page
US20100082747A1 (en) Real-time collaborative browsing
US9684628B2 (en) Mechanism for inserting trustworthy parameters into AJAX via server-side proxy
JP4358188B2 (en) Invalid click detection device in Internet search engine
US20130232234A1 (en) Dynamically rehosting web content
US7987243B2 (en) Method for media discovery
WO2008111048A2 (en) System and method for browser within a web site and proxy server
CN106294379A (en) The loading method of a kind of page, device and system
CN111563216B (en) Local data caching method and device and related equipment
CN103152367A (en) Cache dynamic maintenance updating method and system
US11637863B2 (en) Detection of user interface imitation
JP5709448B2 (en) Access analysis device, access analysis method, and access analysis program
KR100748770B1 (en) A system and method of mediating a web page
JPWO2007088785A1 (en) Personal information leakage prevention device and method
US20080033918A1 (en) Systems, methods and computer program products for supplemental data communication and utilization
CN114301892B (en) Method, device and system for simulating Web application to realize example function
KR101498920B1 (en) Web page pre-caching system and method for offline-executing
KR100363183B1 (en) Media that can record computer programs for direct forwarding service
CN106888248B (en) For obtaining the method and apparatus of user access activity information
CN114996621B (en) Method, system and storage medium for user to self-select portal home page
KR100983480B1 (en) Method, apparatus and computer-readable recording medium for collecting and providing blog document
CN116339855A (en) Page display method, page display device, computer equipment and readable 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
GR01 Patent grant
GR01 Patent grant