mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-11 13:30:01 -04:00
throw error objects instead of plain strings, update wisp server
This commit is contained in:
parent
3c1a942501
commit
c1b78e1d0c
11 changed files with 16 additions and 15 deletions
|
@ -1,5 +1,9 @@
|
|||
# Libcurl.js Changelog:
|
||||
|
||||
## v0.6.16 (10/2/24):
|
||||
- Fix a bug with `Headers` objects and `Request` objects not being properly handled when passed into `libcurl.fetch`
|
||||
- Errors thrown are now `Error` or `TypeError` objects instead of plain strings
|
||||
|
||||
## v0.6.15 (9/6/24):
|
||||
- WolfSSL has been downgraded to v5.6.6 due to an upstream regression
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ try {
|
|||
ws = new WebSocket(url);
|
||||
}
|
||||
else if (typeof api.transport === "string") {
|
||||
throw "invalid transport type";
|
||||
throw new TypeError("invalid transport type");
|
||||
}
|
||||
else { //custom transports
|
||||
ws = new api.transport(url);
|
||||
|
|
|
@ -67,13 +67,13 @@ class HTTPSession extends CurlSession {
|
|||
}
|
||||
if (error > 0) {
|
||||
error_msg(`Request "${url}" failed with error code ${error}: ${get_error_str(error)}`);
|
||||
reject(`Request failed with error code ${error}: ${get_error_str(error)}`);
|
||||
reject(new TypeError(`Request failed with error code ${error}: ${get_error_str(error)}`));
|
||||
}
|
||||
else if (error === -1) {
|
||||
reject(new DOMException("The operation was aborted."));
|
||||
}
|
||||
else if (error === -2) {
|
||||
reject("Request failed because redirects were disallowed.");
|
||||
reject(new TypeError("Request failed because redirects were disallowed."));
|
||||
}
|
||||
this.remove_request(http_handle);
|
||||
http_handle = null;
|
||||
|
|
|
@ -139,7 +139,7 @@ api = {
|
|||
CurlWebSocket: CurlWebSocket,
|
||||
TLSSocket: TLSSocket,
|
||||
HTTPSession: HTTPSession,
|
||||
fetch() {throw "not ready"},
|
||||
fetch() {throw new Error("not ready")},
|
||||
|
||||
get copyright() {return copyright_notice},
|
||||
get version() {return get_version()},
|
||||
|
|
|
@ -24,7 +24,7 @@ class CurlSession {
|
|||
|
||||
assert_ready() {
|
||||
if (!this.session_ptr) {
|
||||
throw "session has been removed";
|
||||
throw new Error("session has been removed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ function data_to_array(data) {
|
|||
return new Uint8Array(data.buffer);
|
||||
}
|
||||
|
||||
throw "invalid data type to be sent";
|
||||
throw new TypeError("invalid data type to be sent");
|
||||
}
|
||||
|
||||
//c function wrapper
|
||||
|
|
|
@ -62,7 +62,7 @@ class FakeWebSocket extends EventTarget {
|
|||
converted = data.buffer;
|
||||
}
|
||||
else {
|
||||
throw "invalid binaryType string";
|
||||
throw new TypeError("invalid binaryType string");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
{
|
||||
"name": "libcurl.js",
|
||||
"version": "0.6.15",
|
||||
"description": "An experimental port of libcurl to WebAssembly for use in the browser.",
|
||||
"version": "0.6.16",
|
||||
"description": "A port of libcurl to WebAssembly, for proxying HTTPS requests from the browser with full TLS encryption",
|
||||
"main": "libcurl.mjs",
|
||||
"exports": {
|
||||
".": "./libcurl.mjs",
|
||||
"./bundled": "./libcurl_full.mjs"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ading2210/libcurl.js.git"
|
||||
|
|
|
@ -4,7 +4,7 @@ set -e
|
|||
|
||||
trap "exit" INT TERM
|
||||
trap "kill 0" EXIT
|
||||
../server/run.sh --static=$(pwd) >/dev/null &
|
||||
../server/run.sh --static=$(pwd) --log-level=WARN >/dev/null &
|
||||
|
||||
echo -n "waiting for wisp server to start"
|
||||
i=0
|
||||
|
|
|
@ -13,7 +13,7 @@ if [ ! -d "$SERVER_PATH.venv" ]; then
|
|||
fi
|
||||
source $SERVER_PATH/.venv/bin/activate
|
||||
|
||||
if ! python3 -c "import websockets, asyncudp" 2> /dev/null; then
|
||||
if ! python3 -c "import websockets, asyncudp, uvloop" 2> /dev/null; then
|
||||
pip3 install -e $SERVER_PATH
|
||||
fi
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit b7cfab072b04dbd4345aedaf5e47c9e0d57ab873
|
||||
Subproject commit 78f872c8e5b180e26ec09cc126e841e12ac75c36
|
Loading…
Add table
Add a link
Reference in a new issue