Set wxWebResponseCURL buffer size as soon as known

Currently for wxWebRequestCURL objects using memory storage, a download
is processed by appending to a wxMemoryBuffer each time the write
callback is called. For a large transfer, this can result in many, many
reallocation calls and can block the main application.

This commit uses the progress callback for wxWebRequestCURL objects
added in a previous commit to set a minimum size for the buffer as soon
as it is known.
This commit is contained in:
New Pagodi
2021-02-07 20:43:51 -06:00
parent 3e5fd5462d
commit 48cba4f88e
4 changed files with 25 additions and 4 deletions

View File

@@ -114,11 +114,12 @@ public:
// Methods called from libcurl callbacks
size_t CURLOnWrite(void *buffer, size_t size);
size_t CURLOnHeader(const char* buffer, size_t size);
int CURLOnProgress();
int CURLOnProgress(curl_off_t);
private:
wxWebRequestHeaderMap m_headers;
wxString m_statusText;
wxFileOffset m_knownDownloadSize;
CURL* GetHandle() const
{ return static_cast<wxWebRequestCURL&>(m_request).GetHandle(); }