From 997b2afca49b7ba25e3da056e360a351d88b973f Mon Sep 17 00:00:00 2001 From: ading2210 Date: Sat, 9 Mar 2024 18:48:55 -0500 Subject: [PATCH] support older browsers --- CHANGELOG.md | 2 +- README.md | 9 +++++---- client/javascript/main.js | 6 ++---- client/tools/curl.sh | 2 +- client/tools/openssl.sh | 2 +- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c852d48..c79b9fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Libcurl.js Changelog: ## v0.5.0 (3/8/24): -- Added support for readable streams in the response +- Added support for streaming HTTP responses via a readable stream ## v0.4.2 (3/7/24): - Expose a function to get error strings diff --git a/README.md b/README.md index de0f0bc..74e4912 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ This is an experimental port of [libcurl](https://curl.se/libcurl/) to WebAssemb - [Copyright](#copyright) * [Copyright Notice](#copyright-notice) -Table of contents generated with markdown-toc +Table of contents generated with [markdown-toc](http://ecotrust-canada.github.io/markdown-toc/). ## Features: - Fetch compatible API @@ -32,7 +32,8 @@ This is an experimental port of [libcurl](https://curl.se/libcurl/) to WebAssemb - Low latency via multiplexing and reusing open connections - Use raw TLS sockets in the browser - Custom network transport support -- Works inside web workers but does not need special permissions or headers +- Works inside web workers without needing special permissions or headers +- Works in all major browsers (Chromium >= 64, Firefox >= 65, Safari >= 14) ## Building: You can build this project by running the following commands: @@ -96,9 +97,9 @@ Most of the standard Fetch API's features are supported, with the exception of: - Sending credentials/cookies automatically - Caching -The response may contain multiple HTTP headers with the same name, which the `Headers` object isn't able to properly represent. If this matters to you, use `response.raw_headers`, which is an array of key value pairs, instead of `response.headers`. +The response may contain multiple HTTP headers with the same name, which the `Headers` object isn't able to properly represent. If this matters to you, use `response.raw_headers`, which is an array of key value pairs, instead of `response.headers`. There is support for streaming the response body using a `ReadableStream`. -Note that there is a hard limit of 50 active TCP connections due to emscripten limitations. +Also note that there is a hard limit of 50 active TCP connections due to emscripten limitations. ### Creating WebSocket Connections: To use WebSockets, create a `libcurl.CurlWebSocket` object, which takes the following arguments: diff --git a/client/javascript/main.js b/client/javascript/main.js index d2de20f..48644b7 100644 --- a/client/javascript/main.js +++ b/client/javascript/main.js @@ -181,16 +181,14 @@ function perform_request_async(url, params, body) { stream_controller = controller; } }); - + function data_callback(new_data) { stream_controller.enqueue(new_data); - }; - + } function headers_callback(response_info) { let response_obj = create_response(stream, response_info); resolve(response_obj); } - function finish_callback(error) { if (error != 0) { let error_str = `Request failed with error code ${error}: ${get_error_str(error)}`; diff --git a/client/tools/curl.sh b/client/tools/curl.sh index cf286a5..bd6ee25 100755 --- a/client/tools/curl.sh +++ b/client/tools/curl.sh @@ -19,7 +19,7 @@ cd curl autoreconf -fi emconfigure ./configure --host i686-linux --disable-shared --disable-threaded-resolver --without-libpsl --disable-netrc --disable-ipv6 --disable-tftp --disable-ntlm-wb --enable-websockets --with-ssl=$OPENSSL_PREFIX --with-zlib=$ZLIB_PREFIX --with-brotli=$BROTLI_PREFIX --with-nghttp2=$NGHTTP2_PREFIX -emmake make -j$CORE_COUNT CFLAGS="-pthread" LIBS="-lbrotlicommon" +emmake make -j$CORE_COUNT LIBS="-lbrotlicommon" rm -rf $PREFIX mkdir -p $PREFIX/include diff --git a/client/tools/openssl.sh b/client/tools/openssl.sh index 014f5c3..ad4c47f 100755 --- a/client/tools/openssl.sh +++ b/client/tools/openssl.sh @@ -16,7 +16,7 @@ cd openssl export CFLAGS="-Wall -Oz" export CXXFLAGS="-Wall -Oz" -emconfigure ./Configure linux-x32 --prefix=$PREFIX -no-asm -static -no-afalgeng -no-dso -DOPENSSL_SYS_NETWARE -DSIG_DFL=0 -DSIG_IGN=0 -DHAVE_FORK=0 -DOPENSSL_NO_AFALGENG=1 -DOPENSSL_NO_SPEED=1 -DOPENSSL_NO_DYNAMIC_ENGINE -DDLOPEN_FLAG=0 +emconfigure ./Configure linux-x32 --prefix=$PREFIX -no-asm -static -no-afalgeng -no-dso -no-threads -DOPENSSL_SYS_NETWARE -DSIG_DFL=0 -DSIG_IGN=0 -DHAVE_FORK=0 -DOPENSSL_NO_AFALGENG=1 -DOPENSSL_NO_SPEED=1 -DOPENSSL_NO_DYNAMIC_ENGINE -DDLOPEN_FLAG=0 sed -i 's|^CROSS_COMPILE.*$|CROSS_COMPILE=|g' Makefile emmake make -j$CORE_COUNT build_generated libssl.a libcrypto.a