mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Fixed bug with ?_trace=1 and large responses, closes #2404
This commit is contained in:
parent
9028d7f805
commit
34a6b2ac84
3 changed files with 23 additions and 1 deletions
|
|
@ -90,6 +90,7 @@ class AsgiTracer:
|
|||
|
||||
async def wrapped_send(message):
|
||||
nonlocal accumulated_body, size_limit_exceeded, response_headers
|
||||
|
||||
if message["type"] == "http.response.start":
|
||||
response_headers = message["headers"]
|
||||
await send(message)
|
||||
|
|
@ -102,11 +103,12 @@ class AsgiTracer:
|
|||
# Accumulate body until the end or until size is exceeded
|
||||
accumulated_body += message["body"]
|
||||
if len(accumulated_body) > self.max_body_bytes:
|
||||
# Send what we have accumulated so far
|
||||
await send(
|
||||
{
|
||||
"type": "http.response.body",
|
||||
"body": accumulated_body,
|
||||
"more_body": True,
|
||||
"more_body": bool(message.get("more_body")),
|
||||
}
|
||||
)
|
||||
size_limit_exceeded = True
|
||||
|
|
|
|||
|
|
@ -62,10 +62,13 @@ class TestClient:
|
|||
follow_redirects=False,
|
||||
redirect_count=0,
|
||||
method="GET",
|
||||
params=None,
|
||||
cookies=None,
|
||||
if_none_match=None,
|
||||
headers=None,
|
||||
):
|
||||
if params:
|
||||
path += "?" + urlencode(params, doseq=True)
|
||||
return await self._request(
|
||||
path=path,
|
||||
follow_redirects=follow_redirects,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue