diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2022-02-02 09:29:10 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2022-02-02 09:29:10 +0800 |
commit | 12cde42c929b63a1ef1b2ad7f3482336419980b2 (patch) | |
tree | 3c7e7185909432068985da6bb739bf34d67fcd58 /post.h | |
parent | ebfa1718a36a8a0f3cf4571bc48b1990129af703 (diff) |
Asynchronous connection
Important updates:
1. Emscripten port.
2. HTTP request code copied from libicclient & slightly fixed.
3. Cookies, for maintaining authorisation between different async
handles.
Diffstat (limited to 'post.h')
-rw-r--r-- | post.h | 43 |
1 files changed, 0 insertions, 43 deletions
@@ -1,43 +0,0 @@ -#ifndef RTCLIENT_POST_H -#define RTCLIENT_POST_H - -#include "request.h" - -inline void post(const char *path, const char *pairs[], size_t n) -{ - size_t length = 0; - for (size_t i = 0; i < n; i += 2) { - const char *pair = pairs[i]; - if (pair && strcmp(pair, "")) - length += strlen(pair) + strlen(pairs[i + 1]) + 3; - } - - char content[length + 1]; - memset(content, 0, strlen(content)); - for (size_t i = 0; i < n; i += 2) { - const char *pair = pairs[i]; - if (pair && strcmp(pair, "")) - sprintf(content, "%s%s: %s\n", content, pairs[i + 1] - , pair); - } -#ifdef DEBUG -#ifdef ANDROID - __android_log_print(ANDROID_LOG_DEBUG, "librtclient", "%s\nContent:\n%s" - , __func__, content); -#else - fprintf(stderr, "%s\nContent:\n%s", __func__, content); -#endif // ANDROID -#endif // DEBUG - - struct curl_httppost *post, *last = NULL; - curl_formadd(&post, &last - , CURLFORM_COPYNAME, "content" - , CURLFORM_PTRCONTENTS, content - , CURLFORM_END); - last = NULL; - request(NULL, NULL, post, "%s", path); - curl_formfree(post); - post = NULL; -} - -#endif // RTCLIENT_POST_H |