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 787029d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 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,9 @@ 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')
print self.cookie
errcode = response.status
errmsg = response.reason
headers = response.msg
Expand Down Expand Up @@ -285,6 +289,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 787029d

Please sign in to comment.