diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-06-12 08:20:13 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-06-12 08:20:13 +0800 |
commit | a7f4dba7c9c0738545c8b41b4185bd5ec9feb099 (patch) | |
tree | 22e09f3619686cecedcf2ebc9be3a54d210f90a8 | |
parent | 0f4ce6386fcbe19544392d3bdc88664674b7a04b (diff) |
Gather request related commands by API
-rw-r--r-- | request.h | 21 |
1 files changed, 4 insertions, 17 deletions
@@ -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 |