diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2023-03-14 13:00:41 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2023-03-14 13:00:41 +0800 |
commit | 710866e180a9d02c99ad1ce64a2f6bcaff2c975b (patch) | |
tree | 191bf1d87f455a1f2f4d636502eb8bd387ff1fe2 | |
parent | 0a247a34b172d94806fbf3db902d97f7f1e51091 (diff) |
Response now carries URL info just like Emscripten
-rw-r--r-- | interchange.c | 1 | ||||
-rw-r--r-- | interchange/typedefs.h | 1 | ||||
-rw-r--r-- | request.c | 2 |
3 files changed, 4 insertions, 0 deletions
diff --git a/interchange.c b/interchange.c index 88d4d10..8a70bbb 100644 --- a/interchange.c +++ b/interchange.c @@ -110,6 +110,7 @@ void interchange_free_response(interchange_response *response) #ifdef __EMSCRIPTEN__ emscripten_fetch_close(response); #else + free(response->url); free(response->data); curl_easy_cleanup(response->curl); free(response); diff --git a/interchange/typedefs.h b/interchange/typedefs.h index 02a412f..a799671 100644 --- a/interchange/typedefs.h +++ b/interchange/typedefs.h @@ -9,6 +9,7 @@ typedef emscripten_fetch_t interchange_response; #include <curl/curl.h> typedef struct { void *userData; + char *url; char *data; size_t numBytes; CURL *curl; @@ -160,6 +160,8 @@ void request(void (*handler)(interchange_response *), void (*callback)(void *), curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, append); interchange_response *response = malloc(sizeof(interchange_response)); + response->url = malloc(length + 1); + strcpy(response->url, url); response->data = malloc(1); response->numBytes = 0; response->userData = callback; |