Background
In the information-oriented society of today, networks are becoming an indispensable part of people's lives and works. When browsing a web page, a person typically establishes a communication connection with a server through a browser (or an application having a browser kernel), so that the browser can send a request for obtaining the web page to the server, and after obtaining the web page returned by the server, display the web page.
Since the web page is composed of a set of codes (e.g., composed of html5 codes), and the code of the web page pointing to various resource files (e.g., JavaScript program source files, style files of web pages, etc.) is also composed of respective codes, but the codes are manually written, so that defects or flaws may exist in any codes. Thus, before a server provides a web page to a network (i.e., before a web page is brought online), each code in the web page is typically tested in an offline environment, i.e., offline.
However, during the offline test, the server can only use the simulated online data to test the web page, which makes the result of the offline test not necessarily accurate, that is, the web page without problems is determined through the offline test, and problems may occur after the web page is online. At this time, the worker needs to debug the code of the resource file with the problem at the server side, but since the server is generally busy, the service of performing the debugging operation in the server may need to wait in a queue until there is a free thread to perform the debugging operation service, so that the time required for debugging the code of the resource file with the problem each time is long. In addition, since it is generally difficult to solve the problem in the code of the resource file by only one debugging, and a plurality of times of debugging are required, time required for solving the problem by debugging is further increased (in particular, when a resource file stored in another server is debugged, a large amount of transmission time is wasted). Based on the reasons, the staff is difficult to debug the resource files with problems in the webpage quickly and conveniently.
Therefore, in the prior art, a http proxy method is adopted for resource files to be debugged in a web page, and the resource files to be debugged are mapped to the local terminal, so that the resource files can be debugged by using real online data in the following process, wherein the http proxy method is specifically shown in fig. 1.
Fig. 1 is a method of http proxy in the prior art, which specifically includes:
s101: and determining a resource file to be debugged in the webpage, and downloading the resource file as a resource file to be debugged.
The http proxy method is expected to enable a worker to complete debugging of the resource file locally at a terminal, so that the terminal needs to determine the resource file to be debugged in a webpage at first, and then downloads the file locally to the terminal to serve as the resource file to be debugged, so that the resource file to be debugged can be debugged later.
S102: and establishing a virtual server and determining an access path for the resource file to be debugged.
The resource file to be debugged needs to be acquired through a local browser. Specifically, the browser obtains an access path of the resource file to be debugged (i.e., a domain name of the resource file to be debugged) by running a code in the web page, then initiates a request for calling the resource file to a server providing the resource file to be debugged according to the access path, and finally obtains the resource file to be debugged returned by the server.
However, since the staff wants to modify the resource file to be debugged locally, at this time, the terminal also needs to pretend to be a server to deceive the browser, and let the browser obtain the locally downloaded resource file to be debugged by running the same web page code. Therefore, the purpose of debugging the resource file to be debugged locally at the terminal is achieved.
Specifically, the terminal needs to establish a virtual server locally, and determine an access path (i.e., a virtual domain name of the resource file to be debugged) for the resource file to be debugged stored locally.
S103: and replacing the access path for accessing the original resource file with the access path for accessing the local resource file to be debugged through the virtual server.
In order to make the browser in the terminal access the resource file through the webpage code, the browser does not access the server of the resource file any more, but accesses the local virtual server. At this time, the network configuration of the terminal also needs to be modified, so that when the terminal receives a request for calling the resource file initiated by the browser, an access path for accessing the resource file is replaced with an access path for accessing the local resource file to be debugged.
When the browser sends a request for calling the resource file to a server on the network, the virtual server replaces the server on the network to receive the calling request, returns the resource file to be debugged to the server, and ensures that the browser determines that the resource file returned by the corresponding server on the network is received.
By the method described in fig. 1, the resource file to be debugged can be downloaded locally and then used as a resource file to be debugged, the resource file to be debugged is debugged locally at the terminal, and since the code in the web page is not changed, online real data can be fully utilized for debugging. Furthermore, the terminal can be only used for debugging the resource file to be debugged, so that each debugging process can be executed immediately without waiting, and the debugging efficiency is improved.
However, the process shown in fig. 1 can be implemented only for a web page whose web page is hypertext transfer protocol (http). For a webpage with a webpage being a Secure Socket Layer hypertext transfer Protocol (https), at this time, transmission between a browser and a server needs to be encrypted for communication, that is, the browser needs to verify the identity of the server by using a security certificate generated by a Secure Socket Layer Protocol (ssl) Protocol, and when receiving a resource file returned by the server, needs to verify whether the resource file carries a corresponding security certificate.
However, in the process shown in fig. 1, the virtual server does not have a security certificate, and cannot provide a security certificate, so that the browser cannot verify the identity of the virtual server, and cannot determine the security of the resource file to be debugged that is returned by the virtual server, and for the https web page, the browser cannot even call the resource file to be debugged, so that the worker cannot perform subsequent debugging work.
Therefore, in the prior art, due to the fact that no security certificate exists, proxy of the https webpage is difficult to carry out, and the resource file to be debugged cannot be called.
Detailed Description
In the embodiment of the application, when a replacement instruction of a network resource in an https webpage is received, the terminal firstly establishes a virtual server locally at the terminal according to the instruction, then replaces an access path of the network resource file accessed in the terminal with an access path of a local resource file to be debugged through the virtual server, and finally generates a root certificate and a corresponding sub-certificate for the virtual server. According to the method, the virtual server can deceive the browser through a method for generating a root certificate (namely, a self-signed certificate issued by the virtual server) for the virtual server, so that the browser determines that the virtual server is a server for providing network resource files in https webpages, and can return a sub-certificate generated by the root certificate when returning local resource files to be debugged to the browser, so that the browser determines that the resource files to be debugged are safe files, and finally, the browser can call and execute the resource files to be debugged.
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be described in detail and completely with reference to the following specific embodiments of the present application and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Fig. 2 is a process for calling a file according to an embodiment of the present application, which specifically includes the following steps:
s201: a replacement instruction for a network resource file in an https web page is received.
Since the network resource file in the https webpage needs to be debugged locally at the terminal, before debugging starts, the local resource file to be debugged needs to be replaced with the network resource file in the https webpage. However, since the resource file to be debugged has not yet been debugged, the current resource file to be debugged may be any file, and may be a file that only possesses a file identifier and an address but does not have corresponding content (i.e., is a blank file), and does not prevent the resource file to be debugged from being called subsequently.
Thus, in the embodiment of the present application, the terminal may receive a replacement instruction for the network resource file in the https webpage.
Specifically, the replacing instruction may be a line of command lines, which is used for enabling the terminal to determine the network resource file that needs to be replaced and the resource file to be debugged that is pre-stored locally. Wherein the replacement instruction comprises: the identification of the network resource file, the access path of the network resource file, the identification of the resource file to be debugged which is pre-stored locally and the address of the resource file to be debugged.
It should be noted that the terminal may be a Personal Computer (PC), a mobile phone, a tablet computer, and the like, and the network Resource file may be a java script language (JavaScript, JS) program source file running on a browser, a Cascading Style sheet (css) file, and the like, which may be provided by a server through a Uniform Resource Locator (URL).
For example, suppose that a music play button in the https webpage a returns a JS program source file (hereinafter, referred to as an audio JS file) for calling a local player application to play an audio file to the browser after being clicked, so that the https webpage a plays a specified audio file through the local player application, but after a worker operates the https webpage a online, the worker finds that the https webpage a does not play the audio file after clicking the music play button, and thus the worker needs to perform a JS program source file on his PC for the https webpage a that has a problem.
Assume further that the PC receives a replacement instruction for the audio JS file (i.e., the network resource file) in the https web page a, and that the replacement instruction includes an identification of the audio JS file: JS, access path of the audio JS file: https:// www.XX.com/XX/a.js, and the identifier of the resource file to be debugged, which is locally and pre-stored by the PC: js and the address of the resource file to be debugged: e \ debugging work \ file to be debugged \ b.
S202: and establishing a virtual server locally according to the replacement instruction.
In the embodiment of the present application, the calling process of the network resource file under normal conditions is: the browser in the terminal determines an access path of a network resource file to be called first by running a code of the https webpage, then initiates a request for calling the network resource file to a server storing the network resource file (i.e., initiates a calling request according to the access path of the network resource file), and finally receives the network resource file returned by the server and a sub-certificate provided by the server, and completes calling of the network resource file.
However, in the present application, since it is necessary for the browser to call the local resource file to be debugged (so that debugging can be performed locally at the terminal in the following), an access path that can be accessed by the browser needs to be provided for the resource file to be debugged. Therefore, in the application, the terminal needs to be disguised as a virtual server storing the resource file to be debugged, and the domain name of the virtual server is determined, so that the browser can access the virtual server through the domain name of the virtual server, so as to generate an access path for the resource file to be debugged subsequently.
Specifically, the process of establishing the virtual server locally at the terminal is consistent with the prior art, and by establishing the virtual server and determining the domain name of the virtual server, the browser in the terminal can access the virtual server locally established at the terminal through the domain name of the virtual server, so that a foundation is established for the browser to call the resource file to be debugged stored locally.
Continuing with the above example, assume that the PC has established a virtual server α on the PC after receiving the replacement command, and determines that its domain name is: https:// www.YY.com.
S203: and replacing the access path for accessing the network resource file with the access path for accessing the local resource file to be debugged through the virtual server.
In the embodiment of the application, after the virtual server is established, an access path can be generated for the resource file to be debugged, so that the browser can call the resource file to be debugged according to the access path of the resource file to be debugged. However, at this time, the browser still accesses the path of the network resource file according to the web page code of the https web page, so the access path for accessing the network resource file also needs to be replaced with the access path for accessing the resource file to be debugged.
Specifically, an access path of the file to be debugged (that is, the virtual domain name of the resource file to be debugged) is first generated according to the domain name of the virtual server and the address of the file to be debugged, and then the resource file to be debugged may be considered to be the file stored in the virtual server at this time.
Secondly, modifying the network configuration of the terminal, and replacing the access path for accessing the network resource file with the access path for accessing the resource file to be debugged. When the terminal receives an access, call or query request which is sent by the browser and is based on the access path of the network resource file, the virtual server receives the access, call or query request according to the alternative relation of the access path, and the destination of the access, call or query request is pointed to the access path of the resource file to be debugged.
In addition, in order to furthest utilize online real data to run the https webpage in a subsequent debugging process and ensure the reliability of a debugging result, in the application, only an access path for the network resource file is modified to be an access path for the resource file to be debugged, and an access path for other resource files sent by the browser is not modified, so that when the browser calls other resource files on the https webpage, an access path determined according to the https webpage is not changed, and the browser is finally called or other resource files on the network, and when the browser calls the network resource files, the access path determined by the browser is replaced by the resource file to be debugged which points to the local terminal, and the browser calls the resource file to be debugged which is locally stored. And in the subsequent debugging process, the browser can use the real data on the line to the maximum extent, so that the staff only debugs the debugging resource file.
It should be noted that, the method for generating an access path for the resource to be debugged is the same as the prior art, and an access path based on the domain name of the virtual server can be arbitrarily generated for the resource file to be debugged, and the corresponding relationship between the access path and the address of the resource file to be debugged is recorded, so that the virtual server can determine the resource file to be debugged according to the access path.
Continuing to use the above example, assuming that the PC generates an access path of the resource file b.js to be debugged through the domain name https:// www.YY.com of the virtual server α and the address E: \ debugging work \ file to be debugged \ b.js of the resource file b.js to be debugged: https:// www.YY.com/b.js. And the PC also replaces the access path https:// www.XX.com/XX/a.js in the network configuration with https:// www.YY.com/b.js. When the PC receives a call request of an audio JS file aiming at the https webpage A sent by a terminal browser B, the virtual server alpha receives the call request according to the modified access path in the network configuration, and calls the resource file b.js to be debugged according to the access path https:// www.YY.com/b.js.
S204: generating a root certificate for the virtual server.
In the embodiment of the present application, it is stated in step S101 that the present application is based on an https web page, and for the https web page, communication encryption is required for the transmission between the browser and the virtual server, so in order to enable the virtual server to encrypt communication with the transmission between the browser, a root certificate needs to be generated for the virtual server.
Specifically, since the root Certificate is only used in the terminal as the security Certificate of the virtual server, an authoritative security Certificate with high public trust (e.g., a CA Certificate issued by a Certificate Authority) is not needed, and only the browser needs to be deceived, so that the browser can communicate with the transmission of the virtual server device for encryption.
It should be noted that the root certificate is various types of security certificates, such as a domain name SSL (DVSSL) certificate, an enterprise SSL (OVSSL) certificate, an enhanced SSL (Extended validity SSL) certificate, and a wildcard SSL (wildcard SSL) certificate, which is not specifically limited in this application.
Continuing with the above example, assume that a root certificate β is generated for the virtual server α.
S205: and generating a sub-certificate according to the root certificate.
In this embodiment, after generating the root certificate for the virtual server (i.e., after issuing the self-signed certificate for the virtual server), in order to enable the browser to call the resource file to be debugged that is locally stored in the terminal, the virtual server may further generate a sub-certificate for sending to the browser according to the root certificate, so that the browser may determine that the resource file to be debugged is secure according to the sub-certificate. After the root certificate and the sub-certificate thereof are generated, the browser can be in communication connection with the virtual server based on the https webpage.
Specifically, consistent with the prior art, the virtual server generates a sub-certificate for sending to the browser based on the root certificate, so that when the browser in the terminal initiates a call request for the network resource file according to the https webpage, the virtual server receives the call request, returns the resource file to be debugged and the sub-certificate to the browser according to an access path for replacing the access path with the local resource file to be debugged, and further enables the browser to determine that the resource file to be debugged is safe according to the sub-certificate and acquire and execute the resource file to be debugged.
Continuing with the above example, assuming that the virtual server generates the sub-certificate γ according to the root certificate β, when the browser B initiates a call request to https:// www.XX.com/XX/a.js according to the https web page a, the virtual server α receives the call request initiated to https:// www.YY.com/b.js, and the virtual server α returns the resource file to be debugged b.js and the sub-certificate γ to the browser, so that after receiving the resource file to be debugged b.js and the sub-certificate γ, the browser B determines that the resource file to be debugged b.js is safely available according to the sub-certificate γ, and acquires and executes the resource file to be debugged b.js.
Through the file calling method shown in fig. 2, it can be seen that, since the root certificate and the sub certificate are generated for the virtual server, even if a browser calls a network resource file initiated according to an https webpage, the virtual server can deceive the browser through the root certificate, so that the browser determines that the virtual server is a server providing the network resource file in the https webpage, and the virtual service returns the resource file to be debugged and the sub certificate to the browser, so that the resource file to be debugged can deceive the browser through the sub certificate, and the browser determines that the identity of the resource file to be debugged is secure. Therefore, the network resource files in the https webpage are replaced, and the browser can acquire and execute the local resource files to be debugged. And the staff can debug the network resource file in the https webpage with problems at the local terminal.
In addition, as described in step S201, the resource file to be debugged may be any file, and thus, in order to debug the resource file to be debugged later, the network resource file may also be downloaded to the address of the resource file to be debugged in the present application.
Specifically, the terminal may determine an access path of the network resource file according to the replacement instruction, and download the network resource file to the address of the resource file to be debugged according to the access path of the network resource file, so that the resource file to be debugged is not any file at this time, but has been replaced with the downloaded network resource file, and then a subsequent worker may debug the resource file to be debugged locally.
It should be noted that the downloading of the network resource file and the replacement of the resource file to be debugged may be performed in any step in the present application, and it is only necessary to ensure that the access path of the resource file to be debugged generated in step S203 is the access path of the resource file to be debugged that has been replaced by the network resource file.
Based on the process of calling a file as shown in fig. 2, an embodiment of the present application further provides a device for calling a file, as shown in fig. 3.
Fig. 3 is a schematic structural diagram of a file calling device according to an embodiment of the present application, which specifically includes:
the receiving module 301 is configured to receive a replacement instruction of a network resource file in an https webpage;
an execution module 302, configured to establish a virtual server locally according to the replacement instruction;
a replacing module 303, configured to replace, by the virtual server, an access path for accessing the network resource file with an access path for accessing a local resource file to be debugged;
a root certificate module 304, configured to generate a root certificate for the virtual server;
and a sub-certificate module 305, configured to generate a sub-certificate according to the root certificate, so that when a local browser initiates a call request for the network resource file according to the https web page, the virtual server receives the call request, and returns the resource file to be debugged and the sub-certificate to the browser according to an access path that is replaced by an access path for accessing a local resource file to be debugged, so that the browser obtains and executes the resource file to be debugged according to the sub-certificate.
The replacement instruction includes: the identification of the network resource file, the access path of the network resource file, the identification of the resource file to be debugged which is pre-stored locally and the address of the resource file to be debugged.
The execution module 302 is specifically configured to locally establish a virtual server according to the replacement request, and determine a domain name of the virtual server.
The replacing module 303 is specifically configured to generate an access path of the resource to be debugged according to the domain name of the virtual server and the address of the resource file to be debugged, and replace the access path for accessing the network resource file with an access path for accessing a local resource file to be debugged.
The device further comprises:
the downloading module 306 is configured to download the network resource file to the address of the resource file to be debugged.
Specifically, the database statement compiling apparatus shown in fig. 3 may be located in a terminal, where the terminal may be a mobile phone, a tablet computer, or a PC.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.