mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-13 22:40:01 -04:00
update curl and fix memory error with websockets
This commit is contained in:
parent
8b53625743
commit
5c3c591a41
4 changed files with 19 additions and 13 deletions
|
@ -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();
|
|
||||||
}
|
|
||||||
else return;
|
|
||||||
|
|
||||||
clearInterval(this.recv_loop);
|
clearInterval(this.recv_loop);
|
||||||
|
|
||||||
|
super.close();
|
||||||
this.connected = false;
|
this.connected = false;
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
|
@ -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;
|
||||||
|
//ws_meta will be null if the recv is not successful, so don't try reading it otherwise
|
||||||
|
if (res == CURLE_OK) {
|
||||||
result->closed = (ws_meta->flags & CURLWS_CLOSE);
|
result->closed = (ws_meta->flags & CURLWS_CLOSE);
|
||||||
result->is_text = (ws_meta->flags & CURLWS_TEXT);
|
result->is_text = (ws_meta->flags & CURLWS_TEXT);
|
||||||
result->bytes_left = ws_meta->bytesleft;
|
result->bytes_left = ws_meta->bytesleft;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result->closed = -1;
|
||||||
|
result->is_text = -1;
|
||||||
|
result->bytes_left = -1;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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": {
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue