CN103685331A - Information processing method and server - Google Patents
Information processing method and server Download PDFInfo
- Publication number
- CN103685331A CN103685331A CN201210318759.5A CN201210318759A CN103685331A CN 103685331 A CN103685331 A CN 103685331A CN 201210318759 A CN201210318759 A CN 201210318759A CN 103685331 A CN103685331 A CN 103685331A
- Authority
- CN
- China
- Prior art keywords
- http
- post
- return code
- request
- described post
- 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
Links
Images
Landscapes
- Information Transfer Between Computers (AREA)
Abstract
The invention discloses an information processing method and server and belongs to the technical field of computer networks. The method comprises the followings: when an HTTP (Hyper Text Transport Protocol) request is received, whether the HTTP request is a post request or not is determined; when the HTTP request is the post request, an HTTP return code corresponding to the POST request is obtained; the POST request is transmitted according to the HTTP return code. Routing transfer to the POST request can be achieved.
Description
Technical field
The present invention relates to technical field of the computer network, particularly a kind of method of information processing and server.
Background technology
HTTP((HyperText Transfer Protocol, HTML (Hypertext Markup Language)) be the application layer protocol towards things, based on this http protocol, between user side and the webserver, can exchange reliably files such as text, sound or image.Particularly, user side can obtain by the GET(in http protocol) ask from the webserver, to obtain data, by the POST(in http protocol, deliver) ask to transmit data to the webserver.
Nginx server is a kind of Web(webpage of lightweight) proxy server, there is stronger concurrent processing ability, and routing function can be provided.In prior art, Nginx server, after receiving GET request, can be forwarded to the corresponding webserver by the GET request receiving according to the parameter in GET request, to obtain data from the described webserver.But in prior art, Nginx server the unrealized route forwarding function to POST request.
Summary of the invention
In order to solve the problem of prior art, the embodiment of the present invention provides a kind of method and server of information processing.Described technical scheme is as follows:
On the one hand, provide a kind of method of information processing, described method comprises:
When receiving HTML (Hypertext Markup Language) HTTP request, determine whether described HTTP request is to deliver POST request;
When described HTTP request is described POST request, obtains with described POST and ask corresponding HTTP return code;
According to described HTTP return code, forward described POST request.
Described obtaining with described POST asked corresponding HTTP return code, comprising:
Obtain described POST and ask entrained POST parameter;
According to described POST parameter acquiring, ask corresponding HTTP return code with described POST.
Describedly according to described POST parameter acquiring, ask corresponding HTTP return code to comprise with described POST:
According to the route area list of the local storage of described POST parameter query, determine that described POST parameter is whether in described route area list;
When described POST parameter is in described route area list, determine that the HTTP return code corresponding with described POST parameter is the first predetermined value;
When described POST parameter is not in described route area list, determine that the HTTP return code corresponding with described POST parameter is the second predetermined value.
Describedly according to described HTTP return code, forward described POST request and comprise:
Described POST request is transmitted to server corresponding to described HTTP return code.
Described HTTP return code is off-gauge http protocol return code.
On the other hand, provide a kind of server, described server comprises: determination module, acquisition module and forwarding module;
Described determination module, for when receiving HTML (Hypertext Markup Language) HTTP request, determines whether described HTTP request is to deliver POST request;
Described acquisition module, for when described HTTP request is described POST request, obtains with described POST and asks corresponding HTTP return code;
Described forwarding module, for forwarding described POST request according to described HTTP return code.
Described acquisition module comprises:
The first acquiring unit, asks entrained POST parameter for obtaining described POST;
Second acquisition unit, for asking corresponding HTTP return code according to described POST parameter acquiring with described POST.
Described second acquisition unit comprises:
Search subelement, for according to the route area list of the local storage of described POST parameter query, determine that described POST parameter is whether in described route area list;
First determines subelement, for when described POST parameter is in described route area list, determines that the HTTP return code corresponding with described POST parameter is the first predetermined value;
Second determines subelement, for when described POST parameter is not in described route area list, determines that the HTTP return code corresponding with described POST parameter is the second predetermined value.
Described forwarding module, specifically for being transmitted to server corresponding to described HTTP return code by described POST request.
Described HTTP return code is off-gauge http protocol return code.
The beneficial effect that the technical scheme that the embodiment of the present invention provides is brought is: when determining that received HTTP request is described POST request, obtain with described POST and ask corresponding HTTP return code, according to described HTTP return code, forward described POST request, thereby realize the routing forwarding to POST request.
Accompanying drawing explanation
In order to be illustrated more clearly in the technical scheme in the embodiment of the present invention, below the accompanying drawing of required use during embodiment is described is briefly described, apparently, accompanying drawing in the following describes is only some embodiments of the present invention, for those of ordinary skills, do not paying under the prerequisite of creative work, can also obtain according to these accompanying drawings other accompanying drawing.
Fig. 1 is the method flow diagram of a kind of information processing of providing of the embodiment of the present invention one;
Fig. 2 is the method flow diagram of a kind of information processing of providing of the embodiment of the present invention two;
Fig. 3 is the structural representation of a kind of server of providing of the embodiment of the present invention three;
Fig. 4 is the structural representation of a kind of server of providing of the embodiment of the present invention three.
Embodiment
For making the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing, embodiment of the present invention is described further in detail.
Embodiment mono-
Referring to Fig. 1, a kind of method of information processing, described method comprises:
Step 101: when receiving HTML (Hypertext Markup Language) HTTP request, determine whether described HTTP request is to deliver POST request;
Step 102: when described HTTP request is described POST request, obtains with described POST and ask corresponding HTTP return code;
Step 103: forward described POST request according to described HTTP return code.
In the embodiment of the present invention, when determining that received HTTP request is described POST request, obtain with described POST and ask corresponding HTTP return code, according to described HTTP return code, forward described POST request, thereby make to realize the server of POST being asked to carry out routing forwarding, as Nginx server can adopt this above-mentioned art scheme after receiving POST request, realize the routing forwarding to POST request.
Embodiment bis-
Referring to Fig. 2, the embodiment of the present invention provides a kind of method of information processing, comprises following operation:
Step 201: user side sends HTTP request to Nginx server;
Step 202: when Nginx server receives HTTP request, determine whether received HTTP request is that POST(delivers) request;
When received HTTP request is POST request, execution step 203;
When received HTTP request is not POST request, adopt existing mode to process received HTTP request;
In the embodiment of the present invention, the form of HTTP request is as follows:
<request line> // request row
<headers> // stem
<blan line> // null
[<request body>] // main body
In HTTP request, the first row is request row <request line>, be used for illustrating the method(method of request resource) (GET method or POST method etc. in this way), want URI(Uniform Resource Identifier corresponding to access resources, universal resource identifier) and the version of the http protocol using, and then be a stem <headers>, be used for illustrating the additional information (as the sign appid of request application) that server will be used, after stem, be a null <blan line>, in addition after, just can add other data (being referred to as (body)) arbitrarily.
Based on above HTTP, ask the description of form to know, Nginx server, after receiving HTTP request, can know whether this HTTP asks is that POST asks by the method item in request row in this HTTP request.
Step 203:Nginx server obtains with described POST and asks corresponding HTTP return code;
Particularly, Nginx server obtains described POST and asks entrained POST parameter;
Nginx server is asked corresponding HTTP return code according to described POST parameter acquiring with described POST.
Wherein, Nginx server asks corresponding HTTP return code to comprise according to described POST parameter acquiring with described POST:
Nginx server is according to the route area list of the local storage of described POST parameter query, determines that described POST parameter is whether in described route area list;
When described POST parameter is in described route area list, determine that the HTTP return code corresponding with described POST parameter is the first predetermined value;
When described POST parameter is not in described route area list, determine that the HTTP return code corresponding with described POST parameter is the second predetermined value.
HTTP return code described in the embodiment of the present invention refers to the return code of off-gauge http protocol, and described POST parameter comprises URI and appid.
Step 204:Nginx server forwards described POST request according to described HTTP return code;
Particularly, Nginx server is transmitted to server corresponding to described HTTP return code by described POST request.
During specific implementation, Nginx server, according to corresponding relation between described HTTP return code inquiry HTTP return code and server device, obtains the corresponding server of described HTTP return code, afterwards, described POST request is transmitted to the server finding.For example, when described HTTP return code is the first predetermined value, as 433 o'clock, search corresponding relation between HTTP return code and server, the server that obtains these HTTP return code 433 correspondences is 6788, described POST request is transmitted to server 6788; When described HTTP return code is the second predetermined value, as 434 o'clock, search corresponding relation between HTTP return code and server, the server that obtains these HTTP return code 434 correspondences is 6789, described POST request is transmitted to server 6789.
In the embodiment of the present invention, when Nginx server determines that received HTTP request is described POST request, obtain with described POST and ask corresponding HTTP return code, and forward described POST request according to described HTTP return code, thereby realize the routing forwarding to POST request.
Now in conjunction with concrete program in machine code, describe the implementation procedure of technique scheme in detail, be described below:
Under the configuration of Nginx Server Default is supported, can ask corresponding HTTP return code according to POST, the POST request receiving is routed to server corresponding to HTTP return code, the Configuration of an example is as follows:
Above-mentioned Configuration process, has adopted the return code of 433 and 434 these two off-gauge http protocols, certainly when concrete configuration, can also use the return code of other non-http protocol, and the embodiment of the present invention is to this and be not specifically limited; After receiving POST request, the POST request acquiescence receiving enters server 8888, its address is specially https://localhost:8888, then the HTTP return code of returning according to server 8888 is 433 or 434, the POST request receiving is routed to the server 6788 of 433 correspondences, its address is https://localhost:6788 or be routed to the server 6789 of 434 correspondences specifically, and its address is https://localhost:6789 specifically.
So, in order to realize Nginx server, can ask corresponding HTTP return code according to POST, POST request is routed to different servers, can be in the custom block of Nginx, realization is according to the POST parameter in POST request, obtain with POST and ask corresponding HTTP return code, and then the POST request receiving is routed in server corresponding to HTTP return code.Wherein, Nginx custom block code is as follows:
void?ngx_http_foo_post_handler(ngx_http_request_t*r){
// call back function, from entering, reads the POST parameter in POST request here after POST request all receives, and can produce this POST and ask corresponding response
Here, in order to realize according to the POST parameter in POST request, obtain with POST and ask corresponding HTTP return code, register a call back function ngx_http_foo_post_handler, when POST request is all finished receiving, this call back function ngx_http_foo_post_handle will be called, received POST request is processed, in processing procedure, by call function get_route_id, obtain POST and ask corresponding HTTP return code, afterwards, by function ngx_http_fnalize_request (r, result) to Nginx server output POST, ask corresponding HTTP return code.
Processing as an optimization, can also be by add lua script in Nginx custom block, make when obtaining POST and ask corresponding HTTP return code, this Nginx custom block can call added lua script and realize, and can improve like this flexibility of configuration.Wherein, the example code of lua script is as follows:
Before asking corresponding HTTP return code according to the POST parameter acquiring POST in POST request, pre-configured route area list also, this route area list has provided the POST parameter of walking this Route Area.
For example, walk the pf:locs list of Cooperative District, this Cooperative District can comprise a plurality of regions, as areas such as Shanghai, Xiamen and Nanjing.
In the embodiment of the present invention, HTTP return code corresponding to Cooperative District is IN_CODE=434, and HTTP return code corresponding to Shenzhen district is OUT_CODE=433;
Afterwards, just can ask to search configured route area list according to the POST obtaining, obtain corresponding HTTP return code.Specific as follows:
After combining lua resolver, by obtaining POST, ask corresponding HTTP return code just can revise lua script to realize, do not need to obtain POST and ask corresponding HTTP return code by remodifying and compile Nginx custom block code, can improve the flexibility of configuration.
Description based on above can show that Nginx realizes asks corresponding HTTP return code according to POST, forwards POST and asks being finally configured to of different server:
Embodiment tri-
Referring to Fig. 3, the embodiment of the present invention provides a kind of server, and this server specifically can be identical with the Nginx server described in said method embodiment, comprising: determination module 301, acquisition module 302 and forwarding module 303;
Referring to Fig. 4, embodiment of the present invention acquisition module 302 as shown in Figure 3 comprises:
The first acquiring unit 3021, asks entrained POST parameter for obtaining described POST;
In the embodiment of the present invention, second acquisition unit 3022 as shown in Figure 4 comprises:
Search subelement, for according to the route area list of the local storage of described POST parameter query, determine that described POST parameter is whether in described route area list;
First determines subelement, for when described POST parameter is in described route area list, determines that the HTTP return code corresponding with described POST parameter is the first predetermined value;
Second determines subelement, for when described POST parameter is not in described route area list, determines that the HTTP return code corresponding with described POST parameter is the second predetermined value.
In the embodiment of the present invention, forwarding module 303, specifically for being transmitted to server corresponding to described HTTP return code by described POST request.
In the embodiment of the present invention, above-mentioned HTTP return code is off-gauge http protocol return code.
The beneficial effect that the technical scheme that the embodiment of the present invention provides is brought is: when determining that received HTTP request is described POST request, obtain with described POST and ask corresponding HTTP return code, according to described HTTP return code, forward described POST request, thereby realize the routing forwarding to POST request.
It should be noted that: the server that above-described embodiment provides is when carrying out information processing, only the division with above-mentioned each functional module is illustrated, in practical application, can above-mentioned functions be distributed and by different functional modules, completed as required, the internal structure that is about to server is divided into different functional modules, to complete all or part of function described above.In addition, the server that above-described embodiment provides and the embodiment of the method for information processing belong to same design, and its specific implementation process refers to embodiment of the method, repeats no more here.
The invention described above embodiment sequence number, just to describing, does not represent the quality of embodiment.
One of ordinary skill in the art will appreciate that all or part of step that realizes above-described embodiment can complete by hardware, also can come the hardware that instruction is relevant to complete by program, described program can be stored in a kind of computer-readable recording medium, the above-mentioned storage medium of mentioning can be read-only memory, disk or CD etc.
The foregoing is only preferred embodiment of the present invention, in order to limit the present invention, within the spirit and principles in the present invention not all, any modification of doing, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.
Claims (10)
1. a method for information processing, is characterized in that, described method comprises:
When receiving HTML (Hypertext Markup Language) HTTP request, determine whether described HTTP request is to deliver POST request;
When described HTTP request is described POST request, obtains with described POST and ask corresponding HTTP return code;
According to described HTTP return code, forward described POST request.
2. method according to claim 1, is characterized in that, described in obtain with described POST and ask corresponding HTTP return code, comprising:
Obtain described POST and ask entrained POST parameter;
According to described POST parameter acquiring, ask corresponding HTTP return code with described POST.
3. method according to claim 2, is characterized in that, describedly according to described POST parameter acquiring, asks corresponding HTTP return code to comprise with described POST:
According to the route area list of the local storage of described POST parameter query, determine that described POST parameter is whether in described route area list;
When described POST parameter is in described route area list, determine that the HTTP return code corresponding with described POST parameter is the first predetermined value;
When described POST parameter is not in described route area list, determine that the HTTP return code corresponding with described POST parameter is the second predetermined value.
4. according to the method described in claims 1 to 3 any one, it is characterized in that, describedly according to described HTTP return code, forward described POST request and comprise:
Described POST request is transmitted to server corresponding to described HTTP return code.
5. method according to claim 1, is characterized in that, described HTTP return code is off-gauge http protocol return code.
6. a server, is characterized in that, described server comprises: determination module, acquisition module and forwarding module;
Described determination module, for when receiving HTML (Hypertext Markup Language) HTTP request, determines whether described HTTP request is to deliver POST request;
Described acquisition module, for when described HTTP request is described POST request, obtains with described POST and asks corresponding HTTP return code;
Described forwarding module, for forwarding described POST request according to described HTTP return code.
7. server according to claim 6, is characterized in that, described acquisition module comprises:
The first acquiring unit, asks entrained POST parameter for obtaining described POST;
Second acquisition unit, for asking corresponding HTTP return code according to described POST parameter acquiring with described POST.
8. server according to claim 7, is characterized in that, described second acquisition unit comprises:
Search subelement, for according to the route area list of the local storage of described POST parameter query, determine that described POST parameter is whether in described route area list;
First determines subelement, for when described POST parameter is in described route area list, determines that the HTTP return code corresponding with described POST parameter is the first predetermined value;
Second determines subelement, for when described POST parameter is not in described route area list, determines that the HTTP return code corresponding with described POST parameter is the second predetermined value.
9. according to the server described in claim 6 to 8 any one, it is characterized in that, described forwarding module, specifically for being transmitted to server corresponding to described HTTP return code by described POST request.
10. server according to claim 6, is characterized in that, described HTTP return code is off-gauge http protocol return code.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210318759.5A CN103685331A (en) | 2012-08-31 | 2012-08-31 | Information processing method and server |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210318759.5A CN103685331A (en) | 2012-08-31 | 2012-08-31 | Information processing method and server |
Publications (1)
Publication Number | Publication Date |
---|---|
CN103685331A true CN103685331A (en) | 2014-03-26 |
Family
ID=50321643
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201210318759.5A Pending CN103685331A (en) | 2012-08-31 | 2012-08-31 | Information processing method and server |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103685331A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108306934A (en) * | 2017-12-28 | 2018-07-20 | 北京天元创新科技有限公司 | A kind of cross-server document transmission method and system |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100217820A1 (en) * | 2001-03-26 | 2010-08-26 | Lev Brouk | Method, system, and computer program product for sending and receiving messages |
CN102571959A (en) * | 2012-01-11 | 2012-07-11 | 北京奇虎科技有限公司 | System and method for downloading data |
-
2012
- 2012-08-31 CN CN201210318759.5A patent/CN103685331A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100217820A1 (en) * | 2001-03-26 | 2010-08-26 | Lev Brouk | Method, system, and computer program product for sending and receiving messages |
CN102571959A (en) * | 2012-01-11 | 2012-07-11 | 北京奇虎科技有限公司 | System and method for downloading data |
Non-Patent Citations (1)
Title |
---|
LOAD_LIFE: """nginx自定义模块编写-根据post参数路由到不同服务器""", <HTTP:https://BLOG.CSDN.NET/LOAD_LIFE/ARTICLE/DETAILS/7350539> * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108306934A (en) * | 2017-12-28 | 2018-07-20 | 北京天元创新科技有限公司 | A kind of cross-server document transmission method and system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109067914B (en) | web service proxy method, device, equipment and storage medium | |
CN110351283B (en) | Data transmission method, device, equipment and storage medium | |
EP3275162B1 (en) | Systems and techniques for web communication | |
CN103475682B (en) | File transfer method and file transfer equipment | |
CN103095479A (en) | Method and device of business configuration | |
CN105763619B (en) | The method and device that client and server-side are communicated | |
CN110022289A (en) | Data transmission method, apparatus and system | |
EP2997747A1 (en) | Systems and methods for enhanced discovery | |
CN109451014B (en) | WebService agent system and transparent agent method thereof | |
JP2013542681A (en) | Content sharing method and apparatus using group change information in content-centric network environment | |
CN102594886B (en) | Method and device for direct communication between browsers, and communication system | |
KR100901281B1 (en) | Method for ubiquitous web service | |
CN113010333A (en) | Multi-scene inter-process communication method suitable for Linux server cluster | |
Qiao et al. | Ccnxtomcat: An extended web server for content-centric networking | |
CN104158868A (en) | File transmission method and management server | |
US11489810B2 (en) | Intelligently routing a response packet along a same connection as a request packet | |
WO2020031157A1 (en) | Method and apparatus for network function selection scheme in service based architecture of communication network | |
US20150006622A1 (en) | Web contents transmission method and apparatus | |
CN104615597A (en) | Method, device and system for clearing cache file in browser | |
CN104219257A (en) | Web real-time communication method, system, server and client | |
US7861001B2 (en) | Transport independent redirection | |
CN103166851B (en) | The transfer processing method of internet information and system | |
CN110798513B (en) | Internet of things equipment interconnection system and method | |
CN111614792B (en) | Transparent transmission method, system, server, electronic device and storage medium | |
CN103685331A (en) | Information processing method and server |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20140326 |