CN107438097A - Network request processing method and processing device - Google Patents

Network request processing method and processing device Download PDF

Info

Publication number
CN107438097A
CN107438097A CN201710495670.9A CN201710495670A CN107438097A CN 107438097 A CN107438097 A CN 107438097A CN 201710495670 A CN201710495670 A CN 201710495670A CN 107438097 A CN107438097 A CN 107438097A
Authority
CN
China
Prior art keywords
network request
data
framework
general
interface layer
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
CN201710495670.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.)
Beijing 58 Information Technology Co Ltd
Original Assignee
Beijing 58 Information 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 Beijing 58 Information Technology Co Ltd filed Critical Beijing 58 Information Technology Co Ltd
Priority to CN201710495670.9A priority Critical patent/CN107438097A/en
Publication of CN107438097A publication Critical patent/CN107438097A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network-specific arrangements or communication protocols supporting networked applications
    • H04L67/32Network-specific arrangements or communication protocols supporting networked applications for scheduling or organising the servicing of application requests, e.g. requests for application data transmissions involving the analysis and optimisation of the required network resources
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network-specific arrangements or communication protocols supporting networked applications
    • H04L67/34Network-specific arrangements or communication protocols supporting networked applications involving the movement of software or configuration parameters

Abstract

The present invention provides a kind of network request processing method and processing device, and this method includes:When application program needs to send network request, the general-purpose interface layer pre-set is called;According to the calling rule of the general-purpose interface layer defined, according to the network request, it is determined that the network request framework matched with the network request;The calling rule is used to indicate the network request framework matched with each network request;Using the network request framework to destination server request data.Network request processing method and processing device provided by the invention, the decoupling of application program and network request framework can be realized, and then the development efficiency of application program can be improved, while the error rate of the calling logic occurred in process of application development can be reduced.

Description

Network request processing method and processing device
Technical field
The present invention relates to field of terminal, more particularly to a kind of network request processing method and processing device.
Background technology
At present, most of application programs usually require to send network request to the webserver, are taken to realize with network The data exchange of business device.In the prior art, the application program in Android (Android) operating system is applied to need to adjust mostly Network request is sent with network request framework.Above-mentioned network request framework include but is not limited to Scoket network requests framework, HTTP (HyperText Transfer Protocol, HTTP) network request framework etc..
On the one hand, because network request framework often carries out great upgrading in itself, in order to which application program can be preferably adapted to Network request framework after upgrading, developer need to change the method for calling of each network request of application program one by one.Separately On the one hand, it is more multi-functional in order to realize, in the exploitation or maintenance of application program, it is sometimes desirable to change application program and currently adjusted Network request framework, now, developer need to adjust the original calling logic of application program.
It can be seen that being developed using existing mode or during maintenance applications, development efficiency is low, in some instances it may even be possible to calling occurs and patrols Collect the phenomenon of mistake.
The content of the invention
The present invention provides a kind of network request processing method and processing device, for realizing application program and network request framework Decoupling, and then the development efficiency of application program is improved, while reduce the mistake of the calling logic occurred in process of application development Rate by mistake.
In a first aspect, the present invention provides a kind of network request processing method, this method includes:
When application program needs to send network request, the general-purpose interface layer pre-set is called;
According to the calling rule of the general-purpose interface layer defined, according to the network request, it is determined that please with the network Seek the network request framework of matching;The calling rule is used to indicate the network request framework matched with each network request;
Using the network request framework to destination server request data.
In a kind of possible embodiment, the network request includes:The currently requested mesh of the application program Mark the address of server;The calling rule includes:Network request framework corresponding to each communication protocol;
The calling rule according to the general-purpose interface layer defined, according to the network request, it is determined that with the net The network request framework of network request matching, including:
According to the address of the destination server, it is determined that communication protocol corresponding with the network request;
According to the communication protocol and the calling rule, network request framework corresponding to the communication protocol is determined.
It is described to use the network request framework to destination server request data in alternatively possible embodiment Afterwards, methods described also includes:
Data are received using the network request framework;
The general-purpose interface layer is called to carry out data processing to the data received.
In alternatively possible embodiment, described when application program needs to send network request, calling is set in advance The general-purpose interface layer put, including:
When the application program needs to send network request, the first thread of the general-purpose interface layer is called;
It is described to call the general-purpose interface layer to carry out data processing to the data received, including:
Call whether the data received described in the second thread determination of the general-purpose interface layer are asked data.
In alternatively possible embodiment, connect in described call described in the second thread determination of the general-purpose interface layer It is described to call the general-purpose interface layer to carry out data to the data received after whether the data received are asked data Processing, in addition to:
The data received for asked data when, call the first thread to the data received Carry out logic of propositions to handle to obtain the data after logical process, and the data after the logical process are sent to described and apply journey The main thread of sequence carries out display processing.
In alternatively possible embodiment, also include in the network request:The display format for the data asked;
Before the calling first thread carries out logic of propositions processing to the data received, the calling institute State general-purpose interface layer and data processing is carried out to the data received, in addition to:
The data received for asked data when, second thread is called, according to the data asked Display format, the data received are entered row format conversion.
In alternatively possible embodiment, connect in described call described in the second thread determination of the general-purpose interface layer It is described to call the general-purpose interface layer to carry out data to the data received after whether the data received are asked data Processing, in addition to:
When the data received are not asked data, the first thread is called, according to default mistake Processing strategy, error handle is carried out to the data received, obtains error handle result;The default error handle plan Slightly include:The corresponding relation of the data received and the error handle result;
The main thread that the error handle result is sent to the application program carries out display processing.
In alternatively possible embodiment, after the network request framework is updated, the determination and the net The network request framework of network request matching, including:
According to the calling rule of the general-purpose interface layer defined, according to the network request, it is determined that please with the network Seek the network request framework after the renewal of matching.
Second aspect, the present invention provide a kind of network request processing unit, and the device includes:
Calling module, for when application program needs to send network request, calling the general-purpose interface layer pre-set;
Determining module, for the calling rule according to the general-purpose interface layer defined, according to the network request, it is determined that The network request framework matched with the network request;The calling rule is used to indicate the network matched with each network request Ask framework;
Request module, for using the network request framework to destination server request data.
In a kind of possible embodiment, the network request includes:The currently requested mesh of the application program Mark the address of server;The calling rule includes:Network request framework corresponding to each communication protocol;
The determining module, specifically for the address according to the destination server, it is determined that corresponding with the network request Communication protocol, and according to the communication protocol and the calling rule, determine network request frame corresponding to the communication protocol Frame.
In alternatively possible embodiment, described device also includes:
Receiving module, for the request module using the network request framework to destination server request data it Afterwards, data are received using the network request framework;
The calling module, it is additionally operable to call the general-purpose interface layer to carry out data processing to the data received.
In alternatively possible embodiment, the calling module, specifically for needing to send in the application program During network request, the first thread of the general-purpose interface layer is called;Call described in the second thread determination of the general-purpose interface layer Whether the data received are asked data.
In alternatively possible embodiment, the calling module, specifically for calling the general-purpose interface described Second thread of layer determine described in after whether the data that receive be asked data, be institute in the data received During the data of request, call the first thread to carry out logic of propositions to the data received and handle after obtaining logical process Data, and by the data after the logical process send to the application program main thread carry out display processing.
In alternatively possible embodiment, also include in the network request:The display format for the data asked;
The calling module, specifically for calling the first thread to carry out at logic of propositions the data received Before reason, the data received for asked data when, second thread is called, according to the data asked Display format, the data received are entered with row format conversion.
In alternatively possible embodiment, the calling module, specifically for calling the general-purpose interface described Second thread of layer determine described in after whether the data that receive be asked data, be not in the data received During the data asked, the first thread is called, according to default error handle strategy, the data received are carried out Error handle, error handle result is obtained, and the error handle result is sent to the main thread progress of the application program Display processing;The default error handle strategy includes:The data received are corresponding with the error handle result Relation.
In alternatively possible embodiment, the determining module, be additionally operable to update the network request framework it Afterwards, according to the calling rule of the general-purpose interface layer defined, according to the network request, it is determined that being matched with the network request Renewal after network request framework.
Network request processing method and processing device provided by the invention, it is located at application program and network by pre-setting one Ask the general-purpose interface layer between framework, it is possible to achieve application program and the decoupling of network request framework, to cause developer In development and application program, it is only necessary to by the point of invocation of all calling network request frameworks of application program and the general-purpose interface layer Calling interface establish call relation, without being that application program has constrained network request corresponding to each network request again Framework.Even if the upgrading of network request framework or used network request framework are switched used in application program, Developer is without the method for calling according to the network request framework after upgrading or new network request framework, in application program The point of invocation of network request framework is called to be called the modification of mode, or, original logic of application program is adjusted, is improved The development efficiency of application program, while reduce the error rate of the calling logic occurred in process of application development, it is ensured that The stability and reliability of application program.
Brief description of the drawings
In order to illustrate more clearly about the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing There is the required accompanying drawing used in technology description to be briefly described, it should be apparent that, drawings in the following description are this hairs Some bright embodiments, for those of ordinary skill in the art, without having to pay creative labor, can be with Other accompanying drawings are obtained according to these accompanying drawings.
Fig. 1 is a kind of Organization Chart of terminal device provided by the invention;
Fig. 2 is a kind of schematic flow sheet of network request processing method provided by the invention;
Fig. 3 is a kind of schematic flow sheet of the data processing method based on network request provided by the invention;
Fig. 4 is a kind of structural representation of network request processing unit provided by the invention;
Fig. 5 is the structural representation of another network request processing unit provided by the invention.
Embodiment
To make the purpose, technical scheme and advantage of the embodiment of the present invention clearer, below in conjunction with the embodiment of the present invention In accompanying drawing, the technical scheme in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is Part of the embodiment of the present invention, rather than whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art The every other embodiment obtained under the premise of creative work is not made, belongs to the scope of protection of the invention.
In the prior art, the application program in Android operation system is applied to need to call network request framework to send out mostly SCN Space Cable Network is asked.Wherein, when using the difference in functionality of application program, application program is sent leads to user used in network request Believe that agreement is different.Because different communication protocol corresponds to different network request frameworks, therefore, Application developer is opening Send out application program when, can it is each calling network request framework point of invocation, according to the point of invocation send network request when it is required The network request framework used, call relation is established for the point of invocation and the network request framework.
For better performance and experience, developer can often upgrade to network request framework.Meanwhile on the market Also new network request framework is had to occur.Therefore, updating the network request framework after upgrading or switching new network request During framework, Application developer needs the called side according to the network request framework after upgrading or new network request framework Formula, the modification of mode is called in the point of invocation of application call network request framework, or, adjust the original of application program There is logic so that the development efficiency of application program is relatively low, the phenomenon of calling logic mistake possibly even occurs.
Fig. 1 is a kind of Organization Chart of terminal device provided by the invention.As shown in figure 1, network request provided by the invention Processing method, by pre-setting a general-purpose interface layer between application program and network request framework, it is possible to achieve Application program and the decoupling of network request framework.Specifically:
As shown in figure 1, the above-mentioned general-purpose interface layer pre-set can have call relation with multiple network request frameworks. Therefore, in the present embodiment, developer is in development and application program, no longer by the calling network request framework of application program Point of invocation establishes call relation with a certain network request framework.I.e. developer's development and application program when, no longer be application The program restriction well network request framework corresponding to each network request, but by all calling network request frames of application program The calling interface of the point of invocation of frame and the general-purpose interface layer establishes call relation, to realize application program and network request framework Decoupling.So, even if used in application program network request framework upgrading or used network request framework there occurs Switching, developer only need to adjust general-purpose interface layer and the network request framework or the tune of new network request framework after upgrading With mode, without the method for calling further according to the network request framework after upgrading or new network request framework, applying The point of invocation of routine call network request framework is called the modification of mode, or, original logic of application program is adjusted, is carried The high development efficiency of application program, while the error rate of the calling logic occurred in process of application development is reduced, really The stability and reliability of application program are protected.During specific implementation, above-mentioned general-purpose interface layer can use any communication protocol Occupation mode realizes, such as:Above-mentioned network request framework interface layer can use occupation mode realization of http protocol etc..
Technical scheme is described in detail with specifically embodiment below.These specific implementations below Example can be combined with each other, and may be repeated no more for same or analogous concept or process in some embodiments.
Fig. 2 is a kind of schematic flow sheet of network request processing method provided by the invention.The executive agent of this method can Think network request processing unit, can also be the terminal device for being integrated with network request processing unit, it is following with executive agent To be integrated with the terminal device of network request processing unit (referred to as:Terminal device) exemplified by illustrate, this implementation refers to How terminal device selects network request framework to carry out the process of request of data after the network request of application program is received. As shown in Fig. 2 this method can include:
S101, application program need send network request when, call the general-purpose interface layer pre-set.
Specifically, during terminal device runs application program, i.e. user using during application program, if When user triggers application program progress network request, then terminal device can call the general-purpose interface layer pre-set.Such as:With Family is when 58 installed in using terminal equipment are with city application program, if user needs to search for a certain second-hand article, user Application program can be triggered and carry out network request, with from network request information corresponding with the second-hand article.Now, terminal device The general-purpose interface layer pre-set can be called.
S102, the calling rule according to general-purpose interface layer defined, according to network request, it is determined that matched with network request Network request framework, wherein, the calling rule is used to indicate the network request framework matched with each network request.
Optionally, above-mentioned calling rule can include:The corresponding relation of each network request and network request framework.Cause This, above-mentioned terminal device can be needed to send network request according to application program, and the network request pair is searched in calling rule The network request framework answered, to determine the network request framework matched with network request.
Optionally, above-mentioned calling rule can include:Network request framework corresponding to each communication protocol.Correspondingly, on Stating in network request to include:The address of the currently requested destination server of application program.Due to the ground of destination server Location carries communication protocol, and therefore, above-mentioned terminal device can need to send the mesh carried in network request according to application program The address of server is marked, it is determined that communication protocol corresponding with the network request.Then, terminal device can according to communication protocol and Calling rule, determine network request framework corresponding to communication protocol.That is, terminal device can search the communication in calling rule Network request framework corresponding to agreement, to determine the network request framework matched with network request.
With the address http of the destination server included by network request:Exemplified by //xa.58.com/, then the destination service HTTP in the address of device is communication protocol used in the network request.Therefore, above-mentioned terminal device can be according to the mesh The address of server is marked, it is HTTP to determine communication protocol used in network request.Then, terminal device can according to HTTP, Determine network request framework corresponding to HTTP.
It should be noted that when developer is according to the updated contents of network request framework, above-mentioned network request is matched Network request framework updated, that is, adjust general-purpose interface layer with upgrading after network request framework method of calling after, Above-mentioned terminal device can be that network request determines more according to network request according to the calling rule of general-purpose interface layer defined Network request framework after new.Or when developer is that above-mentioned network request is provided with new network request framework, it is above-mentioned Developer can adjust above-mentioned calling rule after call relation of the general-purpose interface layer with the new network request framework is established Then, it is that network request is true according to network request to cause calling rule of the above-mentioned terminal device according to general-purpose interface layer defined Fixed is the network request framework (i.e. new network request framework) after renewal.
By the above-mentioned means, on the basis of renewal network request framework or newly-increased network request framework is realized, exploit person Member does not have to the method for calling further according to the network request framework after upgrading or new network request framework, in application call net The point of invocation of network request framework is called the modification of mode, or, original logic of application program is adjusted, is improved using journey The development efficiency of sequence, while reduce the error rate of the calling logic occurred in process of application development, it is ensured that using journey The stability and reliability of sequence.
S103, using network request framework to destination server request data.
Specifically, above-mentioned terminal device, it is determined that after the network request framework matched with network request, can use should Network request framework carries out network interaction, with to destination server request data.Wherein, how terminal device please using the network Ask framework to be interacted with network, may refer to prior art to destination server request data, this is repeated no more.
Network request processing method provided by the invention, by pre-setting one positioned at application program and network request frame General-purpose interface layer between frame, it is possible to achieve application program and the decoupling of network request framework, to cause developer developing During application program, it is only necessary to by the calling of the point of invocation of all calling network request frameworks of application program and the general-purpose interface layer Interface establishes call relation, without having constrained the network request framework corresponding to each network request for application program again. Even if the upgrading of network request framework or used network request framework are switched used in application program, exploit person Member is without the method for calling according to the network request framework after upgrading or new network request framework, in application call net The point of invocation of network request framework is called the modification of mode, or, original logic of application program is adjusted, is improved using journey The development efficiency of sequence, while reduce the error rate of the calling logic occurred in process of application development, it is ensured that using journey The stability and reliability of sequence.
Fig. 3 is a kind of schematic flow sheet of the data processing method based on network request provided by the invention.The present embodiment Refer to above-mentioned terminal device and general-purpose interface layer to after destination server request data, is being called using network request framework The data received are carried out with the process of data processing.As shown in figure 3, after above-mentioned S103, this method can also include:
S201, using network request framework receive data.
Specifically, above-mentioned terminal device, to after destination server request data, can be adopted using network request framework Data are received with corresponding network request framework.Wherein, how terminal device can using network request framework reception data Referring to prior art, to be repeated no more to this.
S202, general-purpose interface layer is called to carry out data processing to the data received.
Specifically, in the present embodiment, terminal device can call the thread of general-purpose interface layer to enter the data received Row data processing, data processing mentioned here can for example include:Judgement processing, logical process, error handle.Judgement is handled For judging whether received data are asked data.Logical process is used in received data to be asked Data when, to data carry out display logic processing, with meet display require.Error handle is used in received data not When being asked data, error handle is carried out to data, so that error result can be known by obtaining user.
Therefore, developer can not have to write above-mentioned be used at data in the application in development and application program The code of reason, the development efficiency of application program is further increased, reduces development cost.During specific implementation, it can use and ring Answer formula to program such as RxJava (response type programming framework) mode, judgement processing is packaged for, at logic in general-purpose interface layer Reason, the code of error handle so that terminal device can be directly realized by by general-purpose interface layer and call network request framework sum According to the function of processing, so that the processing of network request is more convenient and coherent, and then the processing effect of network request is improved Rate.
Wherein, above-mentioned general-purpose interface layer can pass through data processing of the thread to received data, the thread It can be the thread for handling network request, can also be other threads.Above-mentioned general-purpose interface layer can also be by different Data processing of the thread to received data.
In the present embodiment, can be that above-mentioned general-purpose interface layer creates first thread and the second thread, it is above-mentioned to realize Terminal device calls general-purpose interface layer to carry out data processing to the data received.Wherein, first thread can be used for handling and answer With the network request of program, i.e., when application program needs to send network request, terminal device calls the first of general-purpose interface layer Thread is handled.Second thread can be used for carrying out data processing or handle network request.In this manner it is achieved that network request Operation and the asynchronous process of network request processing operation, are respectively adopted different threads and carry out network request or data processing, enter One step realizes the decoupling of network request and data processing, while improves processing speed when terminal device carries out network interaction Degree.
For example, after data are received using network request framework, terminal device can call general-purpose interface layer The second thread judgement processing is carried out to received data, to determine whether received data are asked number According to.Due to handling network request, and, judge that processing can all take the substantial amounts of time, therefore, above two operation is given not The mode of same thread process, can improve processing speed.
It should be noted that in the present embodiment, the data that above-mentioned terminal device is received using network request framework can Think asked data, can also be wrong data or abnormal data.For example, when above-mentioned terminal device and network connection are normal (i.e. network request can be sent to destination server by terminal device using network request framework) and destination server is in just During normal working condition (server can carry out correctly handling to network request), above-mentioned terminal device uses network request frame The data that bridge joint receives are asked data.However, when above-mentioned terminal device, normally (i.e. terminal device is adopted with network connection Network request can be sent to destination server with network request framework) but destination server be in abnormal operating state When (abnormal or mistake being present in processing of the server to network request), above-mentioned terminal device is received using network request framework Data be indicated for the data (i.e. wrong data) of server mistake, rather than the data asked;Or when above-mentioned end When end equipment is with network connection failure, i.e., above-mentioned terminal device can not use network request framework, and network request is sent into mesh When marking server, the data that above-mentioned terminal device is received using network request framework are indicated for the data of Network Abnormal (i.e. abnormal data), rather than the data asked.In the present embodiment, terminal device can call the second of general-purpose interface layer Thread carries out above-mentioned judgement processing to received data, to determine whether received data are asked data.
Further, above-mentioned first thread can also carry out logical process.That is, terminal device is calling general-purpose interface layer After the data that second thread determines the data that receive to be asked, first thread can be sent the data to, to cause Terminal device can call first thread to carry out logic of propositions processing to the data received, obtain the data after logical process, And the main thread for sending the data after logical process to application program directly carries out display processing.In this way so that User can view asked data by the interface of application program.
Optionally, in certain embodiments, received data for asked data when, above-mentioned second thread is also Row format conversion can be entered to received data according to the display format carried in network request.Therefore, if above-mentioned network Also include in request:The display format for the data asked, such as can be table format, picture format etc., then above-mentioned terminal Equipment may call upon the second thread before calling first thread to carry out logic of propositions processing to the data received, according to The display format for the data asked, the data received are entered with row format conversion.In this way so that application program institute The data of display can be the display format seen desired by user.
So, in the present embodiment, terminal device can be by calling the first thread and second of general-purpose interface layer in turn The mode of thread, the operation such as network request and data processing is performed respectively, furthermore achieved that network request and data processing Asynchronous process.
Again for example, after data are received using network request framework, terminal device can call general-purpose interface Second thread of layer carries out judgement processing to received data, to determine whether received data are asked number According to.Further above-mentioned first thread can also carry out error handle.That is, terminal device is calling the second line of general-purpose interface layer After journey determines that the data that receive are not asked data, first thread can be sent the data to, to cause terminal Equipment can call first thread to carry out error handle according to default error handle strategy to the data received, obtain mistake Result by mistake, and then the main thread that error handle result is sent to application program carries out display processing.
Wherein, above-mentioned default error handle strategy includes:The corresponding relation of the data received and error handle result. Such as:When received data are indicated for data (i.e. the wrong data) of server mistake, above-mentioned error handle knot Fruit for example can be " server mistake ".When received data are indicated for data (the i.e. abnormal number of Network Abnormal According to), above-mentioned error handle result is such as can be " network connection is abnormal ".In this way so that user passes through application Error handle result shown by program knows current mistake, and then make it that whether user can need to resend net with decision-making Network is asked, and improves Consumer's Experience.
So, in the present embodiment, terminal device can be by calling the first thread and second of general-purpose interface layer in turn The mode of thread, the operation such as network request and data processing is performed respectively, furthermore achieved that network request and data processing Asynchronous process.It can be seen that network request processing method provided by the invention and the data processing method based on network request, by pre- One general-purpose interface layer between application program and network request framework is first set, is realizing application program and network request Can also be that general-purpose interface layer increases data processing function, make it that it is general that terminal device passes through on the basis of the decoupling of framework Interface layer, which can be directly realized by, calls network request framework and data processing so that the processing of network request it is more convenient and It is coherent, and then realize the asynchronous process of network request and data processing.Meanwhile developer is without again in the application The above-mentioned code for data processing is write, the development efficiency of application program is further increased, reduces development cost.
One of ordinary skill in the art will appreciate that:Realizing all or part of step of above-mentioned each method embodiment can lead to The related hardware of programmed instruction is crossed to complete.Foregoing program can be stored in a computer read/write memory medium.The journey Sequence upon execution, execution the step of including above-mentioned each method embodiment;And foregoing storage medium includes:ROM, RAM, magnetic disc or Person's CD etc. is various can be with the medium of store program codes.
Fig. 4 is a kind of structural representation of network request processing unit provided by the invention.Fig. 4 is referred to, the network please Processing unit is asked to include obtaining calling module 11, determining module 12 and request module 13.Wherein,
Calling module 11, for when application program needs to send network request, calling the general-purpose interface layer pre-set;
Determining module 12, for the calling rule according to general-purpose interface layer defined, according to network request, it is determined that and network The network request framework of matching is asked, wherein, calling rule is used to indicate the network request framework matched with each network request;
Request module 13, for using network request framework to destination server request data.
In certain embodiments, above-mentioned network request includes the ground of the currently requested destination server of application program Location, above-mentioned calling rule include network request framework corresponding to each communication protocol, then above-mentioned determining module 12, can specifically be used In the address according to destination server, it is determined that communication protocol corresponding with network request, and according to communication protocol and calling rule, Determine network request framework corresponding to communication protocol.
In certain embodiments, above-mentioned determining module 12, it is additionally operable to after network request framework is updated, is connect according to general The calling rule of mouth layer defined, according to network request, it is determined that the network request framework after the renewal matched with network request.
Network request processing unit provided by the invention can be used for performing above-mentioned shown embodiment of the method, and it realizes former Reason and beneficial effect are similar, are no longer repeated herein.
Fig. 5 is the structural representation of another network request processing unit provided by the invention.In the frame shown in above-mentioned Fig. 4 On the basis of figure, said apparatus can also include:Receiving module 14.Wherein,
Receiving module 14, in request module 13 using network request framework to after destination server request data, Data are received using network request framework;
Calling module 11, it is additionally operable to call general-purpose interface layer to carry out data processing to the data received.
Optionally, calling module 11, specifically for when application program needs to send network request, calling general-purpose interface layer First thread;Whether the data for calling the second thread of general-purpose interface layer to determine to receive are asked data.
Optionally, above-mentioned calling module 11, specifically for calling the second thread of general-purpose interface layer to determine what is received After whether data are asked data, the data received for asked data when, call first thread to receiving To data carry out the data after logic of propositions handles to obtain logical process, and the data after logical process are sent to using journey The main thread of sequence carries out display processing.
Optionally, when also including the display format of asked data in above-mentioned network request, above-mentioned calling module 11, Before carrying out logic of propositions processing to the data received specifically for calling first thread, in the data received to be asked Data when, call the second thread, according to the display format for the data asked, the data received entered with row format conversion.
Optionally, above-mentioned calling module 11, specifically for calling the second thread of general-purpose interface layer to determine what is received After whether data are asked data, when the data received are not asked data, first thread is called, according to Default error handle strategy, error handle is carried out to the data that receive, obtain error handle result, and by error handle knot Fruit sends to the main thread of application program and carries out display processing;Default error handle strategy includes:The data received and mistake The corresponding relation of result by mistake.
Network request processing unit provided by the invention can be used for performing above-mentioned shown embodiment of the method, and it realizes former Reason and beneficial effect are similar, are no longer repeated herein.
Finally it should be noted that:Various embodiments above is merely illustrative of the technical solution of the present invention, rather than its limitations;To the greatest extent The present invention is described in detail with reference to foregoing embodiments for pipe, it will be understood by those within the art that:Its according to The technical scheme described in foregoing embodiments can so be modified, either which part or all technical characteristic are entered Row equivalent substitution;And these modifications or replacement, the essence of appropriate technical solution is departed from various embodiments of the present invention technology The scope of scheme.

Claims (9)

1. a kind of network request processing method, it is characterised in that methods described includes:
When application program needs to send network request, the general-purpose interface layer pre-set is called;
According to the calling rule of the general-purpose interface layer defined, according to the network request, it is determined that with the network request The network request framework matched somebody with somebody;The calling rule is used to indicate the network request framework matched with each network request;
Using the network request framework to destination server request data.
2. according to the method for claim 1, it is characterised in that the network request includes:The application program is current The address for the destination server asked;The calling rule includes:Network request framework corresponding to each communication protocol;
The calling rule according to the general-purpose interface layer defined, according to the network request, it is determined that please with the network The network request framework of matching is sought, including:
According to the address of the destination server, it is determined that communication protocol corresponding with the network request;
According to the communication protocol and the calling rule, network request framework corresponding to the communication protocol is determined.
3. according to the method for claim 1, it is characterised in that described to use the network request framework to destination server After request data, methods described also includes:
Data are received using the network request framework;
The general-purpose interface layer is called to carry out data processing to the data received.
4. according to the method for claim 3, it is characterised in that it is described when application program needs to send network request, adjust With the general-purpose interface layer pre-set, including:
When the application program needs to send network request, the first thread of the general-purpose interface layer is called;
It is described to call the general-purpose interface layer to carry out data processing to the data received, including:
Call whether the data received described in the second thread determination of the general-purpose interface layer are asked data.
5. according to the method for claim 4, it is characterised in that true in second thread for calling the general-purpose interface layer It is described to call the general-purpose interface layer to the data that receive after whether the data received are asked data Data processing is carried out, in addition to:
The data received for asked data when, call the first thread to carry out the data that receive Logic of propositions is handled to obtain the data after logical process, and the data after the logical process are sent to the application program Main thread carries out display processing.
6. according to the method for claim 5, it is characterised in that also include in the network request:The data asked Display format;
It is described to call described lead to before the calling first thread carries out logic of propositions processing to the data received Data processing is carried out to the data received with interface layer, in addition to:
The data received for asked data when, second thread is called, according to the aobvious of the data asked Show form, the data received are entered with row format conversion.
7. according to the method for claim 4, it is characterised in that true in second thread for calling the general-purpose interface layer It is described to call the general-purpose interface layer to the data that receive after whether the data received are asked data Data processing is carried out, in addition to:
When the data received are not asked data, the first thread is called, according to default error handle Strategy, error handle is carried out to the data received, obtains error handle result;The default error handle strategy bag Include:The corresponding relation of the data received and the error handle result;
The main thread that the error handle result is sent to the application program carries out display processing.
8. according to the method described in claim 1-7, it is characterised in that described true after the network request framework is updated The fixed network request framework matched with the network request, including:
According to the calling rule of the general-purpose interface layer defined, according to the network request, it is determined that with the network request Network request framework after the renewal matched somebody with somebody.
9. a kind of network request processing unit, it is characterised in that described device includes:
Calling module, for when application program needs to send network request, calling the general-purpose interface layer pre-set;
Determining module, for the calling rule according to the general-purpose interface layer defined, according to the network request, it is determined that and institute State the network request framework of network request matching;The calling rule is used to indicate the network request matched with each network request Framework;
Request module, for using the network request framework to destination server request data.
CN201710495670.9A 2017-06-26 2017-06-26 Network request processing method and processing device Pending CN107438097A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710495670.9A CN107438097A (en) 2017-06-26 2017-06-26 Network request processing method and processing device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710495670.9A CN107438097A (en) 2017-06-26 2017-06-26 Network request processing method and processing device

Publications (1)

Publication Number Publication Date
CN107438097A true CN107438097A (en) 2017-12-05

Family

ID=60458610

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710495670.9A Pending CN107438097A (en) 2017-06-26 2017-06-26 Network request processing method and processing device

Country Status (1)

Country Link
CN (1) CN107438097A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108040126A (en) * 2017-12-29 2018-05-15 贵阳语玩科技有限公司 Initiate the method and device of HTTP request
CN108848127A (en) * 2018-05-23 2018-11-20 北京五八信息技术有限公司 Data transmission method, device, computer equipment and computer readable storage medium
CN110099122A (en) * 2019-05-07 2019-08-06 北京字节跳动网络技术有限公司 Method and apparatus for sending network request

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1744498A (en) * 2004-08-31 2006-03-08 华为技术有限公司 Network server and data interacting method for network server and browser
US20070019772A1 (en) * 2003-01-17 2007-01-25 Applied Micro Circuits Corporation Timeshared jitter attenuator in multi-channel mapping applications
CN101765817A (en) * 2007-07-26 2010-06-30 乔治洛德方法研究和开发液化空气有限公司 Programmable logic controller protocol converter
CN101923465A (en) * 2010-06-25 2010-12-22 深圳创维-Rgb电子有限公司 Embedded application-oriented scalable web service system
CN103605525A (en) * 2013-11-29 2014-02-26 深圳市中兴移动通信有限公司 Achievement method and device of desktop application program
CN106357704A (en) * 2015-07-13 2017-01-25 阿里巴巴集团控股有限公司 Method and device for invoking service on basis of development environments

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070019772A1 (en) * 2003-01-17 2007-01-25 Applied Micro Circuits Corporation Timeshared jitter attenuator in multi-channel mapping applications
CN1744498A (en) * 2004-08-31 2006-03-08 华为技术有限公司 Network server and data interacting method for network server and browser
CN101765817A (en) * 2007-07-26 2010-06-30 乔治洛德方法研究和开发液化空气有限公司 Programmable logic controller protocol converter
CN101923465A (en) * 2010-06-25 2010-12-22 深圳创维-Rgb电子有限公司 Embedded application-oriented scalable web service system
CN103605525A (en) * 2013-11-29 2014-02-26 深圳市中兴移动通信有限公司 Achievement method and device of desktop application program
CN106357704A (en) * 2015-07-13 2017-01-25 阿里巴巴集团控股有限公司 Method and device for invoking service on basis of development environments

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108040126A (en) * 2017-12-29 2018-05-15 贵阳语玩科技有限公司 Initiate the method and device of HTTP request
CN108040126B (en) * 2017-12-29 2021-07-16 贵阳语玩科技有限公司 Method and device for initiating HTTP request
CN108848127A (en) * 2018-05-23 2018-11-20 北京五八信息技术有限公司 Data transmission method, device, computer equipment and computer readable storage medium
CN110099122A (en) * 2019-05-07 2019-08-06 北京字节跳动网络技术有限公司 Method and apparatus for sending network request
CN110099122B (en) * 2019-05-07 2020-05-15 北京字节跳动网络技术有限公司 Method and apparatus for sending network request

Similar Documents

Publication Publication Date Title
CN107438097A (en) Network request processing method and processing device
CN103841134B (en) Based on API transmission, the method for receive information, apparatus and system
US7065565B2 (en) System and method for policy-enabled, contract-based management of network operational support systems
US8914804B2 (en) Handling queues associated with web services of business processes
US20180097660A1 (en) Public cloud interface for tranceiving corresponding requests and responses to multiple networks
US10958524B2 (en) Method for generating network slice template and for applying network slice template, and apparatus
CN112771500A (en) Function as a service gateway
CN105072139A (en) Recommendation method and recommendation device
US20120317039A1 (en) On-demand purchase of virtual image licenses in a cloud computing environment
US20200257776A1 (en) Request authorization using recipe-based service coordination
US20110055318A1 (en) Thin client system with round trip reduction using client side code generation
CN107666401A (en) A kind of configuration information obtaining method and terminal
CN110620754B (en) NF (NF) required resource deployment method and device, storage medium and electronic device
CN111045940A (en) Software automation test method, device, architecture, server and storage medium
CN111177112A (en) Database blocking method and device based on operation and maintenance management system and electronic equipment
CN110011875A (en) Dial testing method, device, equipment and computer readable storage medium
KR102123750B1 (en) Network Service Request
CN107391630B (en) Method and device for processing parallel network requests and terminal equipment
CN109729040A (en) Method, equipment and the computer-readable medium of the selection of agreement
CN107329819A (en) A kind of job management method and device
CN109196484A (en) Flexibly optimize data processing in the system with multiple memories
CN106982237A (en) Transaction methods and system
CN106603604A (en) Method and device of triggering transaction processing motion
CN102098660A (en) System for automatically adapting local program of mobile client based on server
CN108259527B (en) Proxy-based service processing method and device and network element equipment

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