refactor request code

This commit is contained in:
ading2210 2024-03-12 17:12:02 -04:00
parent 0d7369c77a
commit 1748ca7dd9
12 changed files with 222 additions and 194 deletions

View file

@ -4,6 +4,7 @@
#include "curl/websockets.h"
#include "types.h"
#include "util.h"
extern CURLM* multi_handle;
@ -36,14 +37,10 @@ void close_websocket(CURL* http_handle) {
curl_ws_send(http_handle, "", 0, &sent, 0, CURLWS_CLOSE);
}
//clean up the http handle associated with the websocket, since the main loop can't do this automatically
void cleanup_handle(CURL* http_handle) {
struct RequestInfo *request_info;
curl_easy_getinfo(http_handle, CURLINFO_PRIVATE, &request_info);
curl_multi_remove_handle(multi_handle, http_handle);
curl_easy_cleanup(http_handle);
free(request_info);
void websocket_set_options(CURL* http_handle) {
struct RequestInfo *request_info = get_handle_info(http_handle);
curl_easy_setopt(http_handle, CURLOPT_CONNECT_ONLY, 2L);
request_info->prevent_cleanup = 1;
}
int get_result_size (const struct WSResult* result) {