mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-13 14:30:02 -04:00
pin library versions, load cacert from blob
This commit is contained in:
parent
cc4009a4af
commit
b5aff5b085
9 changed files with 15 additions and 15 deletions
|
@ -6,7 +6,7 @@
|
||||||
<script defer src="./out/libcurl.js" onload="libcurl.load_wasm('/out/libcurl.wasm');"></script>
|
<script defer src="./out/libcurl.js" onload="libcurl.load_wasm('/out/libcurl.wasm');"></script>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener("libcurl_load", ()=>{
|
document.addEventListener("libcurl_load", ()=>{
|
||||||
libcurl.set_websocket(`wss://${location.hostname}/ws/`);
|
libcurl.set_websocket(location.href.replace("http", "ws"));
|
||||||
console.log(`loaded libcurl.js v${libcurl.version.lib}`);
|
console.log(`loaded libcurl.js v${libcurl.version.lib}`);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -19,9 +19,10 @@ void finish_request(CURLMsg *curl_msg);
|
||||||
|
|
||||||
CURLM *multi_handle;
|
CURLM *multi_handle;
|
||||||
int request_active = 0;
|
int request_active = 0;
|
||||||
|
struct curl_blob cacert_blob;
|
||||||
|
|
||||||
int write_function(void *data, size_t size, size_t nmemb, DataCallback data_callback) {
|
size_t write_function(void *data, size_t size, size_t nmemb, DataCallback data_callback) {
|
||||||
long real_size = size * nmemb;
|
size_t real_size = size * nmemb;
|
||||||
char* chunk = malloc(real_size);
|
char* chunk = malloc(real_size);
|
||||||
memcpy(chunk, data, real_size);
|
memcpy(chunk, data, real_size);
|
||||||
data_callback(chunk, real_size);
|
data_callback(chunk, real_size);
|
||||||
|
@ -53,8 +54,7 @@ CURL* start_request(const char* url, const char* json_params, DataCallback data_
|
||||||
int prevent_cleanup = 0;
|
int prevent_cleanup = 0;
|
||||||
|
|
||||||
curl_easy_setopt(http_handle, CURLOPT_URL, url);
|
curl_easy_setopt(http_handle, CURLOPT_URL, url);
|
||||||
curl_easy_setopt(http_handle, CURLOPT_CAINFO, "/cacert.pem");
|
curl_easy_setopt(http_handle, CURLOPT_CAINFO_BLOB , cacert_blob);
|
||||||
curl_easy_setopt(http_handle, CURLOPT_CAPATH, "/cacert.pem");
|
|
||||||
|
|
||||||
//callbacks to pass the response data back to js
|
//callbacks to pass the response data back to js
|
||||||
curl_easy_setopt(http_handle, CURLOPT_WRITEFUNCTION, &write_function);
|
curl_easy_setopt(http_handle, CURLOPT_WRITEFUNCTION, &write_function);
|
||||||
|
@ -195,7 +195,7 @@ void init_curl() {
|
||||||
curl_multi_setopt(multi_handle, CURLMOPT_MAX_TOTAL_CONNECTIONS, 50L);
|
curl_multi_setopt(multi_handle, CURLMOPT_MAX_TOTAL_CONNECTIONS, 50L);
|
||||||
curl_multi_setopt(multi_handle, CURLMOPT_MAXCONNECTS, 40L);
|
curl_multi_setopt(multi_handle, CURLMOPT_MAXCONNECTS, 40L);
|
||||||
|
|
||||||
FILE* file = fopen("/cacert.pem", "wb");
|
cacert_blob.data = _cacert_pem;
|
||||||
fwrite(_cacert_pem, 1, _cacert_pem_len, file);
|
cacert_blob.len = _cacert_pem_len;
|
||||||
fclose(file);
|
cacert_blob.flags = CURL_BLOB_NOCOPY;
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "libcurl.js",
|
"name": "libcurl.js",
|
||||||
"version": "0.3.6",
|
"version": "0.3.7",
|
||||||
"description": "An experimental port of libcurl to WebAssembly for use in the browser.",
|
"description": "An experimental port of libcurl to WebAssembly for use in the browser.",
|
||||||
"main": "libcurl.mjs",
|
"main": "libcurl.mjs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -10,7 +10,7 @@ PREFIX=$(realpath build/brotli-wasm)
|
||||||
|
|
||||||
cd build
|
cd build
|
||||||
rm -rf brotli
|
rm -rf brotli
|
||||||
git clone -b master --depth=1 https://github.com/google/brotli
|
git clone -b v1.1.0 --depth=1 https://github.com/google/brotli
|
||||||
cd brotli
|
cd brotli
|
||||||
|
|
||||||
emcmake cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./installed
|
emcmake cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./installed
|
||||||
|
|
|
@ -11,7 +11,7 @@ mkdir -p $PREFIX
|
||||||
|
|
||||||
cd build
|
cd build
|
||||||
rm -rf cjson
|
rm -rf cjson
|
||||||
git clone -b master --depth=1 https://github.com/DaveGamble/cJSON cjson
|
git clone -b v1.7.17 --depth=1 https://github.com/DaveGamble/cJSON cjson
|
||||||
cd cjson
|
cd cjson
|
||||||
|
|
||||||
sed -i 's/-fstack-protector-strong//' Makefile
|
sed -i 's/-fstack-protector-strong//' Makefile
|
||||||
|
|
|
@ -14,7 +14,7 @@ NGHTTP2_PREFIX=$(realpath build/nghttp2-wasm)
|
||||||
|
|
||||||
cd build
|
cd build
|
||||||
rm -rf curl
|
rm -rf curl
|
||||||
git clone -b master --depth=1 https://github.com/curl/curl
|
git clone -b curl-8_6_0 --depth=1 https://github.com/curl/curl
|
||||||
cd curl
|
cd curl
|
||||||
|
|
||||||
autoreconf -fi
|
autoreconf -fi
|
||||||
|
|
|
@ -10,7 +10,7 @@ PREFIX=$(realpath build/nghttp2-wasm)
|
||||||
|
|
||||||
cd build
|
cd build
|
||||||
rm -rf nghttp2
|
rm -rf nghttp2
|
||||||
git clone -b master --depth=1 https://github.com/nghttp2/nghttp2
|
git clone -b v1.59.0 --depth=1 https://github.com/nghttp2/nghttp2
|
||||||
cd nghttp2
|
cd nghttp2
|
||||||
|
|
||||||
rm -rf $PREFIX
|
rm -rf $PREFIX
|
||||||
|
|
|
@ -11,7 +11,7 @@ mkdir -p $PREFIX
|
||||||
|
|
||||||
cd build
|
cd build
|
||||||
rm -rf openssl
|
rm -rf openssl
|
||||||
git clone -b master --depth=1 https://github.com/openssl/openssl
|
git clone -b openssl-3.2.1 --depth=1 https://github.com/openssl/openssl
|
||||||
cd openssl
|
cd openssl
|
||||||
|
|
||||||
export CFLAGS="-Wall -Oz"
|
export CFLAGS="-Wall -Oz"
|
||||||
|
|
|
@ -10,7 +10,7 @@ PREFIX=$(realpath build/zlib-wasm)
|
||||||
|
|
||||||
cd build
|
cd build
|
||||||
rm -rf zlib
|
rm -rf zlib
|
||||||
git clone -b master --depth=1 https://github.com/madler/zlib
|
git clone -b v1.3.1 --depth=1 https://github.com/madler/zlib
|
||||||
cd zlib
|
cd zlib
|
||||||
|
|
||||||
emconfigure ./configure --static
|
emconfigure ./configure --static
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue