mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-13 14:30:02 -04:00
add old v0.4 code
This commit is contained in:
parent
582bbd4ecd
commit
9205ae1507
14 changed files with 340 additions and 180 deletions
|
@ -83,6 +83,13 @@ CURL* start_request(const char* url, const char* json_params, DataCallback data_
|
|||
curl_easy_setopt(http_handle, CURLOPT_VERBOSE, 1L);
|
||||
}
|
||||
|
||||
if (strcmp(key, "_connect_only") == 0) {
|
||||
curl_easy_setopt(http_handle, CURLOPT_CONNECT_ONLY, 1L);
|
||||
curl_easy_setopt(http_handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
|
||||
curl_easy_setopt(http_handle, CURLOPT_SSL_ENABLE_ALPN, 0L);
|
||||
prevent_cleanup = 1;
|
||||
}
|
||||
|
||||
if (strcmp(key, "method") == 0 && cJSON_IsString(item)) {
|
||||
curl_easy_setopt(http_handle, CURLOPT_CUSTOMREQUEST, item->valuestring);
|
||||
}
|
||||
|
|
24
client/libcurl/tls_socket.c
Normal file
24
client/libcurl/tls_socket.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "curl/curl.h"
|
||||
#include "curl/easy.h"
|
||||
#include "types.h"
|
||||
|
||||
struct WSResult* recv_from_socket(CURL* http_handle, int buffer_size) {
|
||||
size_t nread;
|
||||
char* buffer = malloc(buffer_size);
|
||||
CURLcode res = curl_easy_recv(http_handle, buffer, buffer_size, &nread);
|
||||
|
||||
struct WSResult* result = malloc(sizeof(struct WSResult));
|
||||
result->buffer_size = nread;
|
||||
result->buffer = buffer;
|
||||
result->res = (int) res;
|
||||
result->closed = (nread == 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
int send_to_socket(CURL* http_handle, const char* data, int data_len) {
|
||||
size_t sent;
|
||||
CURLcode res = curl_easy_send(http_handle, data, data_len, &sent);
|
||||
return (int) res;
|
||||
}
|
|
@ -37,7 +37,7 @@ void close_websocket(CURL* http_handle) {
|
|||
}
|
||||
|
||||
//clean up the http handle associated with the websocket, since the main loop can't do this automatically
|
||||
void cleanup_websocket(CURL* http_handle) {
|
||||
void cleanup_handle(CURL* http_handle) {
|
||||
struct RequestInfo *request_info;
|
||||
curl_easy_getinfo(http_handle, CURLINFO_PRIVATE, &request_info);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue