hsa: make http client do chunked reads/writes to file 52/43152/5
authorSemir Sionek <[email protected]>
Thu, 12 Jun 2025 11:21:01 +0000 (11:21 +0000)
committerFlorin Coras <[email protected]>
Wed, 18 Jun 2025 02:50:57 +0000 (02:50 +0000)
commitf5116517e8e9dd59fe35614dc62035a6c94ebe96
tree23e80101a7c5392ae5d08fd32c499994fb58a9e0
parent2eb0e479bf76b5202d24d4088ea97d86ee5aa0ee
hsa: make http client do chunked reads/writes to file

When using the save-to arg, the http client saves the body of the
response to file. With the current mechanism it would allocate a buffer
as big as the body (up to the limit), iteratively fill it and dump
everything (along with the headers) into the file. This would limit how
big of a response can be saved due to memory constraints and settings,
as well as not reproduce it accurately (e.g the file would need to be
trimmed from the saved headers.

With the new approach, if the response is too big for the max-body-size
settings, we reduce the buffer size to the fifo size, fill it up and
write it to file. We keep the file pointer and write to it, until we have
the response fully saved. The headers are now being displayed through
the cli, similarly to the verbose mode.

Type: improvement
Change-Id: I6a72749bc9c1175aba7769d83984d1d4a40ee9f0
Signed-off-by: Semir Sionek <[email protected]>
extras/hs-test/http_test.go
src/plugins/hs_apps/http_client.c