Skip to content

Commit 5ae21e7

Browse files
committed
Add compatibility to aiohttp to 2.2.5 and bump version
aiohttp 2 added a maximum size to requests which we needed to increase for the fake API server to upload large blobs. I've set the request size on the callback server to 8192 bytes which should be sufficient for any incoming data from the Threema gateway server. (Note that downloading large blobs is unaffected by this size limitation.)
1 parent c279440 commit 5ae21e7

4 files changed

Lines changed: 12 additions & 10 deletions

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def read(file):
5858
'logbook>=1.1.0,<2',
5959
'libnacl>=1.5.2,<2',
6060
'click>=6.7,<7', # doesn't seem to follow semantic versioning
61-
'aiohttp>=1.3.5,<2',
61+
'aiohttp>=2.2.5,<3',
6262
'wrapt>=1.10.10,<2',
6363
],
6464
tests_require=tests_require,

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,8 @@ def api_server_port():
377377
@pytest.fixture(scope='module')
378378
def api_server(request, event_loop, api_server_port, server):
379379
port = api_server_port
380-
app = web.Application(loop=event_loop, router=server.router)
380+
app = web.Application(
381+
loop=event_loop, router=server.router, client_max_size=100 * (2**20))
381382
handler = app.make_handler()
382383

383384
# Set up server

threema/gateway/bin/gateway_client.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import logbook
1212
import logbook.more
1313

14-
from aiohttp.client_exceptions import ServerFingerprintMismatch
15-
1614
from threema.gateway import __version__ as _version
1715
from threema.gateway import (
1816
Connection,
@@ -465,12 +463,11 @@ def main():
465463
exc = None
466464
try:
467465
cli()
466+
except aiohttp.client_exceptions.ServerFingerprintMismatch:
467+
error = 'Fingerprints did not match!'
468468
except Exception as exc_:
469-
if isinstance(exc_, ServerFingerprintMismatch):
470-
error = 'Fingerprints did not match!'
471-
else:
472-
error = str(exc_)
473-
exc = exc_
469+
error = str(exc_)
470+
exc = exc_
474471
else:
475472
error = None
476473

threema/gateway/e2e.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ def create_router(self):
167167

168168
# noinspection PyMethodMayBeStatic
169169
def create_application(self, router, loop):
170-
return web.Application(router=router, loop=loop)
170+
# A box can contain up to 4000 bytes, so this should be sufficient.
171+
# The remaining POST parameters aren't that big.
172+
# See: https://gateway.threema.ch/en/developer/api
173+
request_size_max = 8192
174+
return web.Application(router=router, loop=loop, client_max_size=request_size_max)
171175

172176
def create_handler(self):
173177
return self.application.make_handler()

0 commit comments

Comments
 (0)