Skip to content

Commit

Permalink
Ensure session stickiness when using a load balanced configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattikus committed Oct 24, 2014
1 parent 6b608bf commit d1c2a98
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/Bcfg2/Client/Proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ def __init__(self, key=None, cert=None, ca=None,
self.scns = scns
self.timeout = timeout
self.protocol = protocol
self.cookie = None

def make_connection(self, host):
host, self._extra_headers = self.get_host_info(host)[0:2]
Expand All @@ -258,6 +259,8 @@ def request(self, host, handler, request_body, verbose=0):
try:
conn = self.send_request(host, handler, request_body, False)
response = conn.getresponse()
if not self.cookie:
self.cookie = response.getheader('Set-Cookie')
errcode = response.status
errmsg = response.reason
headers = response.msg
Expand Down Expand Up @@ -285,6 +288,8 @@ def send_request(self, host, handler, request_body, debug):
xmlrpclib.Transport.send_request(self, conn, handler, request_body)
self.send_host(conn, host)
self.send_user_agent(conn)
if self.cookie:
conn.putheader('Cookie', self.cookie)
self.send_content(conn, request_body)
return conn
# pylint: enable=E1101
Expand Down

0 comments on commit d1c2a98

Please sign in to comment.