Jericho / ZoomNet

.NET client library for the Zoom.us REST API v2
MIT License
68 stars 48 forks source link

Issue: The DownloadFileAsync method will throw an OutOfMemoryException if the file is too large #342

Closed pvgritsenko-ansible closed 5 months ago

pvgritsenko-ansible commented 5 months ago

I found an issue when we use the DownloadFileAsync method. Since it uses IRequest.AsStream(), this method invokes HttpClient.SendAsync(request, cancellationtoken) and than HttpResponseMessage.Content.ReadAsStreamAsync() for the response message. The HttpResponseMessage.Content.ReadAsStreamAsync() read whole content into the memory buffer and makes the stream from result buffer.

In our project we encountered with following issue: if we receive a large enough file, buffer can overflow.

But I also found (here Streaming Large HTTP Responses) if we call HttpClient.SendAsync with HttpCompletionOption.ResponseHeadersRead flag it just return stream without buffering and we can handle received stream as we want.

So I suggest to use old implementation of DownloadFileAsync in new method, but with HttpCompletionOption.ResponseHeadersRead flag.

May we also need to create issue in Pathoschild repository.

Jericho commented 5 months ago

:tada: This issue has been resolved in version 0.76.0 :tada:

The release is available on:

Your GitReleaseManager bot :package::rocket: