stop handing out Request Entity Too Large errors

This commit is contained in:
Kay Faraday 2021-09-08 02:40:34 +00:00
parent 695c7145af
commit 00c30d2af0
2 changed files with 8 additions and 1 deletions

4
app.py
View File

@ -4,6 +4,7 @@
import io
import os
import sys
import utils
import random
import asyncio
import aiohttp
@ -60,7 +61,8 @@ async def handler(request):
return resp
async def amain():
srv = web.Server(handler)
# It's not our job to hand out 413s, that's the job of upstream and downstream
srv = web.Server(handler, request_factory=utils.make_unlimited_request)
runner = web.ServerRunner(srv)
await runner.setup()
bind = os.path.expandvars(config['bind'])

View File

@ -1,8 +1,10 @@
# SPDX-License-Identifier: AGPL-3.0-only
import random
import asyncio
import contextlib
import contextvars
from aiohttp import web
class ContextVar:
"""
@ -32,3 +34,6 @@ def build_dprint(debug: bool):
return lambda *args, **kwargs: None
return dprint
def make_unlimited_request(*args):
return web.BaseRequest(*args, loop=asyncio.get_running_loop(), client_max_size=None)