A kind of method for accelerating HTTP on IOS
Technical field
The present invention relates to HTTP accelerates, especially on IOS, the side of HTTP is accelerated by flow guiding and protocol conversion
Method.
Background technology
The method of current acceleration HTTP, usually carries out the HTTP Proxy of standard using APN, and content is compressed
To reach the effect of acceleration, such as flow at full speed.The defect of this speed technology has:1. it is only in generation by the content of request
It is compressed in reason service, can so causes picture category resource to obscure;2. agent skill group as, can only be arranged in client
Act on behalf of and processing data bag of having no way, the agent skill group of standard can not be optimized.
Such as patent of invention of Application No. 201310362191.1, discloses a kind of HTTP and uploads accelerated method, right
In the HTTP upload requests for meeting certain condition, it is possible to reduce the response time, response speed is improved, while can also mitigate
The pressure of CDN service node.Its technical scheme is:Source station carries out upload configuration;User uploads static data by upload configuration;
Content delivery network node receives request;Content delivery network node judges whether the request for receiving is suitable for upload and accelerates work(
Energy;If inapplicable upload of request accelerates function, source station is uploaded data to, receive the response that source station returns, and sent the response to
User;If request is suitable for upload accelerates function, send to user after the completion of user data upload and respond, and data are preserved
In local cache, and any time behind by the data syn-chronization in local cache to source station.The patent of invention needs
Secondary development is carried out on software, it realizes complicated.
Again such as patent of invention of Application No. 200910127106.7, discloses a kind of dialogue-based cache
HTTP accelerates, and its method includes:Receive the first HTTP (HTTP) packet;First is created based on HTTP packets
Session;And for the first conversation establishing session cache entry;Receive the 2nd HTTP packets;Perform session cache to look into
Look for recognizing matching for the 2nd HTTP packets and session cache entries;And it is high based on the 2nd HTTP packets and session
The matching of fast cache entries is creating the second http session.The patent of invention needs the support of hardware, and cannot be straight by software
Connect realization.
The content of the invention
Therefore, for above-mentioned problem, the present invention proposes a kind of method for accelerating HTTP on IOS, solves this on IOS
Only agency service end and the agent skill group without client causes that content compression distortion and standard agency agreement efficiency are too poor to ask
Topic, need not carry out secondary development, it is not required that the support of hardware to software in addition, only be capable of achieving to accelerate by agency
HTTP。
In order to solve above-mentioned technical problem, thinking of the present invention is first, to set up local agent service, and is drawn
HTTP flows are led to local agent service;Local agent service is processed content, and the http protocol of standard is converted into
The higher agreement of performance(Such as spdy, utp).When app starts, the function of sdk is called, at this time lookup process address,
The address of this function is found, then replacement function address, you can the function for allowing app to call oneself to realize.Flow there is provided combining
Amount guiding and the method for protocol conversion, on the one hand can get packet and process is optimized to content prevents distortion, separately
On the one hand raising efficiency can be optimized to standard agreement.
Specifically, a kind of method for accelerating HTTP on IOS of the invention, discloses and combine on IOS flow guiding and assist
Method of the view conversion to accelerate HTTP, the method includes:
Step 1:Set up local agent service;
Step 2:The application software for producing HTTP flows is designated as into HTTP_APP, when the HTTP_APP initiates HTTP request,
First HTTP request is forwarded to into local agent service;
Step 3:The data of HTTP request are converted to spdy protocol formats or utp agreement lattice by local agent service first
The data of the higher protocol format of the performances such as formula, then by the proxy server of the data is activation after conversion to distal end;
Step 4:The proxy server of distal end is parsed to the data for receiving, if spdy protocol formats are then to it
Parsed according to spdy agreements, and be reduced into former HTTP data;If utp protocol formats then enter to it according to utp agreements
Row parsing, and it is reduced into former HTTP data;Then by reduction after former HTTP data is activations to destination address;
Step 5:Destination address is parsed to the former HTTP data for receiving, and exports HTTP result datas, by distal end
The HTTP result datas are converted into the higher protocol format of the performance such as spdy protocol formats or utp protocol formats by proxy server
Data, http protocol is converted to into spdy agreements or utp agreements;To be changed by spdy agreements or utp agreements afterwards
Result data afterwards is sent to local agent service;
Step 6:The data that local agent service is received are parsed, if spdy protocol formats are then to its basis
Spdy agreements are parsed, and are reduced into former HTTP result datas;If utp protocol formats then enter to it according to utp agreements
Row parsing, and it is reduced into former HTTP result datas;Then by reduction after former HTTP result datas send to user side.
Further, local agent service is set up including herein below:Construction proxy function, the proxy function is realized primary
HTTP API obtain the function of the global agency of system(Function SCDynamicStoreCopyProxies)Functional, the generation
After reason function is set up, by primary HTTP API Calls, agency is realized;The proxy function returns the structure comprising proxy information, should
Proxy information at least includes proxy, proxy port;The process address of HTTP_APP is obtained, and searches HTTP_APP in internal memory
Central mirror image head, finds the function of the proxy information for obtaining current network(Function name is
SCDynamicStoreCopyProxies), by the function address in the address replacing structure proxy function of the function;Then create
Build local agent service thread.
Further, HTTP_APP initiates HTTP request, and HTTP request is pre-processed first, then retransmits out
Go, if the pretreatment includes process:The HTTP request detects first the HTTP request domain name to be accessed and HTTP_APP's
Whether domain name is identical, if both differ, the domain name that HTTP request to be accessed is changed to into the domain name of HTTP_APP;Then examine
Survey authorized agency's row of HTTP request(Stem<headers>A line afterwards)Whether it is empty, if being not sky, is changed to
Blank line, then again sends the HTTP request.By above-mentioned setting, the validity of HTTP request can be tieed up
Shield, it is to avoid occur agency's error when follow-up authorized agency, and cause the method to use, so cause HTTP_APP cannot
Use.
The present invention is changed the data that HTTP_APP is transmitted by above-mentioned steps, the foundation serviced by local agent
For the data of the higher protocol format of the performance such as spdy protocol formats or utp protocol formats, so as to greatly accelerate connecing for HTTP
Receive and send, solve this only agency service end IOS on and the agent skill group without client cause content compression distortion with
The too poor problem of standard agency agreement efficiency;In addition, the present invention is also arranged to the situation of authorized agency's error, subtract significantly
Few HTTP_APP cannot use because of local agent service error the occurrence of;Meanwhile, present invention only requires setting up one
Local agent service and authorized agency, it is not necessary to extra exploitation is carried out to software, the burden of developer is significantly reduced, and
The support of hardware is not needed, is only capable of achieving to accelerate HTTP by agency, with good practicality.
Specific embodiment
In conjunction with specific embodiment, the present invention is further described.
As a specific example, the invention provides the SDK based on ios platform is for the generation HTTP flows of IOS
Application software HTTP_APP is called, and it is related to client and service end.In content compression and protocol optimization, need to accomplish visitor
Family end and service end coordinate.Wherein, the SDK possesses following two big functions:(1)Guiding HTTP flows are to local agent.(2)Will mark
Accurate http protocol is converted into the higher agreement of performance, while processing content.
Wherein, guide HTTP flows to local agent, initially set up local agent service, comprise the steps of:
Step 1:A local agent thread is created first, and returns to IP address and the port of local agent
(127.0.0.1:port), in being stored in memory variable;
Step 2:The imageheader mirror image heads of APP are searched, finding name is
“SCDynamicStoreCopyProxies”(Function:The agency for returning current network is arranged)Function address, this address is replaced
It is changed to SQL my_SCDynamicStoreCopyProxies(The function returns the IP address of local agent, its realization
SCDynamicStoreCopyProxies function identical functions, and be only that its agent address is different)Address;
Step 3:When APP calls my_SCDynamicStoreCopyProxies functions, the function first calls primary
SCDynamicStoreCopyProxies functions, obtain current network agency arrange, then with step 1 get it is local
Agent IP address and port(127.0.0.1:port)The IP during current network agency is arranged and port are replaced, and will be reached after replacement
Arrange to local agent and return to the function that upper strata is called, reached with this and replace the purpose that current network agency is arranged.
The http protocol of standard is converted into into the higher agreement of performance and content is processed and accelerate HTTP's to play
Purpose, comprises the steps of:
Step 1:The application software for producing HTTP flows is designated as into HTTP_APP, when the HTTP_APP initiates HTTP request,
First HTTP request is forwarded to into local agent service;
Step 2:The HTTP request for receiving is changed into corresponding protocol format by local agent service first(The higher association of performance
View form), and it is forwarded to the proxy server of distal end.General, can be optimized using two kinds of agreements once:(1)Spdy is assisted
View, local agent establishes spdysession with remote agent, HTTP request is changed into into spdy agreements and is sent to distal end generation
Reason.This agreement can reduce tcp establishment of connections, improve the number of concurrent of request.(2)Utp agreements, using udp agreements, in application layer
Realize Retransmission timeout to reach the effect of tcp agreements.The tcp agreement establishment of connection times can be reduced and the effect of Retransmission timeout is improved
Rate;
Step 3:The proxy server of distal end is parsed to the data for receiving, if spdy protocol formats are then to it
Parsed according to spdy agreements, and be reduced into former HTTP data;If utp protocol formats then enter to it according to utp agreements
Row parsing, and it is reduced into former HTTP data;Then by reduction after former HTTP data is activations to destination address;Meanwhile, distal end
Proxy server can also be optimized to former HTTP data, such as, for picture format transformation, unpressed content is pressed
Contracting.And then carry out contrary operation in client(Decompression), so as to come to reach for HTTP_APP be transparent;Then will
Proxy server of the data is activation after process to distal end;
Step 4:Destination address is parsed to the former HTTP data for receiving, and exports HTTP result datas, by distal end
The HTTP result datas are converted into the higher protocol format of the performance such as spdy protocol formats or utp protocol formats by proxy server
Data, http protocol is converted to into spdy agreements or utp agreements;To be changed by spdy agreements or utp agreements afterwards
Result data afterwards is sent to local agent service;
Step 5:The data that local agent service is received are parsed, if spdy protocol formats are then to its basis
Spdy agreements are parsed, and are reduced into former HTTP result datas;If utp protocol formats then enter to it according to utp agreements
Row parsing, and it is reduced into former HTTP result datas;Then by reduction after former HTTP result datas send to user side.
In addition, when HTTP_APP initiates HTTP request, pre-processing to HTTP request first, then retransmit away,
If the pretreatment includes process:The HTTP request detects first the domain name of the HTTP request domain name to be accessed and HTTP_APP
It is whether identical, if both differ, the domain name that HTTP request to be accessed is changed to into the domain name of HTTP_APP;Then detect
Authorized agency's row of HTTP request(Stem<headers>A line afterwards)Whether it is empty, if being not sky, is changed to sky
Bai Hang, then again sends the HTTP request.By above-mentioned setting, the validity of HTTP request can be safeguarded,
Avoid occurring agency's error when follow-up authorized agency, and cause the method to use, and then cause cannot making for HTTP_APP
With.
Although specifically showing and describing the present invention with reference to preferred embodiment, those skilled in the art should be bright
In vain, in the spirit and scope of the present invention limited without departing from appended claims, in the form and details can be right
The present invention makes a variety of changes, and is protection scope of the present invention.