Add a progress callback for wxWebRequestCURL

This commit adds a progress callback for use with wxWebRequestCURL
objects. This has some complications because over the years curl has
changed the signature of the callback.

A combination of compile-time and run-time checks is used to make sure
the appropriate callback and preferred return value are used.
This commit is contained in:
New Pagodi
2021-02-07 20:37:47 -06:00
parent f406fcd12a
commit 3e5fd5462d
2 changed files with 66 additions and 6 deletions

View File

@@ -114,6 +114,7 @@ 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();
private:
wxWebRequestHeaderMap m_headers;
@@ -149,6 +150,9 @@ public:
void CancelRequest(wxWebRequestCURL* request);
static bool CurlRuntimeAtLeastVersion(unsigned int, unsigned int,
unsigned int);
private:
static int TimerCallback(CURLM*, long, void*);
static int SocketCallback(CURL*, curl_socket_t, int, void*, void*);
@@ -165,6 +169,7 @@ private:
CURLM* m_handle;
static int ms_activeSessions;
static unsigned int ms_runtimeVersion;
wxDECLARE_NO_COPY_CLASS(wxWebSessionCURL);
};