mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-12 22:10:01 -04:00
support http/2
This commit is contained in:
parent
8bcfc2157c
commit
baab0aea8f
6 changed files with 36 additions and 3 deletions
|
@ -13,7 +13,7 @@ WISP_CLIENT="wisp_client"
|
||||||
|
|
||||||
EXPORTED_FUNCS="_init_curl,_start_request,_tick_request,_active_requests"
|
EXPORTED_FUNCS="_init_curl,_start_request,_tick_request,_active_requests"
|
||||||
RUNTIME_METHODS="addFunction,removeFunction,allocate,ALLOC_NORMAL"
|
RUNTIME_METHODS="addFunction,removeFunction,allocate,ALLOC_NORMAL"
|
||||||
COMPILER_OPTIONS="-o $MODULE_FILE -lcurl -lssl -lcrypto -lcjson -lz -lbrotlidec -lbrotlicommon -I $INCLUDE_DIR -L $LIB_DIR"
|
COMPILER_OPTIONS="-o $MODULE_FILE -lcurl -lssl -lcrypto -lcjson -lz -lbrotlidec -lbrotlicommon -lnghttp2 -I $INCLUDE_DIR -L $LIB_DIR"
|
||||||
EMSCRIPTEN_OPTIONS="-lwebsocket.js -sASSERTIONS=1 -sALLOW_TABLE_GROWTH -sALLOW_MEMORY_GROWTH -sEXPORTED_FUNCTIONS=$EXPORTED_FUNCS -sEXPORTED_RUNTIME_METHODS=$RUNTIME_METHODS"
|
EMSCRIPTEN_OPTIONS="-lwebsocket.js -sASSERTIONS=1 -sALLOW_TABLE_GROWTH -sALLOW_MEMORY_GROWTH -sEXPORTED_FUNCTIONS=$EXPORTED_FUNCS -sEXPORTED_RUNTIME_METHODS=$RUNTIME_METHODS"
|
||||||
|
|
||||||
if [ "$1" = "release" ]; then
|
if [ "$1" = "release" ]; then
|
||||||
|
|
|
@ -72,6 +72,7 @@ void start_request(const char* url, const char* json_params, DataCallback data_c
|
||||||
//some default options
|
//some default options
|
||||||
curl_easy_setopt(http_handle, CURLOPT_FOLLOWLOCATION, 1);
|
curl_easy_setopt(http_handle, CURLOPT_FOLLOWLOCATION, 1);
|
||||||
curl_easy_setopt(http_handle, CURLOPT_ACCEPT_ENCODING, "");
|
curl_easy_setopt(http_handle, CURLOPT_ACCEPT_ENCODING, "");
|
||||||
|
curl_easy_setopt(http_handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
|
||||||
|
|
||||||
//if url is a websocket, tell curl that we should handle the connection manually
|
//if url is a websocket, tell curl that we should handle the connection manually
|
||||||
if (starts_with(url, "wss://") || starts_with(url, "ws://")) {
|
if (starts_with(url, "wss://") || starts_with(url, "ws://")) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ CJSON_PREFIX=$(realpath build/cjson-wasm)
|
||||||
CURL_PREFIX=$(realpath build/curl-wasm)
|
CURL_PREFIX=$(realpath build/curl-wasm)
|
||||||
ZLIB_PREFIX=$(realpath build/zlib-wasm)
|
ZLIB_PREFIX=$(realpath build/zlib-wasm)
|
||||||
BROTLI_PREFIX=$(realpath build/brotli-wasm)
|
BROTLI_PREFIX=$(realpath build/brotli-wasm)
|
||||||
|
NGHTTP2_PREFIX=$(realpath build/nghttp2-wasm)
|
||||||
|
|
||||||
if [ ! -d $OPENSSL_PREFIX ]; then
|
if [ ! -d $OPENSSL_PREFIX ]; then
|
||||||
tools/openssl.sh
|
tools/openssl.sh
|
||||||
|
@ -25,8 +26,12 @@ fi
|
||||||
if [ ! -d $CURL_PREFIX ]; then
|
if [ ! -d $CURL_PREFIX ]; then
|
||||||
tools/curl.sh
|
tools/curl.sh
|
||||||
fi
|
fi
|
||||||
|
if [ ! -d $NGHTTP2_PREFIX ]; then
|
||||||
|
tools/nghttp2.sh
|
||||||
|
fi
|
||||||
|
|
||||||
cp -r $OPENSSL_PREFIX/* $CURL_PREFIX
|
cp -r $OPENSSL_PREFIX/* $CURL_PREFIX
|
||||||
cp -r $CJSON_PREFIX/* $CURL_PREFIX
|
cp -r $CJSON_PREFIX/* $CURL_PREFIX
|
||||||
cp -r $ZLIB_PREFIX/* $CURL_PREFIX
|
cp -r $ZLIB_PREFIX/* $CURL_PREFIX
|
||||||
cp -r $BROTLI_PREFIX/* $CURL_PREFIX
|
cp -r $BROTLI_PREFIX/* $CURL_PREFIX
|
||||||
|
cp -r $NGHTTP2_PREFIX/* $CURL_PREFIX
|
|
@ -10,6 +10,7 @@ PREFIX=$(realpath build/curl-wasm)
|
||||||
OPENSSL_PREFIX=$(realpath build/openssl-wasm)
|
OPENSSL_PREFIX=$(realpath build/openssl-wasm)
|
||||||
ZLIB_PREFIX=$(realpath build/zlib-wasm)
|
ZLIB_PREFIX=$(realpath build/zlib-wasm)
|
||||||
BROTLI_PREFIX=$(realpath build/brotli-wasm)
|
BROTLI_PREFIX=$(realpath build/brotli-wasm)
|
||||||
|
NGHTTP2_PREFIX=$(realpath build/nghttp2-wasm)
|
||||||
|
|
||||||
cd build
|
cd build
|
||||||
rm -rf curl
|
rm -rf curl
|
||||||
|
@ -17,7 +18,7 @@ git clone -b master --depth=1 https://github.com/curl/curl
|
||||||
cd curl
|
cd curl
|
||||||
|
|
||||||
autoreconf -fi
|
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
|
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 CFLAGS="-pthread" LIBS="-lbrotlicommon"
|
||||||
|
|
||||||
rm -rf $PREFIX
|
rm -rf $PREFIX
|
||||||
|
|
24
client/tools/nghttp2.sh
Executable file
24
client/tools/nghttp2.sh
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#compile nghttp2 for use with emscripten
|
||||||
|
|
||||||
|
set -x
|
||||||
|
set -e
|
||||||
|
|
||||||
|
CORE_COUNT=$(nproc --all)
|
||||||
|
PREFIX=$(realpath build/nghttp2-wasm)
|
||||||
|
|
||||||
|
cd build
|
||||||
|
rm -rf nghttp2
|
||||||
|
git clone -b master --depth=1 https://github.com/nghttp2/nghttp2
|
||||||
|
cd nghttp2
|
||||||
|
|
||||||
|
rm -rf $PREFIX
|
||||||
|
mkdir -p $PREFIX
|
||||||
|
|
||||||
|
autoreconf -fi
|
||||||
|
emconfigure ./configure --host i686-linux --enable-static --disable-shared --enable-lib-only --prefix=$PREFIX
|
||||||
|
emmake make -j$CORE_COUNT
|
||||||
|
make install
|
||||||
|
|
||||||
|
cd ../../
|
|
@ -14,6 +14,8 @@ rm -rf openssl
|
||||||
git clone -b master --depth=1 https://github.com/openssl/openssl
|
git clone -b master --depth=1 https://github.com/openssl/openssl
|
||||||
cd openssl
|
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 -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
|
sed -i 's|^CROSS_COMPILE.*$|CROSS_COMPILE=|g' Makefile
|
||||||
emmake make -j$CORE_COUNT build_generated libssl.a libcrypto.a
|
emmake make -j$CORE_COUNT build_generated libssl.a libcrypto.a
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue