Skip to content

Commit

Permalink
Use websockets by passing 'ws' param to attach_socket
Browse files Browse the repository at this point in the history
  • Loading branch information
aanand committed Nov 6, 2013
1 parent cf35b38 commit bd938b5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docker/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ def _post_json(self, url, data, **kwargs):
kwargs['headers']['Content-Type'] = 'application/json'
return self.post(url, json.dumps(data2), **kwargs)

def attach_socket(self, container, params=None):
def attach_socket(self, container, params=None, ws=False):
if ws:
return self._attach_websocket(container, params)

if isinstance(container, dict):
container = container.get('Id')
u = self._url("/containers/{0}/attach".format(container))
Expand All @@ -151,7 +154,7 @@ def attach_socket(self, container, params=None):
# eventually block
return res.raw._fp.fp._sock

def attach_websocket(self, container, params=None):
def _attach_websocket(self, container, params=None):
url = self._url("/containers/{0}/attach/ws".format(container))
req = requests.Request("POST", url, params=self._attach_params(params))
full_url = req.prepare().url
Expand Down

0 comments on commit bd938b5

Please sign in to comment.