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]>