mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Add async_iterable_to_stream utility to avoid aiohttp compatibility issues
Create async_iterable_to_stream() in gns3server.utils.asyncio that converts an async iterable to an aiohttp StreamReader via a background feeder task. This bypasses aiohttp's AsyncIterablePayload which can cause 'Connection reset by peer' with certain HTTP servers. Use it in _run_http_query for the __aiter__ data path.
This commit is contained in:
2 files changed
+43
-1
No files matched your search
@@ -32,7 +32,7 @@ else:
|
||||
from async_timeout import timeout as asynctimeout
|
||||
|
||||
from ..utils import parse_version
|
||||
from ..utils.asyncio import locking
|
||||
from ..utils.asyncio import locking, async_iterable_to_stream
|
||||
from ..controller.controller_error import (
|
||||
ControllerError,
|
||||
ControllerBadRequestError,
|
||||
@@ -537,6 +537,7 @@ class Compute:
|
||||
elif hasattr(data, "__aiter__"):
|
||||
chunked = True
|
||||
headers["content-type"] = "application/octet-stream"
|
||||
data = await async_iterable_to_stream(data)
|
||||
# If the data is an open file we will iterate on it
|
||||
elif isinstance(data, io.BufferedIOBase):
|
||||
chunked = True
|
||||
|
||||
Reference in new issue
Block a user