Kaydet (Commit) 0c2b4e4d authored tarafından Joffrey F's avatar Joffrey F Kaydeden (comit) Joffrey F

Always send attach request as streaming

Signed-off-by: 's avatarJoffrey F <joffrey@docker.com>
üst fc6773d6
...@@ -50,7 +50,7 @@ class ContainerApiMixin(object): ...@@ -50,7 +50,7 @@ class ContainerApiMixin(object):
} }
u = self._url("/containers/{0}/attach", container) u = self._url("/containers/{0}/attach", container)
response = self._post(u, headers=headers, params=params, stream=stream) response = self._post(u, headers=headers, params=params, stream=True)
return self._read_from_socket( return self._read_from_socket(
response, stream, self._check_is_tty(container) response, stream, self._check_is_tty(container)
......
...@@ -1092,20 +1092,28 @@ class AttachContainerTest(BaseAPIIntegrationTest): ...@@ -1092,20 +1092,28 @@ class AttachContainerTest(BaseAPIIntegrationTest):
command = "printf '{0}'".format(line) command = "printf '{0}'".format(line)
container = self.client.create_container(BUSYBOX, command, container = self.client.create_container(BUSYBOX, command,
detach=True, tty=False) detach=True, tty=False)
ident = container['Id'] self.tmp_containers.append(container)
self.tmp_containers.append(ident)
opts = {"stdout": 1, "stream": 1, "logs": 1} opts = {"stdout": 1, "stream": 1, "logs": 1}
pty_stdout = self.client.attach_socket(ident, opts) pty_stdout = self.client.attach_socket(container, opts)
self.addCleanup(pty_stdout.close) self.addCleanup(pty_stdout.close)
self.client.start(ident) self.client.start(container)
next_size = next_frame_size(pty_stdout) next_size = next_frame_size(pty_stdout)
self.assertEqual(next_size, len(line)) self.assertEqual(next_size, len(line))
data = read_exactly(pty_stdout, next_size) data = read_exactly(pty_stdout, next_size)
self.assertEqual(data.decode('utf-8'), line) self.assertEqual(data.decode('utf-8'), line)
def test_attach_no_stream(self):
container = self.client.create_container(
BUSYBOX, 'echo hello'
)
self.tmp_containers.append(container)
self.client.start(container)
output = self.client.attach(container, stream=False, logs=True)
assert output == 'hello\n'.encode(encoding='ascii')
class PauseTest(BaseAPIIntegrationTest): class PauseTest(BaseAPIIntegrationTest):
def test_pause_unpause(self): def test_pause_unpause(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment