mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-13 14:30:02 -04:00
remove emscripten socket file descriptor limit
This commit is contained in:
parent
45b0084c79
commit
a282734c13
6 changed files with 58 additions and 5 deletions
|
@ -27,4 +27,6 @@ tls_socket_set_options
|
|||
recv_from_socket
|
||||
send_to_socket
|
||||
|
||||
ftp_set_options
|
||||
|
||||
free
|
3
client/fragments/fix_socket_limit.js
Normal file
3
client/fragments/fix_socket_limit.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
/* DELETE
|
||||
assert\(sock\.stream\.fd ?< ?64\);
|
||||
*/
|
44
client/javascript/ftp.js
Normal file
44
client/javascript/ftp.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
//unfinished!
|
||||
|
||||
class FTPSession {
|
||||
constructor(url, options={}) {
|
||||
if (!url.startsWith("ftp://") || !url.startsWith("ftps://")) {
|
||||
throw "invalid url protocol";
|
||||
}
|
||||
|
||||
this.url = url;
|
||||
this.cwd = new URL(url).pathname;
|
||||
this.options = options;
|
||||
this.http_handle = null;
|
||||
}
|
||||
|
||||
do_request(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let http_handle;
|
||||
let data_callback = (data) => {this.data_callback(data)};
|
||||
let finish_callback = (error) => {
|
||||
_cleanup_handle(http_handle);
|
||||
if (error) {
|
||||
reject();
|
||||
}
|
||||
else {
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
let headers_callback = () => {this.headers_callback()};
|
||||
|
||||
http_handle = create_handle(url, data_callback, finish_callback, headers_callback);
|
||||
_ftp_set_options(http_handle, url, 1);
|
||||
start_request(http_handle);
|
||||
});
|
||||
}
|
||||
|
||||
async download(path) {
|
||||
let url = new URL(path, this.url);
|
||||
_ftp_set_options(this.http_handle, url, 0);
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
|
||||
}
|
||||
}
|
9
client/libcurl/ftp.c
Normal file
9
client/libcurl/ftp.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include "curl/curl.h"
|
||||
|
||||
#include "types.h"
|
||||
#include "util.h"
|
||||
|
||||
void ftp_set_options(CURL* http_handle, const char* url, int no_body) {
|
||||
curl_easy_setopt(http_handle, CURLOPT_NOBODY, (long) no_body);
|
||||
curl_easy_setopt(http_handle, CURLOPT_URL, url);
|
||||
}
|
|
@ -119,11 +119,6 @@ void init_curl() {
|
|||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
multi_handle = curl_multi_init();
|
||||
|
||||
//emscripten has a fairly low file descriptor limit which means
|
||||
//we must limit the total number of active tcp connections
|
||||
curl_multi_setopt(multi_handle, CURLMOPT_MAX_TOTAL_CONNECTIONS, 50L);
|
||||
curl_multi_setopt(multi_handle, CURLMOPT_MAXCONNECTS, 40L);
|
||||
|
||||
cacert_blob.data = _cacert_pem;
|
||||
cacert_blob.len = _cacert_pem_len;
|
||||
cacert_blob.flags = CURL_BLOB_NOCOPY;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue