Add hijack hints for non-detached exec api calls

Signed-off-by: David Gageot <david@gageot.net>
This commit is contained in:
David Gageot 2016-07-08 12:12:23 +02:00 committed by Aanand Prasad
parent 6dec639a1a
commit 5464cf2bea
2 changed files with 39 additions and 3 deletions

View File

@ -66,8 +66,16 @@ class ExecApiMixin(object):
'Detach': detach
}
headers = {} if detach else {
'Connection': 'Upgrade',
'Upgrade': 'tcp'
}
res = self._post_json(
self._url('/exec/{0}/start', exec_id), data=data, stream=stream
self._url('/exec/{0}/start', exec_id),
headers=headers,
data=data,
stream=stream
)
if socket:

View File

@ -51,8 +51,36 @@ class ExecTest(DockerClientTest):
}
)
self.assertEqual(args[1]['headers'],
{'Content-Type': 'application/json'})
self.assertEqual(
args[1]['headers'], {
'Content-Type': 'application/json',
'Connection': 'Upgrade',
'Upgrade': 'tcp'
}
)
def test_exec_start_detached(self):
self.client.exec_start(fake_api.FAKE_EXEC_ID, detach=True)
args = fake_request.call_args
self.assertEqual(
args[0][1], url_prefix + 'exec/{0}/start'.format(
fake_api.FAKE_EXEC_ID
)
)
self.assertEqual(
json.loads(args[1]['data']), {
'Tty': False,
'Detach': True
}
)
self.assertEqual(
args[1]['headers'], {
'Content-Type': 'application/json'
}
)
def test_exec_inspect(self):
self.client.exec_inspect(fake_api.FAKE_EXEC_ID)