refactoring

This commit is contained in:
Maxim Devaev 2022-07-23 08:50:20 +03:00
parent 5b11b6bc55
commit 3e402f4d7b
2 changed files with 2 additions and 2 deletions

View File

@ -129,7 +129,7 @@ class MsdApi:
get_logger(0).info("Downloading image %r as %r to MSD ...", url, name) get_logger(0).info("Downloading image %r as %r to MSD ...", url, name)
async with self.__msd.write_image(name, size) as chunk_size: async with self.__msd.write_image(name, size) as chunk_size:
response = await start_streaming(request) response = await start_streaming(request, "application/x-ndjson")
await stream_write_info() await stream_write_info()
last_report_ts = 0 last_report_ts = 0
async for chunk in remote.content.iter_chunked(chunk_size): async for chunk in remote.content.iter_chunked(chunk_size):

View File

@ -187,7 +187,7 @@ def make_json_exception(err: Exception, status: Optional[int]=None) -> Response:
}, status=status) }, status=status)
async def start_streaming(request: Request, content_type: str="application/x-ndjson") -> StreamResponse: async def start_streaming(request: Request, content_type: str) -> StreamResponse:
response = StreamResponse(status=200, reason="OK", headers={"Content-Type": content_type}) response = StreamResponse(status=200, reason="OK", headers={"Content-Type": content_type})
await response.prepare(request) await response.prepare(request)
return response return response