From a7f4dba7c9c0738545c8b41b4185bd5ec9feb099 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: Sat, 12 Jun 2021 08:20:13 +0800 Subject: Gather request related commands by API --- request.h | 21 ++++----------------- 1 file 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 -- cgit v1.2.3