bugfixes for websocket api

This commit is contained in:
ading2210 2024-03-20 17:53:39 -04:00
parent 7284487430
commit 3a50060e07
7 changed files with 13 additions and 10 deletions

View file

@ -106,7 +106,7 @@ api = {
WispConnection: WispConnection,
transport: "wisp",
WebSocket: WebSocket,
WebSocket: FakeWebSocket,
CurlWebSocket: CurlWebSocket,
TLSSocket: TLSSocket,
HTTPSession: HTTPSession,

View file

@ -132,7 +132,7 @@ class CurlSession {
catch (e) {
//the readable stream has been closed elsewhere, so cancel the request
if (e instanceof TypeError) {
finish_callback(-1);
end_callback(-1);
}
else {
throw e;

View file

@ -107,7 +107,7 @@ class CurlWebSocket extends CurlSession {
cleanup(error=0) {
if (this.http_handle) {
this.remove_handle(this.http_handle);
this.remove_request(this.http_handle);
this.http_handle = null;
super.close();
}

View file

@ -1,6 +1,6 @@
{
"name": "libcurl.js",
"version": "0.6.1",
"version": "0.6.3",
"description": "An experimental port of libcurl to WebAssembly for use in the browser.",
"main": "libcurl.mjs",
"exports": {

View file

@ -1,8 +1,8 @@
function test() {
let message_len = 128*1024;
let message_len = 1024;
return new Promise((resolve, reject) => {
let ws = new libcurl.WebSocket("wss://echo.websocket.org");
let ws = new libcurl.WebSocket("wss://echo.websocket.in/");
ws.addEventListener("open", () => {
ws.send("hello".repeat(message_len));
});
@ -12,8 +12,8 @@ function test() {
messages += 1;
if (messages >= 2) {
if (event.data !== "hello".repeat(message_len)) reject("unexpected response");
if (messages >= 11) resolve();
ws.send("hello".repeat(message_len));
else if (messages >= 11) resolve();
else ws.send("hello".repeat(message_len));
}
});