update curl and fix memory error with websockets

This commit is contained in:
ading2210 2025-01-22 16:10:44 -05:00
parent 8b53625743
commit 5c3c591a41
4 changed files with 19 additions and 13 deletions

View file

@ -111,14 +111,12 @@ class CurlWebSocket extends CurlSession {
} }
cleanup(error=0) { cleanup(error=0) {
if (this.http_handle) { if (!this.connected)
this.remove_request(this.http_handle); return;
this.http_handle = null; if (this.recv_loop)
super.close(); clearInterval(this.recv_loop);
}
else return; super.close();
clearInterval(this.recv_loop);
this.connected = false; this.connected = false;
if (error) { if (error) {

View file

@ -18,9 +18,17 @@ struct WSResult* recv_from_websocket(CURL* http_handle, int buffer_size) {
result->buffer_size = result_len; result->buffer_size = result_len;
result->buffer = buffer; result->buffer = buffer;
result->res = (int) res; result->res = (int) res;
result->closed = (ws_meta->flags & CURLWS_CLOSE); //ws_meta will be null if the recv is not successful, so don't try reading it otherwise
result->is_text = (ws_meta->flags & CURLWS_TEXT); if (res == CURLE_OK) {
result->bytes_left = ws_meta->bytesleft; result->closed = (ws_meta->flags & CURLWS_CLOSE);
result->is_text = (ws_meta->flags & CURLWS_TEXT);
result->bytes_left = ws_meta->bytesleft;
}
else {
result->closed = -1;
result->is_text = -1;
result->bytes_left = -1;
}
return result; return result;
} }

View file

@ -1,6 +1,6 @@
{ {
"name": "libcurl.js", "name": "libcurl.js",
"version": "0.6.22", "version": "0.7.0",
"description": "A port of libcurl to WebAssembly, for proxying HTTPS requests from the browser with full TLS encryption", "description": "A port of libcurl to WebAssembly, for proxying HTTPS requests from the browser with full TLS encryption",
"main": "libcurl.mjs", "main": "libcurl.mjs",
"exports": { "exports": {

View file

@ -14,7 +14,7 @@ NGHTTP2_PREFIX=$(realpath build/nghttp2-wasm)
cd build cd build
rm -rf curl rm -rf curl
git clone -b curl-8_10_1 --depth=1 https://github.com/curl/curl git clone -b curl-8_11_1 --depth=1 https://github.com/curl/curl
cd curl cd curl
autoreconf -fi autoreconf -fi