mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-13 22:40:01 -04:00
Merge branch 'main' into reclaimtls
This commit is contained in:
commit
4ff2d179b0
9 changed files with 42 additions and 16 deletions
|
@ -4,7 +4,7 @@ class HTTPSession extends CurlSession {
|
|||
this.options = options;
|
||||
this.base_url = undefined;
|
||||
|
||||
this.set_connections(50, 40);
|
||||
this.set_connections(50, 40, 6);
|
||||
this.import_cookies();
|
||||
}
|
||||
|
||||
|
@ -181,6 +181,17 @@ class HTTPSession extends CurlSession {
|
|||
for (let [header_name, header_value] of response_info.headers) {
|
||||
response_obj.headers.append(header_name, header_value);
|
||||
}
|
||||
|
||||
//hack to fix invalid blob type
|
||||
let response_proto = Object.getPrototypeOf(response_obj);
|
||||
response_obj.blob = async () => {
|
||||
let blob = await response_proto.blob.call(response_obj);
|
||||
let mime_type = blob.type.split(";")[0].trim();
|
||||
Object.defineProperty(blob, "type", {
|
||||
value: mime_type
|
||||
});
|
||||
return blob;
|
||||
}
|
||||
|
||||
return response_obj;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
ading2210/libcurl.js - A port of libcurl to WASM for the browser.
|
||||
Copyright (C) 2023 ading2210
|
||||
Copyright (C) 2024 ading2210
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
|
|
|
@ -28,9 +28,9 @@ class CurlSession {
|
|||
}
|
||||
}
|
||||
|
||||
set_connections(connections_limit, cache_limit) {
|
||||
set_connections(connections_limit, cache_limit, host_conn_limit=0) {
|
||||
this.assert_ready();
|
||||
_session_set_options(this.session_ptr, connections_limit, cache_limit);
|
||||
_session_set_options(this.session_ptr, connections_limit, cache_limit, host_conn_limit);
|
||||
}
|
||||
|
||||
end_callback(request_id, error) {
|
||||
|
@ -41,8 +41,7 @@ class CurlSession {
|
|||
|
||||
data_callback(request_id, chunk_ptr, chunk_size) {
|
||||
let data = Module.HEAPU8.subarray(chunk_ptr, chunk_ptr + chunk_size);
|
||||
let chunk = new Uint8Array(data);
|
||||
this.request_callbacks[request_id].data(chunk);
|
||||
this.request_callbacks[request_id].data(data);
|
||||
}
|
||||
|
||||
headers_callback(request_id, chunk_ptr, chunk_size) {
|
||||
|
|
|
@ -40,6 +40,7 @@ CURL* create_request(const char* url, int request_id, DataCallback data_callback
|
|||
|
||||
curl_easy_setopt(http_handle, CURLOPT_PRIVATE, request_info);
|
||||
curl_easy_setopt(http_handle, CURLOPT_URL, url);
|
||||
curl_easy_setopt(http_handle, CURLOPT_BUFFERSIZE, 512*1024);
|
||||
|
||||
//callbacks to pass the response data back to js
|
||||
curl_easy_setopt(http_handle, CURLOPT_WRITEFUNCTION, &write_function);
|
||||
|
|
|
@ -27,9 +27,10 @@ void session_perform(struct SessionInfo *session) {
|
|||
}
|
||||
}
|
||||
|
||||
void session_set_options(struct SessionInfo *session, int connections_limit, int cache_limit) {
|
||||
void session_set_options(struct SessionInfo *session, int connections_limit, int cache_limit, int host_conn_limit) {
|
||||
curl_multi_setopt(session->multi_handle, CURLMOPT_MAX_TOTAL_CONNECTIONS, connections_limit);
|
||||
curl_multi_setopt(session->multi_handle, CURLMOPT_MAXCONNECTS, cache_limit);
|
||||
curl_multi_setopt(session->multi_handle, CURLMOPT_MAX_HOST_CONNECTIONS, host_conn_limit);
|
||||
}
|
||||
|
||||
void session_add_request(struct SessionInfo *session, CURL* http_handle) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "libcurl.js-reclaimtls",
|
||||
"version": "0.6.16-reclaimtls",
|
||||
"version": "0.6.19-reclaimtls",
|
||||
"description": "A port of libcurl to WebAssembly, for proxying HTTPS requests from the browser with full TLS encryption",
|
||||
"main": "libcurl.mjs",
|
||||
"exports": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue