summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-06-12 08:20:13 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-06-12 08:20:13 +0800
commita7f4dba7c9c0738545c8b41b4185bd5ec9feb099 (patch)
tree22e09f3619686cecedcf2ebc9be3a54d210f90a8
parent0f4ce6386fcbe19544392d3bdc88664674b7a04b (diff)
Gather request related commands by API
-rw-r--r--request.h21
1 files changed, 4 insertions, 17 deletions
diff --git a/request.h b/request.h
index 73b26d8..b65985c 100644
--- a/request.h
+++ b/request.h
@@ -86,34 +86,21 @@ inline void request(icclient_handler writefunction, void *writedata,
#ifdef __EMSCRIPTEN__
attr.onsuccess = writefunction;
+ if (writedata)
+ attr.userData = writedata;
+ strcpy(attr.requestMethod, "GET");
+ emscripten_fetch(&attr, url);
#else
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunction);
-#endif
if (writedata)
-#ifdef __EMSCRIPTEN__
- attr.userData = writedata;
-#else
curl_easy_setopt(curl, CURLOPT_WRITEDATA, writedata);
else
curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout);
-#endif
if (post)
-#ifdef __EMSCRIPTEN__
- strcpy(attr.requestMethod, "POST");
-#else
curl_easy_setopt(curl, CURLOPT_HTTPPOST, post);
-#endif
else
-#ifdef __EMSCRIPTEN__
- strcpy(attr.requestMethod, "GET");
-#else
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
-#endif
-
-#ifdef __EMSCRIPTEN__
- emscripten_fetch(&attr, url);
-#else
#ifdef DEBUG
CURLcode res =
#endif