diff --git a/client/javascript/ftp.js b/client/javascript/ftp.js deleted file mode 100644 index 6978905..0000000 --- a/client/javascript/ftp.js +++ /dev/null @@ -1,55 +0,0 @@ -class FTPSession extends CurlSession { - constructor(url, options={}) { - if (!url.startsWith("ftp://") && !url.startsWith("ftps://")) { - throw "invalid url protocol"; - } - super(); - - this.url = url; - this.options = options; - } - - send_cmd(cmd) { - return new Promise((resolve, reject) => { - let request_ptr; - let chunks = []; - - let data_callback = () => {}; - let finish_callback = (error) => { - this.remove_request(request_ptr); - if (error) { - reject(`Sending FTP command failed with error ${error}: ${get_error_str(error)}`); - } - } - let headers_callback = (chunk) => { - chunks.push(chunk); - console.log(chunk); - } - - request_ptr = this.create_request(this.url, data_callback, finish_callback, headers_callback); - c_func(_ftp_set_cmd, [request_ptr, cmd]); - }); - } - - download(path) { - let url = new URL(path, this.url).href; - console.log(url); - - return new Promise((resolve, reject) => { - let request_ptr; - let finish_callback = (error) => { - this.remove_request(request_ptr); - if (error) { - reject(`FTP request failed with error ${error}: ${get_error_str(error)}`); - } - }; - let headers_callback = (stream) => { - resolve(stream); - }; - - request_ptr = this.stream_response(url, headers_callback, finish_callback); - _ftp_set_options(request_ptr); - this.start_request(request_ptr); - }); - } -} \ No newline at end of file diff --git a/client/javascript/main.js b/client/javascript/main.js index d6b82bf..93d8ec5 100644 --- a/client/javascript/main.js +++ b/client/javascript/main.js @@ -102,7 +102,6 @@ api = { CurlWebSocket: CurlWebSocket, TLSSocket: TLSSocket, HTTPSession: HTTPSession, - FTPSession: FTPSession, fetch() {throw "not ready"}, get copyright() {return copyright_notice}, diff --git a/client/javascript/session.js b/client/javascript/session.js index e2911f3..04b569d 100644 --- a/client/javascript/session.js +++ b/client/javascript/session.js @@ -79,7 +79,6 @@ class CurlSession { this.event_loop = setInterval(() => { let libcurl_active = _session_get_active(this.session_ptr); if (libcurl_active || this.active_requests) { - console.log("test"); _session_perform(this.session_ptr); } else { @@ -147,12 +146,12 @@ class CurlSession { headers_callback(stream); } - if (error != 0) { - try { - stream_controller.close(); - } - catch {} + console.log(error); + + try { + stream_controller.close(); } + catch {} end_callback(error); } diff --git a/client/libcurl/ftp.c b/client/libcurl/ftp.c deleted file mode 100644 index 307ddda..0000000 --- a/client/libcurl/ftp.c +++ /dev/null @@ -1,18 +0,0 @@ -#include "curl/curl.h" - -#include "types.h" -#include "util.h" - -void ftp_set_options(CURL* easy_handle) { - curl_easy_setopt(easy_handle, CURLOPT_VERBOSE, 1L); -} - -void ftp_set_cmd(CURL* easy_handle, const char* cmd) { - struct curl_slist *cmd_list = NULL; - cmd_list = curl_slist_append(cmd_list, cmd); - - curl_easy_setopt(easy_handle, CURLOPT_QUOTE, cmd_list); - curl_easy_setopt(easy_handle, CURLOPT_NOBODY, 1L); - - curl_slist_free_all(cmd_list); -} \ No newline at end of file