From 710866e180a9d02c99ad1ce64a2f6bcaff2c975b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Tue, 14 Mar 2023 13:00:41 +0800 Subject: Response now carries URL info just like Emscripten --- interchange.c | 1 + interchange/typedefs.h | 1 + request.c | 2 ++ 3 files changed, 4 insertions(+) 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 typedef struct { void *userData; + char *url; char *data; size_t numBytes; CURL *curl; diff --git a/request.c b/request.c index e8dfcf7..32e46f0 100644 --- a/request.c +++ b/request.c @@ -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; -- cgit v1.2.3