Summary of the invention
In order to solve the above-mentioned technical problem, the embodiment of the present application provides a kind for the treatment of method and apparatus of network request,
Also to improve the efficiency of transmission of information while ensuring information security.
The embodiment of the present application discloses following technical solution:
A kind of processing method of network request, comprising:
Obtain the network request of client;
Identify in the access resource of the network request whether comprising client local resource;
If searching visitor from the client comprising the resource of client local in the access resource of the network request
The resource at family end, and obtain in the access resource of the network request from network server except the client is local
Resource except remote resource;
The resource of the client local and the long-range resource are merged, the resource after merging is the net
The access resource of network request.
Preferably, it is described identification in the access resource of the network request whether include client local resource, wrap
It includes:
Destination request information is parsed from the network request;
Judge that the destination request information whether there is and the matched character string of feature string in preset white list;
If so, determine the resource in the access resource of the network request comprising client local, otherwise, it determines
The resource of client local is not included in the access resource of the network request;
Wherein, be stored in the preset white list it is corresponding between feature string and the resource of client local
Relationship.
Preferably, further includes:
White list setting template is provided a user, sets characteristic character in order to which user is based on white list setting template
Corresponding relationship between string and the resource of client local.
Preferably, the white list sets template to obtain from network server.
Preferably, the white list sets the feature string in template to be preset by network server, so as to
The resource of corresponding client local can be set for preset feature string in user.
Preferably, the destination request information includes transport protocol type, request address, requesting method, request header and asks
Ask any one in body or any number of combinations.
Preferably, the resource that client local is searched from the client are as follows:
According to the corresponding relationship between the feature string stored in white list and the resource of client local, from client
Obtain the corresponding local resource of feature string for matching the character string in the solicited message.
It is preferably, described to merge the resource of the client local and the long-range resource, comprising:
The resource of the client local is pre-processed, so that by the money of the pretreated client local
Source is consistent with the remote resource form;
It will be merged by the resource of the pretreated client local with the remote resource.
A kind of processing unit of network request, comprising:
Acquiring unit, for obtaining the network request of client;
Recognition unit, for identification in the access resource of the network request whether include client local resource;
Search acquiring unit, if in the access resource of the network request comprising client local resource,
The resource of client local is searched from the client, and obtains the access resource in the network request from network server
In remote resource in addition to the resource of the client local;
Combining unit, for the resource of the client local and the remote resource to be merged, the money after merging
Source is the access resource of the network request.
Preferably, the recognition unit includes:
Parsing subunit, for parsing destination request information from the network request;
Judgment sub-unit, for judging that the destination request information whether there is and the characteristic character in preset white list
The character string of String matching;
Subelement is determined, for if so, determining in the access resource of the network request comprising client local
Resource, otherwise, it determines not including the resource of client local in the access resource of the network request;
Wherein, be stored in the preset white list it is corresponding between feature string and the resource of client local
Relationship.
Preferably, further includes:
Template provides unit, for providing a user white list template, sets mould in order to which user is based on the white list
Plate sets the corresponding relationship between feature string and the resource of client local.
Preferably, the white list sets template to obtain from network server.
Preferably, the white list sets the feature string in template to be preset by network server, so as to
The resource of corresponding client local can be set for preset feature string in user.
Preferably, the destination request information includes transport protocol type, request address, requesting method, request header and asks
Ask any one in body or any number of combinations.
Preferably, the lookup acquiring unit is specifically used for, according to the feature string and client stored in white list
Corresponding relationship between local resource obtains the feature string pair for matching the character string in the solicited message from client
The local resource answered.
Preferably, the combining unit includes:
Subelement is compiled, for pre-processing the resource of the client local, so that by pretreated institute
The resource for stating client local is consistent with the remote resource form;
Merge subelement, the resource and the long-range resource for that will pass through the pretreated client local carry out
Merge.
As can be seen from the above-described embodiment, compared with prior art, it is the advantages of the application:
The network request that client is sent to network server is obtained, first identifying in the access resource of the network request is
The no resource comprising client local, if being sent to network server comprising, the network request that no longer will acquire, but from visitor
The resource of client local is searched at family end, and obtains remaining remote resource from network server, then in client local
Complete access resource is merged into two parts resource, client will be submitted directly to comprising the network response for completely accessing resource
End.Since in entire treatment process, the resource of client local is always in client, without being uploaded to network server,
Therefore, a possibility that resource of client local is illegally stolen is reduced, and then also avoids asking for privacy of user leakage
Topic.
In addition, the resource of client local, which also no longer needs to undergo, first uploads to network server from client, then from net
Network server downloads back the process of client, therefore, also improves the efficiency of transmission of information.
Specific embodiment
It exemplary is answered referring initially to what Fig. 1, Fig. 1 schematically showed that presently filed embodiment can be implemented within
Use scene.Wherein, the processing unit 30 of the network request in the application is set up in client 10.The processing unit of network request
Browser 40 is sent to the network request 11 of network server 20 in 30 acquisition clients 10, if in the access of network request 11
Comprising the resource that client 10 is local in resource, the processing unit 30 of network request responds network request 11, and by net
The browser 40 of client 10 is submitted in network response 31;If not including client 10 in the access resource of network request 11
Network request 11 is sent to network server 20 by the processing unit 30 of the resource on ground, network request, is pressed by network server 20
Network request 11 is responded according to the prior art, and network response 21 is returned into browser 40.Wherein, " resource " can be
The files such as picture, audio or video.It will be understood by those skilled in the art that schematic diagram shown in FIG. 1 is only the reality of the application
The mode of applying can be in an example being wherein achieved.The application range of the application embodiment is not by any side of the frame
The limitation in face.For example, network server 20 is also possible to other kinds of server, such as APP server.
In order to make the above objects, features, and advantages of the present application more apparent, with reference to the accompanying drawing to the application
Embodiment is described in detail.
Embodiment of the method
Referring to Fig. 2, schematically showing the processing method of the network request of an embodiment according to the application
Flow chart, for example, this method can be executed by the processing unit 30 of network request, this method for example may include following step
It is rapid:
Step 201: obtaining the network request of client.
Step 202: identification in the access resource of the network request whether comprising client local resource.
Step 203: if comprising the resource of client local in the access resource of the network request, from the client
The resource of client local is searched at end, and is obtained from network server and removed the visitor in the access resource of the network request
Remote resource except the resource at family end.
Step 204: the resource of the client local and the remote resource being merged, the resource after merging is
The access resource of the network request.
It should be understood that in this application, obtaining client and being sent to the network request of network server, if identified
Comprising the resource of client local in the access resource of network request, the network request that not will acquire is sent to network service
Device, that is to say, that network server does not need to respond network request, and client is also no longer by the resource of client local
It is uploaded to network server.Processing to network request is completed in client-side, that is, on the one hand searches visitor from client
On the other hand the resource at family end obtains other in addition to the resource of client local in access resource from network server
Then two parts resource is merged into complete access resource by resource.In entire treatment process, the resource of client local begins
Eventually in client, without being uploaded to network server, therefore, reduce the resource of client local in upload procedure and
A possibility that network server is illegally stolen, and then also avoid the problem of privacy of user is revealed.In addition, due to client
The local resource in end does not need experience and first uploads to network server from client, then downloads back client from network server
Therefore process also improves the efficiency of transmission of information.
Wherein it is possible to intercept the network request by blocking module before client sends network request.
In the preferred embodiment of the application, the network of the access resource comprising the network request is responded straight
It connects and submits to client.
In addition, in another preferred embodiment of the application, if in the access resource of the network request not
The network request is sent to network server by the resource comprising client local.
It should be understood that being said if identifying the resource for not including client local in the access resource of network request
The access resource of the bright network request is only in network server side, and therefore, client does not need to upload visitor to network server
The resource at family end, and then the problem of privacy of user is revealed also just is not present.
In another preferred embodiment of the application, as shown in figure 3, providing a kind of visit identified in network request
Ask in resource whether the method for the resource comprising client local, this method may comprise steps of:
Step 301: destination request information is parsed from the network request.
Step 302: judging in the destination request information with the presence or absence of the characteristic character String matching with preset white list
Character string otherwise, enter step 304 if so, entering step 303.
Step 303: determining the resource in the access resource of the network request comprising client local, terminate process.
Step 304: determining the resource for not including client local in the access resource of the network request, terminate stream
Journey.
Wherein, in the corresponding pass being stored in preset white list between feature string and the resource of client local
System.
In the preferred embodiment of the application, white list setting template can be provided a user, in order to user
Based on the corresponding relationship between white list setting template setting feature string and the resource of client local.
Wherein it is possible to provide a user the white list setting template an of blank, first preset in the template by user
Feature string, then set for preset feature string the resource of corresponding client local.Certainly, white list is set
Feature string in solid plate can also be preset by network server, and the processing unit 30 of network request is from network service
Device obtains the template.The white list setting template for being set with feature string can be provided a user at this time, so as to
The resource of corresponding client local is further set for the feature string in the template by user.
In the preferred embodiment of the application, destination request information includes transport protocol type, request address, asks
Ask any one in method, request header and request body or any number of combinations.
For example, user accesses some webpage by client (e.g., browser), if the access address of the webpage are as follows:
Http:// www.taobao.com/go/rgn/sidebar/my1212.php? date&_ksTS=
1418267274797_597&callback=jsonp598
The message content for the network request for accessing the webpage that the client is sent to network server is as follows:
request
GET//go/rgn/sidebar/my1212.php? date&_ksTS=1418267274797_597&callback
=jsonp598HTTP/1.1
host:www.taobao.com
proxy-connection:keep-alive
accept:text/javascript,application/javascript,application/ecmascript,
application/x-ecmascript,*/*;Q=0.01
x-requested-with:XMLHttprequest
user-agent:Mozilla/5.0(macintosh;Intel Mac OS X 10_10_0)AppleWebKit/
537.36(KHTML,likeGecko)Chrome/39.0.2171.7
dnt:1
referrer:http://www.taobao.com/
accept-encording:gzip,deflate,sdch
accept-language:en-US,en;Q=0.8, zh-CN;Q=0.6
……
content-length:0
request body
response header
……
The solicited message that can be parsed out from the network request is as follows:
1, transport protocol type: HTTP/1.1
2, request address:
/ go/rgn/sidebar/my1212.php? date&_ksTS=1418267274797_597&callback=
jsonp598
3, requesting method: GET method
4, request header:
host:www.taobao.com
proxy-connection:keep-alive
accept:text/javascript,application/javascript,application/ecmascript,
application/x-ecmascript,*/*;Q=0.01
x-requested-with:XMLHttprequest
user-agent:Mozilla/5.0(macintosh;Intel Mac OS X 10_10_0)AppleWebKit/
537.36(KHTML,likeGecko)Chrome/39.0.2171.7
dnt:1
referrer:http://www.taobao.com/
accept-encording:gzip,deflate,sdch
accept-language:en-US,en;Q=0.8, zh-CN;Q=0.6
……
content-length:0
5, request body is sky.
For example, by taking destination request information is only request address as an example, as shown in figure 4, if being set in preset white list
Fixed feature string includes:
“foo/1.0.0/a.js”、“foo/1.2.0/b.js”
Does is the request address that can be parsed out from network request shown in Fig. 4 //t.com/? foo/1.0.0/a.js,
foo、1.2.0/b.js,bar/2.0.0/c.js
In the request address exist in above-mentioned preset white list the matched character string of feature string (that is,
Foo/1.0.0/a.js and foo/1.2.0/b.js), therefore, visitor is included in the access resource of network request shown in Fig. 4
The resource at family end.And in the request address there is also with the matched word of feature string in above-mentioned preset white list
Symbol string (that is, bar/2.0.0/c.js), the request address requested resource are remote resource, need to obtain from network server
It takes.Finally, the resource of client local and remote resource are merged processing.
Certainly, it should be noted that several destination request information are specifically parsed from network request for identification in net
Network request access resource in whether comprising client local resource, can arbitrarily be set according to the difference of application scenarios,
The application is not specifically limited the number of solicited message.
It, can be with when searching the resource of client local from client in another preferred embodiment of the application
According to the corresponding relationship between the feature string stored in white list and the resource of client local, obtains and match from client
The corresponding local resource of the feature string of character string in the solicited message.
In addition, being obtained in the access resource of network request in addition to the resource of client local when from network server
When remote resource, the network request is adjusted, so that the network request adjusted only includes eliminate local resource other
Resource request information (for example, can first delete in the network request with the matched character string of feature string in white list),
Then the network request for being adjusted processing is sent to network server again, so that network server is adjusted processing to this
Network request responded, and return comprising remote resource network respond.
In this application, after the resource and remote resource for obtaining client local, to the resource of client local and remote
The merging treatment of Cheng Ziyuan is identical as the mode of the merging treatment of network server in the prior art, that is, local to client
Resource is pre-processed, so that consistent with remote resource form by the resource of pretreated client local;It will be by pre-
The resource of the client local of processing is merged with remote resource.Obviously, the resource after merging is the access of network request
Resource.
Wherein, pretreatment includes but is not limited to: the compiling of code, code dependence extract, code syntax and correlation
At the adjustment of information, the modification of text information, the size processing of picture and video and tone processing, Information Compression and coded format
Reason etc..
It is, of course, also possible to be pre-processed to remote resource, so that by pretreated remote resource and client sheet
The resource form on ground is consistent, will merge by pretreated remote resource and the resource of client local.
As can be seen from the above-described embodiment, compared with prior art, it is the advantages of the application:
The network request that client is sent to network server is obtained, first identifying in the access resource of the network request is
The no resource comprising client local, if being sent to network server comprising, the network request that no longer will acquire, but from visitor
The resource of client local is searched at family end, and obtains remaining remote resource from network server, then in client local
Complete access resource is merged into two parts resource, client will be submitted directly to comprising the network response for completely accessing resource
End.Since in entire treatment process, the resource of client local is always in client, without being uploaded to network server,
Therefore, the problem of reducing a possibility that resource of client local is illegally stolen, and then also avoiding information leakage.
In addition, the resource of client local, which also no longer needs to undergo, first uploads to network server from client, then from net
Network server downloads back the process of client, therefore, also improves the efficiency of transmission of information.
Installation practice
Corresponding with a kind of above-mentioned processing method of network request, the embodiment of the present application also provides a kind of network requests
Processing unit.Referring to Fig. 5, Fig. 5 schematically shows the processing of the network request of an embodiment according to the application
The structural block diagram of device, the device include: acquiring unit 501, recognition unit 502, search acquiring unit 503 and combining unit
504.Its internal structure and connection relationship are further described below with reference to the working principle of the device.
Acquiring unit 501, for obtaining the network request of client;
Recognition unit 502, for identification in the access resource of the network request whether include client local money
Source;
Acquiring unit 503 is searched, if for including the money of client local in the access resource of the network request
The resource of client local is searched from the client, and obtains the access in the network request from network server in source
Remote resource in resource in addition to the resource of the client local;
Combining unit 504, for merging the resource of the client local and the remote resource, after merging
Resource is the access resource of the network request.
In the preferred embodiment of the application, as shown in fig. 6, the device further include:
First response unit 405, for will include that the access response of access resource of the network request returns to client
End.
Certainly, as shown in fig. 7, the device can further include:
Second response unit, if the money for not including client local in the access resource of the network request
The network request is sent to network server by source.
In another preferred embodiment of the application, as shown in figure 8, recognition unit 502 includes:
Parsing subunit 5021, for parsing destination request information from the network request;
Judgment sub-unit 5022, for judging that the destination request information whether there is and the feature in preset white list
The character string of string matching;
Subelement 5023 is determined, for if so, determining to include client sheet in the access resource of the network request
The resource on ground, otherwise, it determines not including the resource of client local in the access resource of the network request;
Wherein, be stored in the preset white list it is corresponding between feature string and the resource of client local
Relationship.
In another preferred embodiment of the application, the device further include:
Template provides unit, for providing a user white list template, sets mould in order to which user is based on the white list
Plate sets the corresponding relationship between feature string and the resource of client local.
In another preferred embodiment of the application, the white list sets template to obtain from network server.
In another preferred embodiment of the application, the white list sets the feature string in template as by net
Network server is preset, in order to which user can set the money of corresponding client local for preset feature string
Source.
In another preferred embodiment of the application, the destination request information includes transport protocol type, request
Any one in address, requesting method, request header and request body or any number of combinations.
In another preferred embodiment of the application, searches acquiring unit 503 and be specifically used for, deposited according in white list
Corresponding relationship between the resource of feature string and the client local of storage is obtained from client and is matched in the solicited message
Character string the corresponding local resource of feature string
In another preferred embodiment of the application, combining unit 504 includes:
Subelement is compiled, for pre-processing the resource of the client local, so that by pretreated institute
The resource for stating client local is consistent with the remote resource form;
Merge subelement, for closing the resource for passing through the pretreated client local with the remote resource
And.
As can be seen from the above-described embodiment, compared with prior art, it is the advantages of the application:
The network request that client is sent to network server is obtained, first identifying in the access resource of the network request is
The no resource comprising client local, if being sent to network server comprising, the network request that no longer will acquire, but from visitor
The resource of client local is searched at family end, and obtains remaining remote resource from network server, then in client local
Complete access resource is merged into two parts resource, client will be submitted directly to comprising the network response for completely accessing resource
End.Since in entire treatment process, the resource of client local is always in client, without being uploaded to network server,
Therefore, a possibility that resource of client local is illegally stolen is reduced, and then also avoids asking for privacy of user leakage
Topic.
In addition, the resource of client local, which also no longer needs to undergo, first uploads to network server from client, then from net
Network server downloads back the process of client, therefore, also improves the efficiency of transmission of information.
The technical staff in the field can be understood that for convenience of description and succinctly, foregoing description is
The specific work process of system, device and unit, can refer to corresponding processes in the foregoing method embodiment, details are not described herein.
In several embodiments provided herein, it should be understood that disclosed systems, devices and methods, it can be with
It realizes by another way.For example, the Installation practice described above arrived is only schematical, for example, the unit
Division, only a kind of logical function partition, there may be another division manner in actual implementation, such as multiple units or group
Part can combine or be desirably integrated into another system, or some features can be ignored or not executed.Another point, it is shown or
The mutual coupling, direct-coupling or communication connection discussed can be through some interfaces, the indirect coupling of device or unit
It closes or communicates to connect, can be electrical, mechanical or other forms.
The unit as illustrated by the separation member can be or be also possible to be physically separated, and show as unit
Component may or may not be physical unit, it can it is in one place, or may be distributed over multiple nets
On network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme
's.
It, can also be in addition, each functional unit in each embodiment of the application can integrate in one processing unit
It is that each unit physically exists alone, can also be integrated in one unit with two or more units.Above-mentioned integrated list
Member both can take the form of hardware realization, can realize in the form of software functional units.
It should be noted that those of ordinary skill in the art will appreciate that realizing the whole in above-described embodiment method or portion
Split flow is relevant hardware can be instructed to complete by computer program, and the program can be stored in a computer
In read/write memory medium, the program is when being executed, it may include such as the process of the embodiment of above-mentioned each method.Wherein, described
Storage medium can be magnetic disk, CD, read-only memory (Read-Only Memory, ROM) or random access memory
(Random Access Memory, RAM) etc..
A kind for the treatment of method and apparatus of network request provided herein is described in detail above, herein
Applying specific embodiment, the principle and implementation of this application are described, and the explanation of above example is only intended to sides
Assistant solves the present processes and its core concept;At the same time, for those skilled in the art, the think of according to the application
Think, there will be changes in the specific implementation manner and application range, in conclusion the content of the present specification should not be construed as pair
The limitation of the application.