CN109729176A - Network request method and device - Google Patents

Network request method and device Download PDF

Info

Publication number
CN109729176A
CN109729176A CN201910061370.9A CN201910061370A CN109729176A CN 109729176 A CN109729176 A CN 109729176A CN 201910061370 A CN201910061370 A CN 201910061370A CN 109729176 A CN109729176 A CN 109729176A
Authority
CN
China
Prior art keywords
connection
network request
network
url information
instantiation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910061370.9A
Other languages
Chinese (zh)
Inventor
陈鸿图
洪小军
阮永丽
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xiamen Meitu Technology Co Ltd
Original Assignee
Xiamen Meitu 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 Xiamen Meitu Technology Co Ltd filed Critical Xiamen Meitu Technology Co Ltd
Priority to CN201910061370.9A priority Critical patent/CN109729176A/en
Publication of CN109729176A publication Critical patent/CN109729176A/en
Pending legal-status Critical Current

Links

Abstract

The disclosure provides a kind of network request method and device, is related to Internet technical field.Applied to client, the client and server-side are communicated to connect, and method includes: acquisition network request, include the uniform resource position mark URL information of requested data in the network request;Judge in the connection pool pre-established with the presence or absence of connection corresponding with URL information included by the network request;If there is connection corresponding with URL information included by the network request in the connection pool pre-established, request of data directly is initiated to the server-side using the connection.To promote network request efficiency.

Description

Network request method and device
Technical field
This disclosure relates to Internet technical field, in particular to a kind of network request method and device.
Background technique
In many scenes, as mobile Internet develop scene in, network application is based primarily upon Client/Server frame Structure, i.e. client-side/server-side architecture, client are initiated to request to server-side, server-side returned data.Client now is very Under more scenes network request continually can be initiated to obtain cloud data to server-side, it has been investigated that, network request now Efficiency is to be improved.
Summary of the invention
The disclosure provides a kind of network request method and device.
In a first aspect, being applied to client, the client and server-side present disclose provides a kind of network request method Communication connection, which comprises
Network request is obtained, includes the uniform resource position mark URL information of requested data in the network request;
Judge in the connection pool pre-established with the presence or absence of company corresponding with URL information included by the network request It connects;
If there is connection corresponding with URL information included by the network request in the connection pool pre-established, Then request of data directly is initiated to the server-side using the connection.
Optionally, connection is put into connection pool by following steps:
Obtain the URL information of the requested data of network request;
Judge whether the network library of the client initializes, if the network library no initializtion, initializes the net The connection pool of the network library is obtained after network library;
Domain name mapping is carried out to domain name according to the URL information, after domain name mapping success, instantiates connecting object;
Foundation is attached to the connecting object of instantiation;
Established connection is put into the connection pool.
Optionally, foundation is attached to the connecting object of instantiation, comprising:
If the URL information configuration protocol is http, transmission control protocol TCP is carried out to the connecting object of instantiation Connection;
If the URL information configuration protocol is https/http2, transmission control is carried out to the connecting object of instantiation Agreement TCP connection, and carry out Secure Socket Layer SSL or Transport Layer Security TLS connection.
Optionally, the method also includes:
After domain name mapping success, if instantiation connecting object failure, terminates connection and establishes;
If carrying out transmission control protocol TCP connection, Secure Socket Layer SSL or transport layer to the connecting object of instantiation to pacify Full TLS connection failure then terminates connection and establishes.
Optionally, the method also includes:
Before established connection is put into the connection pool, when being arranged idle for established connection Between;
According to the free time, whether the free time length of detection connection reaches given threshold, if the free time length of connection reaches To the given threshold, then the connection is removed from the connection pool.
Second aspect, the disclosure provide a kind of network request device, are applied to client, and the client and server-side are logical Letter connection, the network request device include:
Request obtains module, includes the unified money of requested data for obtaining network request, in the network request Source finger URL URL information;
Request processing module, in the connection pool for judging to pre-establish with the presence or absence of with included by the network request The corresponding connection of URL information, if existing and URL information pair included by the network request in the connection pool pre-established The connection answered then directly initiates request of data to the server-side using the connection.
Optionally, the network request device further include connection processing module, the connection processing module for by with Connection is put into connection pool by lower step:
Obtain the URL information of the requested data of network request;
Judge whether the network library of the client initializes, if the network library no initializtion, initializes the net The connection pool of the network library is obtained after network library;
Domain name mapping is carried out to domain name according to the URL information, after domain name mapping success, instantiates connecting object;
Foundation is attached to the connecting object of instantiation;
Established connection is put into the connection pool.
Optionally, the connection processing module is built for being attached by connecting object of the following steps to instantiation It is vertical:
If the URL information configuration protocol is http, transmission control protocol TCP is carried out to the connecting object of instantiation Connection;
If the URL information configuration protocol is https/http2, transmission control is carried out to the connecting object of instantiation Agreement TCP connection, and carry out Secure Socket Layer SSL or Transport Layer Security TLS connection.
Optionally, the connection processing module is also used to, after domain name mapping success, if instantiation connecting object loses It loses, then terminates connection and establish;
If carrying out transmission control protocol TCP connection, Secure Socket Layer SSL or transport layer to the connecting object of instantiation to pacify Full TLS connection failure then terminates connection and establishes.
Optionally, the connection processing module is also used to, before established connection is put into the connection pool, For established connection, free time is set;According to the free time, whether the free time length of detection connection reaches setting Threshold value removes the connection if the free time length of connection reaches the given threshold from the connection pool.
The network request method and device that the disclosure provides, by the way that the connection pre-established is stored in connection pool, After obtaining network request, corresponding with URL information included by network request connection is searched in connection pool, finding and After the corresponding connection of URL information included by network request, data directly are initiated to server-side using the connection found and are asked It asks, thus duration required for reducing because establishing connection, to improve network request efficiency.
To enable the above objects, features, and advantages of the disclosure to be clearer and more comprehensible, preferred embodiment is cited below particularly, and cooperate Appended attached drawing, is described in detail below.
Detailed description of the invention
In order to illustrate more clearly of the technical solution of the disclosure, letter will be made to attached drawing needed in the embodiment below It singly introduces, it should be understood that the following drawings illustrates only some embodiments of the disclosure, therefore is not construed as to range It limits, it for those of ordinary skill in the art, without creative efforts, can also be according to these attached drawings Obtain other relevant attached drawings.
Fig. 1 is a kind of application scenarios schematic diagram that the disclosure provides.
Fig. 2 is a kind of flow diagram for network request method that the disclosure provides.
Fig. 3 is a kind of another flow diagram for network request method that the disclosure provides.
Fig. 4 is the flow diagram of network request method in the prior art.
Fig. 5 is a kind of flow diagram for network request method that the disclosure provides.
Fig. 6 is a kind of block diagram for network request device that the disclosure provides.
Icon: 10- client;11- memory;12- processor;13- network module;20- network request device;21- is asked Seek acquisition module;22- request processing module;23- connection processing module.
Specific embodiment
Below in conjunction with attached drawing in the disclosure, the technical solution in the disclosure is clearly and completely described, it is clear that Described embodiment is only disclosure a part of the embodiment, instead of all the embodiments.Usually retouched in attached drawing here The component for the disclosure stated and shown can be arranged and be designed with a variety of different configurations.Therefore, below to mentioning in the accompanying drawings The detailed description of the embodiment of the disclosure of confession is not intended to limit claimed the scope of the present disclosure, but is merely representative of this Disclosed selected embodiment.Based on embodiment of the disclosure, those skilled in the art are in the premise for not making creative work Under every other embodiment obtained, belong to the disclosure protection range.
It should also be noted that similar label and letter indicate similar terms in following attached drawing, therefore, once a certain Xiang Yi It is defined in a attached drawing, does not then need that it is further defined and explained in subsequent attached drawing.
Referring to Fig. 1, being a kind of application scenarios schematic diagram that the disclosure provides.Network request scheme in the disclosure can be with Applied to client 10 shown in FIG. 1, the client 10 and server-side are communicated to connect.As shown in Figure 1, client 10 can wrap It includes: memory 11, processor 12 and network module 13.
The memory 11, processor 12 and network module 13 are directly or indirectly electrically connected between each other, with reality The transmission or interaction of existing data.For example, these elements can be realized between each other by one or more communication bus or signal wire It is electrically connected.At least one is stored in memory 11 to be stored in the storage in the form of software or firmware (firmware) Functional module in device 11, the processor 12 are stored in the function mould of the software in memory 11 or example, in hardware by operation Block, thereby executing various function application and data processing, i.e., the network request side executed in the realization disclosure by client 10 Method.
Wherein, the memory 11 may be, but not limited to, random access memory (Random Access Memory, RAM), read-only memory (Read Only Memory, ROM), programmable read only memory (Programmable Read-Only Memory, PROM), erasable read-only memory (Erasable Programmable Read-Only Memory, EPROM), Electricallyerasable ROM (EEROM) (Electric Erasable Programmable Read-Only Memory, EEPROM), magnetic Disk or solid state hard disk etc..Wherein, memory 11 is for storing program, and the processor 12 executes after receiving and executing instruction Described program.
The processor 12 may be a kind of IC chip, the processing capacity with data.Above-mentioned processor 12 It can be general processor, including central processing unit (Central Processing Unit, CPU), network processing unit (Network Processor, NP) etc..It may be implemented or execute each method, step and the logic diagram in the disclosure.It is general Processor can be microprocessor or the processor is also possible to any conventional processor etc..
Network module 13 is used to establish the communication connection between client 10 and external communications terminals by network, realizes net The transmitting-receiving of network signal and data operates.Above-mentioned network signal may include wireless signal or wire signal.
It is appreciated that structure shown in FIG. 1 is only to illustrate, client 10 may also include than shown in Fig. 1 more or more Few component, or with the configuration different from shown in Fig. 1.Each component shown in Fig. 1 can use hardware, software or its group It closes and realizes.
On the basis of the above, the disclosure also provides a kind of computer readable storage medium, the computer-readable storage medium Matter includes computer program, and client 10 computer program controls the computer readable storage medium when running where is held The following network request method of row.
Fig. 2 is please referred to, the disclosure provides a kind of network request method, and this method can be realized by client 10.Institute The method of stating includes the following steps.
Step S21, obtains network request, includes the uniform resource locator of requested data in the network request URL information.
Uniform resource locator (Uniform Resource Locator, URL) is to can obtain from internet The position of resource and a kind of succinct expression of access method, are the addresses of standard resource on internet.Each of on internet File has a unique URL, and the information that it includes points out how the position of file and browser should handle it.Cause And according to the URL information in network request, the connection of the data to be requested and required foundation can be obtained.
Step S22 judges to whether there is and URL information pair included by the network request in the connection pool pre-established The connection answered.If there is connection corresponding with URL information included by the network request in the connection pool pre-established, Then follow the steps S23.
If company corresponding with URL information included by the network request is not present in the connection pool pre-established It connects, then executes connection establishment step.Connection establishment step includes: to carry out domain name mapping to domain name according to the URL information, in domain After name successfully resolved, connecting object is instantiated.If instantiating connecting object failure, terminate connection building process.If example Change connecting object success, then foundation is attached to the connecting object of instantiation.Wherein, the connecting object of instantiation is connected Connect foundation, comprising: if the URL information configuration protocol is http, biography transport control protocol is carried out to the connecting object of instantiation Discuss TCP connection.If the URL information configuration protocol is https/http2, transmission control is carried out to the connecting object of instantiation Agreement TCP connection processed, and carry out Secure Socket Layer SSL or Transport Layer Security TLS connection.If to the connecting object of instantiation into The connection of row transmission control protocol TCP, Secure Socket Layer SSL or Transport Layer Security TLS connection failure then terminate connection and establish. If carrying out transmission control protocol TCP connection, Secure Socket Layer SSL to the connecting object of instantiation to connect with Transport Layer Security TLS Success then executes the step of carrying out request of data using the established connection.This can be called directly for the ease of next time Connection carries out request of data, which is put into the connection pool.
Step S23 directly initiates request of data to the server-side using the connection.
It is corresponding with URL information included by network request by being stored in the connection pool pre-established in the disclosure Connection, so that client 10 after obtaining network request, is searched and URL information pair included by network request in connection pool The connection answered just be can be used directly and be found after find connection corresponding with URL information included by network request It connects to server-side and initiates request of data, without executing domain name mapping, transmission control protocol (Transmission Control Protocol, TCP) connection, Secure Socket Layer SSL the operation such as connect with Transport Layer Security TLS, reduce because of execution corresponding operating Required duration, to improve network request efficiency.It is corresponding with URL information included by network request not finding It when connection, executes connection and establishes operation, request of data is carried out according to the connection of foundation, and the connection of foundation is put into connection pool In, so that the connection that can be called directly in connection pool carries out request of data when next time obtains same network request, into And promote overall network request response efficiency.
Please refer to Fig. 3, in the disclosure, connection can be put into connection pool by following steps:
Step S31 obtains the URL information of the requested data of network request.
Step S32, judges whether the network library of the client 10 initializes, if the network library no initializtion, just The connection pool of the network library is obtained after the beginningization network library.
Connection pool is the set of storage connection, and the creation of connection pool can directly pass through instantiation connection pool object implementatio8. Network library refers to that client initiates the component of network request.For example, the network library of Java or Android is OkHttp, HttpUrlConnection.The initialization of network library generally refers to: generating the object of network request, and configures to these objects Some business functions, such as log printing, unified head information addition, customized connection function.By initializing network request Object, to operate this network request object, Lai Faqi network request.
Step S33 carries out domain name mapping to domain name according to the URL information, and after domain name mapping success, instantiation connects Connect object.If instantiating connecting object failure, terminate connection building process.If instantiating connecting object success, step is executed Rapid S34.
Step S34 is attached foundation to the connecting object of instantiation.It is built if being attached to the connecting object of instantiation Vertical failure, then terminate connection building process.It is successfully established if being attached to the connecting object of instantiation, thens follow the steps S35.
Wherein, foundation is attached to the connecting object of instantiation, comprising: if the URL information configuration protocol is Http then carries out transmission control protocol TCP connection to the connecting object of instantiation.If the URL information configuration protocol is Https/http2 then carries out transmission control protocol TCP connection to the connecting object of instantiation, and carry out Secure Socket Layer SSL or The TLS connection of person's Transport Layer Security.
Established connection is put into the connection pool by step S35.
In order to ensure the availability respectively connected in connection pool, and ensure that connection pool memory space is enough, optionally, is inciting somebody to action Before established connection is put into the connection pool, can be set for established connection free time, thus root According to the free time, whether the free time length of detection connection reaches given threshold, if the free time length of connection reaches the setting Threshold value then removes the connection from the connection pool.
Wherein it is possible to free time be set by current time, when the recycling thread of connection pool can be according to the free time of connection Between automaticly inspect the free time length of connection, long when being more than setting threshold values when idle, which, which can be connected pond, removes and recycles. Given threshold can be with flexible setting, for example, can be set to four minutes, five minutes, six minutes etc..If in the duration of given threshold Interior connection has not been used, then the connection is removed from connection pool.Mistake occurs during use in addition, connecting if it exists Accidentally, abnormal, unsuccessfully etc. states, the recycling thread removing that can be also connected pond recycle.
In view of actual demand, after monitoring a certain connection in connection pool by use, it can count idle again Duration, to ensure to be used the biggish connection of possibility can persistently exist in connection pool.
In the disclosure, establish connection in advance and be understood that as according to URL information, as protocol+host/ip+port this The information of three, unique definition one connection establish the connection in advance and carry out dns resolution+TCP connection+SSL/TLS in advance Connect three steps.
Wherein, protocol refers to: current URL is which of tri- agreements of http/https/http2.
Host/ip refers to: the domain name or ip of current URL.Such as http://baidu.com/index.html middle finger baidu.com;Http: // 119.29.29.29/d middle finger 119.29.29.29.
Port refers to: the port of current URL/domain name.The port of http agreement default is 80, the port default of https, http2 It is 443, the port of default can write exactly in URL, also can be omitted.When port is other values, need to write exactly in URL, such as Http:// baidu.com:8080/index.html then refers to that current URL request will access 8080 ports.
The disclosure by carrying out dns resolution+three steps of TCP connection+SSL/TLS connection in advance, and being successfully somebody's turn to do The connection of three steps is put into connection pool, is used for subsequent request.According to URL information, i.e. protocol+host/ip+ The information of port three finds matched connection in connection pool and does not need then to carry out the company of building, is directly used in subsequent request.? The various steps that matched connection then carries out creation connection are not found in connection pool.
It is former to the realization of the disclosure now by taking following scenes as an example in order to more clearly illustrate the implementation of the disclosure Reason carries out illustrative examples explanation.
As shown in figure 4, network request method implementation process in the prior art is as follows.
The operation layer of client 10 initializes network library component, and client 10 obtains the network request letter for preparing to initiate request Breath, network library is according to network request information, (requested) target domain name initiated domain name (Domain Name of Xiang Zhiding System, DNS) parsing.Network library according to dns resolution as a result, initiate TCP connection to the server-side in cloud, if it is HTTPS or HTTP2 network request needs additionally to establish SSL (Secure Sockets when then establishing the connection of https/http2 agreement Layer, Secure Socket Layer)/TLS (Transport Layer Security, transport layer security protocol) secure connection.In reality After now connection is established, network library sends 10 request data of client, including request header (Header) and request to server-side again Body (Body).The pending datas transmission success such as network library waits the server-side in cloud to handle data, and returns to cloud data.Network Library receives and reads the cloud data that the server-side in cloud is returned, and returns data to 10 operation layer of client, thus complete It is responded at network request.
In above-mentioned steps, as long as initialization primary network library component, then subsequent network request can share.It establishes The step of network connection, " network library was according to network request information, (requested) target domain name initiated domain name of Xiang Zhiding (Domain Name System, DNS) parsing.Network library according to dns resolution as a result, to the server-side in cloud initiate TCP connection, If it is HTTPS or HTTP2 network request, then need additionally to establish SSL (Secure when establishing the connection of https/http2 agreement SocketsLayer, Secure Socket Layer)/TLS (Transport Layer Security, transport layer security protocol) safely connect Connect " it is unrelated with specific 10 business of client.
It has been investigated that in above-mentioned network request process, dns resolution, TCP connection and SSL/TLS secure connection consumption When occupy the most of the time of network request.It is found for example, carrying out analysis for the back-end data of network request several times, The a length of 466ms of mean time needed for dns resolution, a length of 333ms of mean time needed for TCP connection, needed for SSL/TLS secure connection The a length of 1.04S of mean time, integrally take a long time.
Based on the studies above, in order to reduce the whole time-consuming of network request, if unrelated with specific 10 business of client Initialization network library component, and establish network connection the step of " network library is according to network request the information, (institute of Xiang Zhiding Request) target domain name initiated domain name (Domain Name System, DNS) parsing.Network library according to dns resolution as a result, to The server-side in cloud initiates TCP connection, if it is HTTPS or HTTP2 network request, then establishes the connection of https/http2 agreement When need additionally to establish SSL (Secure Sockets Layer, Secure Socket Layer)/TLS (Transport Layer Security, transport layer security protocol) secure connection " on do optimization processing, it is whole time-consuming that network request can be significantly reduced. Based on this, by initializing network library component in advance in the disclosure, and connection is established in advance, to reduce network request time-consuming.
Please refer to Fig. 5, in the disclosure, network request method passes through following below scheme and realizes: the connection that will be established in advance It is put into connection pool, when 10 subsequent access network of client, then skips dns resolution, TCP connection, SSL/TLS are established, directly It connects and takes out preparatory established connection from connection pool, initiate request of data, and reading service to server-side using the connection The data returned are held, to complete network request response, and then it is time-consuming to greatly reduce request.Using the connection established in advance, It is connected to due to establishing in advance, and then 10 operation layer of client can be reduced in the connection error rate of request stage, into one Step improves network request and responds timeliness, and then promotes user experience.
Wherein, there are many modes for establishing network connection in advance, for example, can be established in advance by OkHttp networking component Network connection, the disclosure to this with no restriction.
In the disclosure, the Establishing process of connection pool is as follows: obtaining requested URL information, which can be by client 10 operation layers configure in advance.If network library no initializtion initializes network library, and obtains the connection pool of the network library, such as Fruit network library is initialized, then directly acquires the connection pool of the network library.According to requested URL information, domain name is carried out Dns resolution, if dns resolution success, instantiates connecting object, if dns resolution is failed, terminate process.To example The connecting object of change carries out TCP connection, if it is https/http2 agreement, then additionally carries out SSL/TLS secure connection, if Failure is established in connection, then terminates process.The free time of connection is set, to allow connection pool according to free time value subsequent The connection can be recycled in period.The connection for the company of having built is put into the connection pool of network library.
On the basis of the above, Fig. 6 is please referred to, the disclosure additionally provides a kind of network request device 20, is applied to visitor Family end 10, the client 10 are communicated to connect with server-side, and the network request device 20 includes that request obtains module 21 and asks Seek processing module 22.
Wherein, request obtains module 21 for obtaining network request, includes requested data in the network request Uniform resource position mark URL information.
The implementation for obtaining module 21 about request can not go to live in the household of one's in-laws on getting married herein refering to the associated description of step S22 in Fig. 2 It states.
Request processing module 22 be used to judge to whether there is in the connection pool that pre-establishes with included by the network request The corresponding connection of URL information, if in the connection pool pre-established exist and URL information included by the network request Corresponding connection then directly initiates request of data to the server-side using the connection.
About request processing module 22 implementation can refering to the associated description of step S22 and step S23 in Fig. 2, Therefore not to repeat here.
Optionally, the network request device 20 further includes connection processing module 23, and the connection processing module 23 is used for Connection is put into connection pool by following steps: obtaining the URL information of the requested data of network request;Judge the client Whether the network library at end 10 initializes, if the network library no initializtion, initializes the network library and obtains the network later The connection pool in library;Domain name mapping is carried out to domain name according to the URL information, after domain name mapping success, instantiation connection pair As;Foundation is attached to the connecting object of instantiation;Established connection is put into the connection pool.
About connection processing module 23 implementation can refering to the associated description of step S31 in Fig. 3 to step S35, Therefore not to repeat here.
Optionally, the connection processing module 23 is also used to be attached by connecting object of the following steps to instantiation It establishes, if the URL information configuration protocol is http, transmission control protocol TCP company is carried out to the connecting object of instantiation It connects;If the URL information configuration protocol is https/http2, transmission control protocol is carried out to the connecting object of instantiation TCP connection, and carry out Secure Socket Layer SSL or Transport Layer Security TLS connection.
Optionally, the connection processing module 23 is also used to, after domain name mapping success, if instantiation connecting object loses It loses, then terminates connection and establish.If to the connecting object of instantiation carry out transmission control protocol TCP connection, Secure Socket Layer SSL or Person's Transport Layer Security TLS connection failure then terminates connection and establishes.
Optionally in the connection processing module 23 is also used to, and established connection is being put into the connection pool Before, is set for established connection free time;According to the free time, whether the free time length of detection connection reaches The connection is removed from the connection pool if the free time length of connection reaches the given threshold to given threshold.
In the disclosure, the realization principle of network request device 20 is similar with the realization principle in aforementioned network requesting method, Corresponding contents can be refering to the description in preceding method, thus therefore not to repeat here.
Network request method and device in the disclosure is being obtained by the way that the connection pre-established to be stored in connection pool After network request, connection corresponding with URL information included by network request is searched in connection pool, is being found and net After the included corresponding connection of URL information of network request, request of data directly is initiated to server-side using the connection found, Thus duration required for reducing because establishing connection, to improve network request efficiency.Using the connection established in advance, by It is connected in establishing in advance, and then client traffic layer can be reduced in the connection error rate of request stage, further mentioned High network request responds timeliness, and the user experience is improved.
In several embodiments provided by the disclosure, it should be understood that disclosed device and method can also pass through Other modes are realized.Device and method embodiment described above is only schematical, for example, the flow chart in attached drawing The device of multiple embodiments according to the disclosure, the system in the cards of method and computer program product are shown with block diagram Framework, function and operation.In this regard, each box in flowchart or block diagram can represent a module, program segment or generation A part of code, a part of the module, section or code include one or more for realizing defined logic function Executable instruction.It should also be noted that function marked in the box can also be in some implementations as replacement Occur different from the sequence marked in attached drawing.For example, two continuous boxes can actually be basically executed in parallel, they Sometimes it can also execute in the opposite order, this depends on the function involved.It is also noted that block diagram and or flow chart In each box and the box in block diagram and or flow chart combination, can function or movement as defined in executing it is special Hardware based device is realized, or can be realized using a combination of dedicated hardware and computer instructions.
In addition, each functional module in each embodiment of the disclosure can integrate one independent portion of formation together Point, it is also possible to modules individualism, an independent part can also be integrated to form with two or more modules.
It, can be with if the function is realized and when sold or used as an independent product in the form of software function module It is stored in a computer readable storage medium.Based on this understanding, the technical solution of the disclosure is substantially in other words The part of the part that contributes to existing technology or the technical solution can be embodied in the form of software products, the meter Calculation machine software product is stored in a storage medium, including some instructions are used so that a computer equipment (can be a People's computer, electronic equipment or network equipment etc.) execute all or part of step of each embodiment the method for the disclosure Suddenly.And storage medium above-mentioned includes: USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), deposits at random The various media that can store program code such as access to memory (RAM, Random Access Memory), magnetic or disk. It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to the packet of nonexcludability Contain, so that the process, method, article or equipment for including a series of elements not only includes those elements, but also including Other elements that are not explicitly listed, or further include for elements inherent to such a process, method, article, or device. In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including the element Process, method, article or equipment in there is also other identical elements.
The foregoing is merely the alternative embodiments of the disclosure, are not limited to the disclosure, for the skill of this field For art personnel, the disclosure can have various modifications and variations.It is all within the spirit and principle of the disclosure, it is made any to repair Change, equivalent replacement, improvement etc., should be included within the protection scope of the disclosure.

Claims (10)

1. a kind of network request method, is applied to client, the client and server-side are communicated to connect, which is characterized in that institute The method of stating includes:
Network request is obtained, includes the uniform resource position mark URL information of requested data in the network request;
Judge in the connection pool pre-established with the presence or absence of connection corresponding with URL information included by the network request;
If there is connection corresponding with URL information included by the network request in the connection pool pre-established, make Request of data directly is initiated to the server-side with the connection.
2. network request method according to claim 1, which is characterized in that connection is put into connection pool by following steps In:
Obtain the URL information of the requested data of network request;
Judge whether the network library of the client initializes, if the network library no initializtion, initializes the network library The connection pool of the network library is obtained later;
Domain name mapping is carried out to domain name according to the URL information, after domain name mapping success, instantiates connecting object;
Foundation is attached to the connecting object of instantiation;
Established connection is put into the connection pool.
3. network request method according to claim 2, which is characterized in that be attached and build to the connecting object of instantiation It is vertical, comprising:
If the URL information configuration protocol is http, transmission control protocol TCP company is carried out to the connecting object of instantiation It connects;
If the URL information configuration protocol is https/http2, transmission control protocol is carried out to the connecting object of instantiation TCP connection, and carry out Secure Socket Layer SSL or Transport Layer Security TLS connection.
4. network request method according to claim 3, which is characterized in that the method also includes:
After domain name mapping success, if instantiation connecting object failure, terminates connection and establishes;
If the connecting object to instantiation carries out transmission control protocol TCP connection, Secure Socket Layer SSL or Transport Layer Security TLS connection failure then terminates connection and establishes.
5. network request method according to claim 2, which is characterized in that the method also includes:
Before established connection is put into the connection pool, is set for established connection free time;
According to the free time, whether the free time length of detection connection reaches given threshold, if the free time length of connection reaches institute Given threshold is stated, then removes the connection from the connection pool.
6. a kind of network request device, is applied to client, the client and server-side are communicated to connect, which is characterized in that institute Stating network request device includes:
Request obtains module, and for obtaining network request, the unified resource including requested data is fixed in the network request Position symbol URL information;
Request processing module, whether there is in the connection pool for judging to pre-establish and URL included by the network request The corresponding connection of information, if existing in the connection pool pre-established corresponding with URL information included by the network request Connection, then using the connection directly to the server-side initiate request of data.
7. network request device according to claim 6, which is characterized in that the network request device further includes junction Module is managed, connection for being put into connection pool by the connection processing module by following steps:
Obtain the URL information of the requested data of network request;
Judge whether the network library of the client initializes, if the network library no initializtion, initializes the network library The connection pool of the network library is obtained later;
Domain name mapping is carried out to domain name according to the URL information, after domain name mapping success, instantiates connecting object;
Foundation is attached to the connecting object of instantiation;
Established connection is put into the connection pool.
8. network request device according to claim 7, which is characterized in that the connection processing module is used for by following Step is attached foundation to the connecting object of instantiation:
If the URL information configuration protocol is http, transmission control protocol TCP company is carried out to the connecting object of instantiation It connects;
If the URL information configuration protocol is https/http2, transmission control protocol is carried out to the connecting object of instantiation TCP connection, and carry out Secure Socket Layer SSL or Transport Layer Security TLS connection.
9. network request device according to claim 8, which is characterized in that the connection processing module is also used to, in domain After name successfully resolved, if instantiation connecting object failure, terminates connection and establishes;
If the connecting object to instantiation carries out transmission control protocol TCP connection, Secure Socket Layer SSL or Transport Layer Security TLS connection failure then terminates connection and establishes.
10. network request device according to claim 7, which is characterized in that the connection processing module is also used to, and is being incited somebody to action Before established connection is put into the connection pool, is set for established connection free time;According to the sky Whether the free time length that connection is detected between idle reaches given threshold, if the free time length of connection reaches the given threshold, The connection is removed from the connection pool.
CN201910061370.9A 2019-01-22 2019-01-22 Network request method and device Pending CN109729176A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910061370.9A CN109729176A (en) 2019-01-22 2019-01-22 Network request method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910061370.9A CN109729176A (en) 2019-01-22 2019-01-22 Network request method and device

Publications (1)

Publication Number Publication Date
CN109729176A true CN109729176A (en) 2019-05-07

Family

ID=66298430

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910061370.9A Pending CN109729176A (en) 2019-01-22 2019-01-22 Network request method and device

Country Status (1)

Country Link
CN (1) CN109729176A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110278271A (en) * 2019-06-24 2019-09-24 厦门美图之家科技有限公司 Network request control method, device and terminal device
CN110430238A (en) * 2019-07-05 2019-11-08 中国平安财产保险股份有限公司 Long connection management method, apparatus, equipment and computer readable storage medium
CN110971703A (en) * 2019-12-11 2020-04-07 腾讯科技(深圳)有限公司 Service request method, device, server and storage medium based on connection pool
CN111343252A (en) * 2020-02-13 2020-06-26 深圳壹账通智能科技有限公司 High-concurrency data transmission method based on http2 protocol and related equipment
CN114629885A (en) * 2021-01-05 2022-06-14 亚信科技(中国)有限公司 Service request processing method and device, electronic equipment and storage medium
CN114650438A (en) * 2020-12-17 2022-06-21 阿里巴巴集团控股有限公司 Video playing data processing method and device and electronic equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101309233A (en) * 2008-06-04 2008-11-19 腾讯科技(深圳)有限公司 Method realizing TCP connection reusing in instant communication
CN104283957A (en) * 2014-10-13 2015-01-14 无锡云捷科技有限公司 CDN cache method based on continuous connectionism
CN105471869A (en) * 2015-11-23 2016-04-06 珠海全志科技股份有限公司 Internet television content request connection reuse method and system thereof

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101309233A (en) * 2008-06-04 2008-11-19 腾讯科技(深圳)有限公司 Method realizing TCP connection reusing in instant communication
CN104283957A (en) * 2014-10-13 2015-01-14 无锡云捷科技有限公司 CDN cache method based on continuous connectionism
CN105471869A (en) * 2015-11-23 2016-04-06 珠海全志科技股份有限公司 Internet television content request connection reuse method and system thereof

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110278271A (en) * 2019-06-24 2019-09-24 厦门美图之家科技有限公司 Network request control method, device and terminal device
CN110430238A (en) * 2019-07-05 2019-11-08 中国平安财产保险股份有限公司 Long connection management method, apparatus, equipment and computer readable storage medium
CN110430238B (en) * 2019-07-05 2023-10-31 中国平安财产保险股份有限公司 Long connection management method, device, equipment and computer readable storage medium
CN110971703A (en) * 2019-12-11 2020-04-07 腾讯科技(深圳)有限公司 Service request method, device, server and storage medium based on connection pool
CN111343252A (en) * 2020-02-13 2020-06-26 深圳壹账通智能科技有限公司 High-concurrency data transmission method based on http2 protocol and related equipment
CN114650438A (en) * 2020-12-17 2022-06-21 阿里巴巴集团控股有限公司 Video playing data processing method and device and electronic equipment
CN114629885A (en) * 2021-01-05 2022-06-14 亚信科技(中国)有限公司 Service request processing method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN109729176A (en) Network request method and device
CN110247784B (en) Method and device for determining network topology structure
CN112416840B (en) Remote mapping method, device, equipment and storage medium for computing resources
CN102420765B (en) Method and device for determining physical link between switchboard and terminal
US11799888B2 (en) Automatic identification of roles and connection anomalies
CN111131037A (en) Data transmission method, device, medium and electronic equipment based on virtual gateway
CN111796858A (en) Method, system and related equipment for access detection of application programs in Kubernetes cluster
US9037912B1 (en) Validation of asset data for component assemblies
Vollmer et al. Autonomic intelligent cyber-sensor to support industrial control network awareness
CN104702564A (en) Tethering user identification method and device
US9641595B2 (en) System management apparatus, system management method, and storage medium
CN109981745A (en) A kind of journal file processing method and server
WO2016114750A1 (en) Data link layer information
CN109561165A (en) Domain name system configuration method and relevant apparatus
CN108712428A (en) A kind of method and device carrying out device type identification to terminal
CN113630418B (en) Network service identification method, device, equipment and medium
CN111901412B (en) Data processing method and computer readable storage medium
CN109788052A (en) A kind of server configuration remote inquiry method, apparatus, terminal and storage medium
US20160191368A1 (en) Information processing device, method, and medium
CN108965403A (en) O&M monitors establishment of connection method and terminal device
US20220174081A1 (en) Monitoring of abnormal host
CN112615831A (en) Vulnerability scanning platform, method, equipment and medium based on industrial internet
US8543861B1 (en) Systems and methods for diagnosing a network configuration of a computing device
CN110620682B (en) Resource information acquisition method and device, storage medium and terminal
US11546235B2 (en) Action based on advertisement indicator in network packet

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20190507

RJ01 Rejection of invention patent application after publication