Skip to content

Commit 8dea666

Browse files
authored
release 0.0.313 (#48)
* fix ASGI app return empty str * independent max payload size for ws --------- Co-authored-by: nggit <[email protected]>
1 parent c7821df commit 8dea666

File tree

9 files changed

+18
-8
lines changed

9 files changed

+18
-8
lines changed

alltests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
port=HTTP_PORT,
2222
debug=False,
2323
reload=True,
24-
client_max_body_size=73728))
24+
client_max_body_size=73728,
25+
ws_max_payload_size=73728))
2526
)
2627
processes.append(mp.Process(
2728
target=tremolo.run,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name='tremolo',
10-
version='0.0.312',
10+
version='0.0.313',
1111
license='MIT',
1212
author='nggit',
1313
author_email='[email protected]',

tests/http_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,6 @@ async def reload(request=None, **_):
310310

311311
if __name__ == '__main__':
312312
app.run(HTTP_HOST, port=HTTP_PORT, debug=True, reload=True,
313-
client_max_body_size=73728)
313+
client_max_body_size=73728, ws_max_payload_size=73728)
314314

315315
# END

tests/test_http_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,8 @@ def test_reload(self):
821821
port=HTTP_PORT,
822822
debug=False,
823823
reload=True,
824-
client_max_body_size=73728)
824+
client_max_body_size=73728,
825+
ws_max_payload_size=73728)
825826
)
826827

827828
p.start()

tremolo/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '0.0.312'
1+
__version__ = '0.0.313'
22

33
from .tremolo import Tremolo # noqa: E402
44
from . import exceptions # noqa: E402,F401

tremolo/__main__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
print(' --reload Enable auto reload on code changes')
3838
print(' Intended for development')
3939
print(' --no-ws Disable built-in WebSocket support')
40+
print(' --ws-max-payload-size Maximum payload size for the built-in WebSocket') # noqa: E501
41+
print(' Defaults to 2 * 1048576, or 2MiB')
4042
print(' --log-level Defaults to "DEBUG". See')
4143
print(' https://docs.python.org/3/library/logging.html#levels') # noqa: E501
4244
print(' --download-rate Limits the sending speed to the client') # noqa: E501
@@ -77,6 +79,7 @@
7779
'--download-rate',
7880
'--upload-rate',
7981
'--buffer-size',
82+
'--ws-max-payload-size',
8083
'--client-max-body-size',
8184
'--client-max-header-size',
8285
'--max-queue-size',

tremolo/asgi_server.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,9 @@ async def send(self, data):
255255
)
256256

257257
if 'more_body' not in data or data['more_body'] is False:
258-
await self.response.write(b'', throttle=False)
258+
await self.response.write(
259+
b'', chunked=self._http_chunked, throttle=False
260+
)
259261
self.response.close(keepalive=True)
260262

261263
self._read = None

tremolo/lib/websocket.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ async def recv(self):
4646
payload_length = int.from_bytes(await self.request.recv(8),
4747
byteorder='big')
4848

49-
if payload_length > self.protocol.options['client_max_body_size']:
49+
if payload_length > self.protocol.options['ws_max_payload_size']:
5050
raise WebSocketServerClosed(
5151
'%d exceeds maximum payload size (%d)' % (
5252
payload_length,
53-
self.protocol.options['client_max_body_size']),
53+
self.protocol.options['ws_max_payload_size']),
5454
code=1009
5555
)
5656

tremolo/tremolo.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@ async def _serve(self, host, port, **options):
335335
worker=context,
336336
debug=options.get('debug', False),
337337
ws=options.get('ws', True),
338+
ws_max_payload_size=options.get(
339+
'ws_max_payload_size', 2 * 1048576
340+
),
338341
download_rate=options.get('download_rate', 1048576),
339342
upload_rate=options.get('upload_rate', 1048576),
340343
buffer_size=options.get('buffer_size', 16 * 1024),

0 commit comments

Comments
 (0)