Skip to content

Restore the global client for the purposes of streaming responses

Andrej Shadura requested to merge fix-streaming-responses into main

When we proxy huge binary downloads from the repserver or the srcserver, we create a subtask pulling the data from the backend, and hand it over to Quart, which runs the task and streams the data back to the client. If we use a context-bound httpx client, this subtask gets essentially killed before it can even get started.

For this purpose, restore the global client, mark it clearly as such, use it only in the two places in the server where this is difficult to otherwise avoid. At the same time, wrap the response iterator in try...finally to ensure there is no resource leak in case an exception occurs.

Add a test to try to stream getbinaries request from the source server.

Edited by Andrej Shadura

Merge request reports