CN109451068A - The insertion method and device of Set-Cookie value - Google Patents
The insertion method and device of Set-Cookie value Download PDFInfo
- Publication number
- CN109451068A CN109451068A CN201811626452.5A CN201811626452A CN109451068A CN 109451068 A CN109451068 A CN 109451068A CN 201811626452 A CN201811626452 A CN 201811626452A CN 109451068 A CN109451068 A CN 109451068A
- Authority
- CN
- China
- Prior art keywords
- session
- http response
- response message
- cookie value
- ageing time
- 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.)
- Granted
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
- H04L67/146—Markers for unambiguous identification of a particular session, e.g. session cookie or URL-encoding
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/02—Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1001—Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
Abstract
The application is applied in load-balancing device for the insertion method and device of a kind of Set-Cookie value, which comprises receives the hypertext transfer protocol http response message that server is sent;Search the corresponding session of the http response message;If not finding the session, corresponding Set-Cookie value is inserted into the http response message;If finding the session, determined whether to be inserted into corresponding Set-Cookie value in the http response message according to the remaining ageing time of the session.Using embodiments herein, the resource of load-balancing device is saved, improves the treatment effeciency of load-balancing device.
Description
Technical field
This application involves network communication technology fields, are specifically designed the insertion method and device of a kind of Set-Cookie value.
Background technique
Into after big data era, many websites are intended to user's energy register account number and carry out user identity authentication, electronics quotient
Business website then requires user that must carry out user authentication login.User and these websites produce a large amount of numbers during interaction
According to often relevant before and after these data, these data can not be present in each server.Before user's LoginLogout
It is required that all these interactive processes are all completed by same server, and it cannot be scheduled on different servers, session is protected
Hold function there have been.
Currently, Cookie session keep function there are three types of mode: intercalation model, Passive Mode, Hash mode.Wherein,
Intercalation model be load-balancing device server hypertext transfer protocol (HyperText Transfer Protocol,
HTTP Set-Cookie value) is inserted into response message;Passive Mode is that server is inserted into Set- in http response message
Cookie value;Hash mode, which is load-balancing device, to be carried out hash operation according to Cookie value and finds corresponding real server.
When Cookie session is maintained under intercalation model, load-balancing device is in each http response message of server
It is inserted into Set-Cookie value.Detailed process are as follows: when terminal sends HTTP request message for the first time, do not taken in the HTTP request message
HTTP request message is sent to a server according to load balance scheduling algorithm by band Cookie value, load-balancing device;Clothes
After business device receives HTTP request message, http response message is sent to load-balancing device;Load-balancing device receives HTTP
After response message, terminal is sent to after Set-Cookie value is written in http response message;When terminal receives http response report
The corresponding Cookie value of Set-Cookie value is locally being saved after text, the Cookie can be carried when sending HTTP request message again
Value;Load-balancing device can be decoded simultaneously after being received again by HTTP request according to the Cookie value carried in HTTP request message
It is dispatched to corresponding real server;After server receives HTTP request message, sends http response message and set to load balancing
It is standby, after load-balancing device receives http response message, after still Set-Cookie value being written in http response message
It is sent to terminal.
It can be seen that, sent based on load-balancing device for server from the insertion method of above-mentioned Set-Cookie value
Each http response message, can all be inserted into corresponding Set-Cookie value, this will waste the money of load-balancing device significantly
Source influences the treatment effeciency of load-balancing device.
Summary of the invention
In view of this, the application provides the insertion method and device of a kind of Set-Cookie value, to solve in the related technology
The existing resource for wasting load-balancing device significantly, the problem of influencing the treatment effeciency of load-balancing device.
Specifically, the application is achieved by the following technical solution:
A kind of insertion method of Set-Cookie value is applied in load-balancing device, which comprises
Receive the hypertext transfer protocol http response message that server is sent;
Search the corresponding session of the http response message;
If not finding the session, corresponding Set-Cookie value is inserted into the http response message;
If finding the session, determined whether according to the remaining ageing time of the session in the http response report
Corresponding Set-Cookie value is inserted into text.
A kind of insertion apparatus of Set-Cookie value is applied in load-balancing device, which is characterized in that described device packet
It includes:
Receiving module, for receiving the hypertext transfer protocol http response message of server transmission;
Searching module, for searching the corresponding session of the http response message;
It is inserted into module, if being inserted into corresponding Set- in the http response message for not finding the session
Cookie value;If finding the session, determined whether according to the remaining ageing time of the session in the http response
Corresponding Set-Cookie value is inserted into message.
By the above technical solution provided by the present application as it can be seen that load-balancing device receives the http response report that server is sent
Wen Hou can search the corresponding session of http response message first, if not finding the session, be inserted into http response message
Corresponding Set-Cookie value determines whether according to the remaining ageing time of the session in HTTP if finding the session
It is inserted into corresponding Set-Cookie value in response message, is not the addition Set-Cookie value directly in http response message,
This will save the resource of load-balancing device, promote the treatment effeciency of load-balancing device.
Detailed description of the invention
Fig. 1 is a kind of flow chart of the insertion method of Set-Cookie value shown in the application;
Fig. 2 is a kind of structural schematic diagram of the insertion apparatus of Set-Cookie value shown in the application.
Specific embodiment
Example embodiments are described in detail here, and the example is illustrated in the accompanying drawings.Following description is related to
When attached drawing, unless otherwise indicated, the same numbers in different drawings indicate the same or similar elements.Following exemplary embodiment
Described in embodiment do not represent all embodiments consistent with the application.On the contrary, they be only with it is such as appended
The example of the consistent device and method of some aspects be described in detail in claims, the application.
It is only to be not intended to be limiting the application merely for for the purpose of describing particular embodiments in term used in this application.
It is also intended in the application and the "an" of singular used in the attached claims, " " and "the" including most shapes
Formula, unless the context clearly indicates other meaning.It is also understood that term "and/or" used herein refers to and includes
One or more associated any or all of project listed may combine.
It will be appreciated that though various information, but this may be described using term first, second, third, etc. in the application
A little information should not necessarily be limited by these terms.These terms are only used to for same type of information being distinguished from each other out.For example, not departing from
In the case where the application range, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as
One information.Depending on context, word as used in this " if " can be construed to " ... when " or " when ...
When " or " in response to determination ".
To solve the above-mentioned problems, it the embodiment of the invention provides a kind of insertion method of Set-Cookie value, saves
The resource of load-balancing device improves the treatment effeciency of load-balancing device.Referring to Figure 1, Fig. 1 is one shown in the application
The flow chart of the insertion method of kind Set-Cookie value, is applied in load-balancing device.
S11: the http response message that server is sent is received.
S12: the corresponding session of http response message is searched if not finding session and executes S13;If finding session,
Then execute S14.
S13: corresponding Set-Cookie value is inserted into http response message.
S14: determine whether to be inserted into corresponding Set- in http response message according to the remaining ageing time of session
Cookie value.
Http response message can be what the HTTP request message sent for the first time based on terminal was sent, it is also possible to based on eventually
The non-HTTP request message sent for the first time is held to send.After load-balancing device receives HTTP request message, this can be searched
The corresponding session of http response message, if not finding the session, explanation is the HTTP request message sent for the first time based on terminal
It sends, that is to say, that there are no corresponding Cookie values in terminal, therefore, are directly inserted into http response message corresponding
Set-Cookie value;If finding the session, explanation is sent based on the non-HTTP request message sent for the first time of terminal, also
It is to say that corresponding Cookie value may be had existed in terminal, therefore, is determined whether according to the remaining ageing time of session
Corresponding Set-Cookie value is inserted into http response message.
By the above technical solution provided by the present application as it can be seen that load-balancing device receives the http response report that server is sent
Wen Hou can search the corresponding session of http response message first, if not finding the session, be inserted into http response message
Corresponding Set-Cookie value determines whether according to the remaining ageing time of the session in HTTP if finding the session
It is inserted into corresponding Set-Cookie value in response message, is not the addition Set-Cookie value directly in http response message,
This will save the resource of load-balancing device, promote the treatment effeciency of load-balancing device.
Specifically, searching the corresponding session of http response message in above-mentioned S12, specifically include:
Obtain the five-tuple information of http response message;
Search the corresponding session of five-tuple information.
Load-balancing device would generally establish session based on five-tuple information, therefore, can be according to http response message
Five-tuple information search corresponding session.
Wherein, five-tuple information include the address source internet protocol (Internet Protocol, IP), purpose IP address,
Source port, destination port and protocol number.
Optionally, the above method further include:
If not finding session, session is established;
Countdown is carried out to the digestion period of session.
It when establishing session, can be established based on the five-tuple of http response message, after session establishment, can star the meeting
It can be, but not limited to the session by the way of countdown the digestion period of words.
Wherein, digestion period can be set according to actual needs.
Specifically, the remaining ageing time in above-mentioned S14 according to session determines whether the insertion pair in http response message
The Set-Cookie value answered, specifically includes:
Obtain the remaining ageing time of session;
Determine whether residue ageing time is less than given threshold;
If it is determined that remaining ageing time is less than given threshold, then corresponding Set-Cookie is inserted into http response message
Value;
If it is determined that remaining ageing time is greater than or equal to given threshold, then it is not inserted into http response message corresponding
Set-Cookie value.
It can be set according to actual needs given threshold, for example, it can be set to being a quarter of digestion period, work as residue
When ageing time is less than a quarter of digestion period, the very possible aging of the session, in order to ensure terminal can be accessed smoothly pair
The server answered can be inserted into corresponding Set-Cookie value in http response message;Be greater than when remaining ageing time or
Equal to digestion period a quarter when, a possibility that conversation aging, is smaller, can not have to insert in http response message
Enter corresponding Set-Cookie value.
Fig. 2 is referred to, Fig. 2 is a kind of structural schematic diagram of the insertion apparatus of Set-Cookie value shown in the application, is answered
For in load-balancing device, which includes:
Receiving module 21, for receiving the hypertext transfer protocol http response message of server transmission;
Searching module 22, for searching the corresponding session of http response message;
It is inserted into module 23, if being inserted into corresponding Set-Cookie in http response message for not finding session
Value;If finding session, determine whether to be inserted into http response message according to the remaining ageing time of session corresponding
Set-Cookie value.
By the above technical solution provided by the present application as it can be seen that load-balancing device receives the http response report that server is sent
Wen Hou can search the corresponding session of http response message first, if not finding the session, be inserted into http response message
Corresponding Set-Cookie value determines whether according to the remaining ageing time of the session in HTTP if finding the session
It is inserted into corresponding Set-Cookie value in response message, is not the addition Set-Cookie value directly in http response message,
This will save the resource of load-balancing device, promote the treatment effeciency of load-balancing device.
Specifically, searching module 22, for searching the corresponding session of http response message, it is specifically used for:
Obtain the five-tuple information of http response message;
Search the corresponding session of five-tuple information.
Optionally, further includes:
Module is established, if establishing session for not finding session;
Timing module, for progress countdown digestion period to session.
Specifically, insertion module 23, for being determined whether in http response message according to the remaining ageing time of session
It is inserted into corresponding Set-Cookie value, is specifically used for:
Obtain the remaining ageing time of session;
Determine whether residue ageing time is less than given threshold;
If it is determined that remaining ageing time is less than given threshold, then corresponding Set-Cookie is inserted into http response message
Value.
Optionally, it is inserted into module 23, is also used to:
If it is determined that remaining ageing time is greater than or equal to given threshold, then it is not inserted into http response message corresponding
Set-Cookie value.
For device embodiment, since it corresponds essentially to embodiment of the method, so related place is referring to method reality
Apply the part explanation of example.The apparatus embodiments described above are merely exemplary, wherein described be used as separation unit
The unit of explanation may or may not be physically separated, and component shown as a unit can be or can also be with
It is not physical unit, it can it is in one place, or may be distributed over multiple network units.It can be according to actual
The purpose for needing to select some or all of the modules therein to realize application scheme.Those of ordinary skill in the art are not paying
Out in the case where creative work, it can understand and implement.
The foregoing is merely the preferred embodiments of the application, not to limit the application, all essences in the application
Within mind and principle, any modification, equivalent substitution, improvement and etc. done be should be included within the scope of the application protection.
Claims (10)
1. a kind of insertion method of Set-Cookie value is applied in load-balancing device, which is characterized in that the method packet
It includes:
Receive the hypertext transfer protocol http response message that server is sent;
Search the corresponding session of the http response message;
If not finding the session, corresponding Set-Cookie value is inserted into the http response message;
If finding the session, determined whether in the http response message according to the remaining ageing time of the session
It is inserted into corresponding Set-Cookie value.
2. the method according to claim 1, wherein searching the corresponding session of the http response message, specifically
Include:
Obtain the five-tuple information of the http response message;
Search the corresponding session of the five-tuple information.
3. the method according to claim 1, wherein further include:
If not finding the session, the session is established;
Countdown is carried out to the digestion period of the session.
4. method according to claim 1 to 3, which is characterized in that determined according to the remaining ageing time of the session
Whether it is inserted into corresponding Set-Cookie value in the http response message, specifically includes:
Obtain the remaining ageing time of the session;
Determine whether the remaining ageing time is less than the given threshold;
If it is determined that the residue ageing time is less than the given threshold, then it is inserted into the http response message corresponding
Set-Cookie value.
5. according to the method described in claim 4, it is characterized in that, the method also includes:
If it is determined that the residue ageing time is greater than or equal to the given threshold, then it is not inserted into the http response message
Corresponding Set-Cookie value.
6. a kind of insertion apparatus of Set-Cookie value is applied in load-balancing device, which is characterized in that described device packet
It includes:
Receiving module, for receiving the hypertext transfer protocol http response message of server transmission;
Searching module, for searching the corresponding session of the http response message;
It is inserted into module, if being inserted into corresponding Set- in the http response message for not finding the session
Cookie value;If finding the session, determined whether according to the remaining ageing time of the session in the http response
Corresponding Set-Cookie value is inserted into message.
7. device according to claim 6, which is characterized in that the searching module, for searching the http response report
The corresponding session of text, is specifically used for:
Obtain the five-tuple information of the http response message;
Search the corresponding session of the five-tuple information.
8. device according to claim 6, which is characterized in that further include:
Module is established, if establishing the session for not finding the session;
Timing module, for progress countdown digestion period to the session.
9. according to device as claimed in claim 6 to 8, which is characterized in that the insertion module, for according to the session
Remaining ageing time determine whether to be inserted into corresponding Set-Cookie value in the http response message, be specifically used for:
Obtain the remaining ageing time of the session;
Determine whether the remaining ageing time is less than the given threshold;
If it is determined that the residue ageing time is less than the given threshold, then it is inserted into the http response message corresponding
Set-Cookie value.
10. device according to claim 9, which is characterized in that the insertion module is also used to:
If it is determined that the residue ageing time is greater than or equal to the given threshold, then it is not inserted into the http response message
Corresponding Set-Cookie value.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811626452.5A CN109451068B (en) | 2018-12-28 | 2018-12-28 | Method and device for inserting Set-Cookie value |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811626452.5A CN109451068B (en) | 2018-12-28 | 2018-12-28 | Method and device for inserting Set-Cookie value |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109451068A true CN109451068A (en) | 2019-03-08 |
CN109451068B CN109451068B (en) | 2021-11-23 |
Family
ID=65542036
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811626452.5A Active CN109451068B (en) | 2018-12-28 | 2018-12-28 | Method and device for inserting Set-Cookie value |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109451068B (en) |
Citations (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101340371A (en) * | 2008-08-12 | 2009-01-07 | 杭州华三通信技术有限公司 | Session keeping method and load balance apparatus |
CN101534321A (en) * | 2009-03-09 | 2009-09-16 | 浪潮电子信息产业股份有限公司 | Load-balancing session-keeping algorithm based on cookie |
CN101783771A (en) * | 2010-03-24 | 2010-07-21 | 杭州华三通信技术有限公司 | Method and equipment for realizing load balance continuity |
CN102185723A (en) * | 2011-05-27 | 2011-09-14 | 杭州迪普科技有限公司 | Session management method and device |
CN103457869A (en) * | 2013-08-28 | 2013-12-18 | 北京星网锐捷网络技术有限公司 | Conversation maintaining method and device |
CN106131129A (en) * | 2016-06-23 | 2016-11-16 | 杭州迪普科技有限公司 | The method and apparatus of the data syn-chronization time management of GSLB |
CN107360251A (en) * | 2017-08-16 | 2017-11-17 | 中国工商银行股份有限公司 | Method, system and the load balancing apparatus that session is kept |
CN107995304A (en) * | 2017-12-13 | 2018-05-04 | 杭州迪普科技股份有限公司 | A kind of session keeping method and device based on cookie |
CN108076003A (en) * | 2016-11-07 | 2018-05-25 | 阿里巴巴集团控股有限公司 | The detection method and device of Session Hijack |
CN108881430A (en) * | 2018-06-14 | 2018-11-23 | 平安科技(深圳)有限公司 | Session keeping method, device, computer equipment and storage medium |
-
2018
- 2018-12-28 CN CN201811626452.5A patent/CN109451068B/en active Active
Patent Citations (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101340371A (en) * | 2008-08-12 | 2009-01-07 | 杭州华三通信技术有限公司 | Session keeping method and load balance apparatus |
CN101534321A (en) * | 2009-03-09 | 2009-09-16 | 浪潮电子信息产业股份有限公司 | Load-balancing session-keeping algorithm based on cookie |
CN101783771A (en) * | 2010-03-24 | 2010-07-21 | 杭州华三通信技术有限公司 | Method and equipment for realizing load balance continuity |
CN102185723A (en) * | 2011-05-27 | 2011-09-14 | 杭州迪普科技有限公司 | Session management method and device |
CN103457869A (en) * | 2013-08-28 | 2013-12-18 | 北京星网锐捷网络技术有限公司 | Conversation maintaining method and device |
CN106131129A (en) * | 2016-06-23 | 2016-11-16 | 杭州迪普科技有限公司 | The method and apparatus of the data syn-chronization time management of GSLB |
CN108076003A (en) * | 2016-11-07 | 2018-05-25 | 阿里巴巴集团控股有限公司 | The detection method and device of Session Hijack |
CN107360251A (en) * | 2017-08-16 | 2017-11-17 | 中国工商银行股份有限公司 | Method, system and the load balancing apparatus that session is kept |
CN107995304A (en) * | 2017-12-13 | 2018-05-04 | 杭州迪普科技股份有限公司 | A kind of session keeping method and device based on cookie |
CN108881430A (en) * | 2018-06-14 | 2018-11-23 | 平安科技(深圳)有限公司 | Session keeping method, device, computer equipment and storage medium |
Non-Patent Citations (1)
Title |
---|
王旭铭: "负载均衡集群中的会话保持研究", 《中国优秀硕士论文全文数据库 信息科技辑》 * |
Also Published As
Publication number | Publication date |
---|---|
CN109451068B (en) | 2021-11-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105516080B (en) | The processing method of TCP connection, apparatus and system | |
CN104158808B (en) | Portal authentication method and its device based on APP applications | |
US9635015B1 (en) | Method to securely connect to and manage X11 applications on a remote system through an HTTP client | |
CN104009938B (en) | The long method and system connected based on route aspect | |
US7949704B2 (en) | Administration of a broker-based publish/subscribe messaging system | |
CN108924210A (en) | Service request processing method, device, server and storage medium | |
CN105162883B (en) | Network Load Balance processing system and its method and apparatus | |
CN104852919B (en) | Realize the method and device of door Portal certifications | |
US10601831B2 (en) | Accessing local information based on a browser session | |
CN107465666A (en) | A kind of client ip acquisition methods and device | |
US20060031571A1 (en) | Data communications through a split connection proxy | |
EP3128713B1 (en) | Page push method and system | |
CN112910793B (en) | Method for connection multiplexing in seven-layer load balancing and load balancer | |
CN105991640B (en) | Handle the method and device of HTTP request | |
CN107920094A (en) | Data capture method, device, server and the network equipment | |
CN107124483A (en) | Domain name analytic method and server | |
CN113259415B (en) | Network message processing method and device and network server | |
CN104010001A (en) | Method and system for carrying out connection communication on same networking requests in mobile terminal | |
CN103561063A (en) | Method and terminal for logging onto set top box | |
CN110233902A (en) | Conversation processing method, device, electronic equipment and machine readable storage medium | |
CN104202432B (en) | Remote web management system and management method | |
CN102938782A (en) | Message processing method, device and system | |
CN107395582A (en) | Portal authentication devices and system | |
CN109451068A (en) | The insertion method and device of Set-Cookie value | |
CN103607324B (en) | Data processing method for Java message service, Java message client and server |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |