support older browsers

This commit is contained in:
ading2210 2024-03-09 18:48:55 -05:00
parent 9504f9d167
commit 997b2afca4
5 changed files with 10 additions and 11 deletions

View file

@ -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

View file

@ -20,7 +20,7 @@ This is an experimental port of [libcurl](https://curl.se/libcurl/) to WebAssemb
- [Copyright](#copyright)
* [Copyright Notice](#copyright-notice)
<small><i><a href='http://ecotrust-canada.github.io/markdown-toc/'>Table of contents generated with markdown-toc</a></i></small>
<small>Table of contents generated with [markdown-toc](http://ecotrust-canada.github.io/markdown-toc/).</small>
## 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:

View file

@ -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)}`;

View file

@ -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

View file

@ -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