Stream requests to ingress (#2979)

* Chunk large requests to ingress

* Remove timout for POST

* No timeout

* stream

* Remove chunked
This commit is contained in:
Joakim Sørensen 2021-06-26 19:31:15 +02:00 committed by GitHub
parent 564e9811d0
commit 8a9657c452
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,7 @@ import logging
from typing import Any, Dict, Union from typing import Any, Dict, Union
import aiohttp import aiohttp
from aiohttp import hdrs, web from aiohttp import ClientTimeout, hdrs, web
from aiohttp.web_exceptions import ( from aiohttp.web_exceptions import (
HTTPBadGateway, HTTPBadGateway,
HTTPServiceUnavailable, HTTPServiceUnavailable,
@ -162,7 +162,6 @@ class APIIngress(CoreSysAttributes):
) -> Union[web.Response, web.StreamResponse]: ) -> Union[web.Response, web.StreamResponse]:
"""Ingress route for request.""" """Ingress route for request."""
url = self._create_url(addon, path) url = self._create_url(addon, path)
data = await request.read()
source_header = _init_header(request, addon) source_header = _init_header(request, addon)
async with self.sys_websession.request( async with self.sys_websession.request(
@ -171,7 +170,8 @@ class APIIngress(CoreSysAttributes):
headers=source_header, headers=source_header,
params=request.query, params=request.query,
allow_redirects=False, allow_redirects=False,
data=data, data=request.content,
timeout=ClientTimeout(total=None),
) as result: ) as result:
headers = _response_header(result) headers = _response_header(result)
@ -219,6 +219,7 @@ def _init_header(
if name in ( if name in (
hdrs.CONTENT_LENGTH, hdrs.CONTENT_LENGTH,
hdrs.CONTENT_ENCODING, hdrs.CONTENT_ENCODING,
hdrs.TRANSFER_ENCODING,
hdrs.SEC_WEBSOCKET_EXTENSIONS, hdrs.SEC_WEBSOCKET_EXTENSIONS,
hdrs.SEC_WEBSOCKET_PROTOCOL, hdrs.SEC_WEBSOCKET_PROTOCOL,
hdrs.SEC_WEBSOCKET_VERSION, hdrs.SEC_WEBSOCKET_VERSION,