Commit 5f364170 by Sheng

Increase buffer size for channel

parent 41740690
...@@ -65,7 +65,7 @@ class Server(paramiko.ServerInterface): ...@@ -65,7 +65,7 @@ class Server(paramiko.ServerInterface):
def check_auth_password(self, username, password): def check_auth_password(self, username, password):
print('Auth attempt with username: {!r} & password: {!r}'.format(username, password)) # noqa print('Auth attempt with username: {!r} & password: {!r}'.format(username, password)) # noqa
if (username in ['robey', 'bar']) and (password == 'foo'): if (username in ['robey', 'bar', 'foo']) and (password == 'foo'):
return paramiko.AUTH_SUCCESSFUL return paramiko.AUTH_SUCCESSFUL
return paramiko.AUTH_FAILED return paramiko.AUTH_FAILED
...@@ -150,6 +150,17 @@ def run_ssh_server(port=2200, running=True): ...@@ -150,6 +150,17 @@ def run_ssh_server(port=2200, running=True):
if username == 'bar': if username == 'bar':
msg = chan.recv(1024) msg = chan.recv(1024)
chan.send(msg) chan.send(msg)
elif username == 'foo':
lst = []
while True:
msg = chan.recv(32 * 1024)
lst.append(msg)
if msg.endswith(b'\r\n\r\n'):
break
data = b''.join(lst)
while data:
s = chan.send(data)
data = data[s:]
chan.close() chan.close()
t.close() t.close()
......
...@@ -487,4 +487,32 @@ class TestAppInDebug(OtherTestBase): ...@@ -487,4 +487,32 @@ class TestAppInDebug(OtherTestBase):
class TestAppMiscell(OtherTestBase): class TestAppMiscell(OtherTestBase):
debug = False @tornado.testing.gen_test
def test_app_for_sending_message_with_large_size(self):
url = self.get_url('/')
client = self.get_http_client()
body = urlencode(dict(self.body, username='foo'))
response = yield client.fetch(url, method='POST', body=body,
headers=self.headers)
data = json.loads(to_str(response.body))
self.assertIsNone(data['status'])
self.assertIsNotNone(data['id'])
self.assertIsNotNone(data['encoding'])
url = url.replace('http', 'ws')
ws_url = url + 'ws?id=' + data['id']
ws = yield tornado.websocket.websocket_connect(ws_url)
msg = yield ws.read_message()
self.assertEqual(to_str(msg, data['encoding']), banner)
send = 'h' * (64 * 1024) + '\r\n\r\n'
yield ws.write_message(json.dumps({'data': send}))
lst = []
while True:
msg = yield ws.read_message()
lst.append(msg)
if msg.endswith(b'\r\n\r\n'):
break
recv = b''.join(lst).decode(data['encoding'])
self.assertEqual(send, recv)
ws.close()
...@@ -6,7 +6,7 @@ from tornado.iostream import _ERRNO_CONNRESET ...@@ -6,7 +6,7 @@ from tornado.iostream import _ERRNO_CONNRESET
from tornado.util import errno_from_exception from tornado.util import errno_from_exception
BUF_SIZE = 1024 BUF_SIZE = 32 * 1024
workers = {} workers = {}
...@@ -46,6 +46,8 @@ class Worker(object): ...@@ -46,6 +46,8 @@ class Worker(object):
if self.mode != mode: if self.mode != mode:
self.loop.update_handler(self.fd, mode) self.loop.update_handler(self.fd, mode)
self.mode = mode self.mode = mode
if mode == IOLoop.WRITE:
self.loop.call_later(0.1, self, self.fd, IOLoop.WRITE)
def on_read(self): def on_read(self):
logging.debug('worker {} on read'.format(self.id)) logging.debug('worker {} on read'.format(self.id))
......
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