From 93fb338ce0878730ab4f391dd18eb12d7d84fe89 Mon Sep 17 00:00:00 2001 From: Chee Yee Date: Fri, 8 Nov 2024 00:38:31 -0800 Subject: [PATCH] failed install to display server error message --- CMakeLists.txt | 2 +- source/actions.cpp | 2 +- source/clients/baseclient.cpp | 6 +++++- source/http/httplib.h | 2 ++ source/server/http_server.cpp | 13 +++++++++++-- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 26db6ae..3cc22b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,7 @@ add_executable(ezremote_client add_self(ezremote_client) -add_pkg(ezremote_client ${CMAKE_SOURCE_DIR}/data "RMTC00001" "ezRemote Client" "01.30" 32 0) +add_pkg(ezremote_client ${CMAKE_SOURCE_DIR}/data "RMTC00001" "ezRemote Client" "01.31" 32 0) target_link_libraries(ezremote_client c diff --git a/source/actions.cpp b/source/actions.cpp index 68d249c..888fe26 100644 --- a/source/actions.cpp +++ b/source/actions.cpp @@ -1157,7 +1157,7 @@ namespace Actions int ret = tmp_client.Size(path, &bytes_to_download); if (ret == 0) { - sprintf(status_message, "%s - %s", lang_strings[STR_FAILED], lang_strings[STR_CANNOT_READ_PKG_HDR_MSG]); + sprintf(status_message, "%s", tmp_client.LastResponse()); tmp_client.Quit(); activity_inprogess = false; Windows::SetModalMode(false); diff --git a/source/clients/baseclient.cpp b/source/clients/baseclient.cpp index eb5217c..8cd08d4 100644 --- a/source/clients/baseclient.cpp +++ b/source/clients/baseclient.cpp @@ -90,7 +90,7 @@ int BaseClient::Size(const std::string &path, int64_t *size) *size = atoll(content_length.c_str()); return 1; } - else // Server doesn't support HEAD request. Try get range with 0 bytes and grab size from the response header + else if (res->status == 405)// Server doesn't support HEAD request. Try get range with 0 bytes and grab size from the response header // example: Content-Range: bytes 0-10/4372785 { Headers headers = {{"Range", "bytes=0-1"}}; @@ -111,6 +111,10 @@ int BaseClient::Size(const std::string &path, int64_t *size) } } } + else + { + sprintf(this->response, "%d - %s", res->status, detail::status_message(res->status)); + } } else { diff --git a/source/http/httplib.h b/source/http/httplib.h index 14aa264..45fd248 100644 --- a/source/http/httplib.h +++ b/source/http/httplib.h @@ -1898,6 +1898,8 @@ make_basic_authentication_header(const std::string &username, namespace detail { +const char *status_message(int status); + std::string encode_query_param(const std::string &value); std::string encode_url(const std::string &s); diff --git a/source/server/http_server.cpp b/source/server/http_server.cpp index e3a25ae..b336454 100644 --- a/source/server/http_server.cpp +++ b/source/server/http_server.cpp @@ -1292,7 +1292,7 @@ namespace HttpServer failed(res, 200, lang_strings[STR_CANT_EXTRACT_URL_MSG]); activity_inprogess = false; file_transfering = false; - Windows::SetModalMode(true); + Windows::SetModalMode(false); return; } delete(filehost); @@ -1305,6 +1305,15 @@ namespace HttpServer BaseClient *baseclient = new BaseClient(); baseclient->Connect(host, "", ""); + + if (!baseclient->FileExists(path)) + { + failed(res, 200, baseclient->LastResponse()); + activity_inprogess = false; + file_transfering = false; + Windows::SetModalMode(false); + return; + } baseclient->Head(path, &header, sizeof(pkg_header)); if (BE32(header.pkg_magic) == 0x7F434E54) @@ -1322,7 +1331,7 @@ namespace HttpServer failed(res, 200, lang_strings[STR_FAIL_INSTALL_FROM_URL_MSG]); activity_inprogess = false; file_transfering = false; - Windows::SetModalMode(true); + Windows::SetModalMode(false); return; } }