mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-13 14:30:02 -04:00
refactor request code
This commit is contained in:
parent
0d7369c77a
commit
1748ca7dd9
12 changed files with 222 additions and 194 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue