Browse Source

common : improve error message when HTTPS is missing but required (#18987)

Signed-off-by: Adrien Gallouët <angt@huggingface.co>
Adrien Gallouët 1 week ago
parent
commit
14be5a39b1
2 changed files with 12 additions and 1 deletions
  1. 11 0
      common/http.h
  2. 1 1
      vendor/cpp-httplib/CMakeLists.txt

+ 11 - 0
common/http.h

@@ -57,6 +57,17 @@ static std::pair<httplib::Client, common_http_url> common_http_client(const std:
         throw std::runtime_error("error: invalid URL format");
     }
 
+#ifndef CPPHTTPLIB_OPENSSL_SUPPORT
+    if (parts.scheme == "https") {
+        throw std::runtime_error(
+            "HTTPS is not supported. Please rebuild with:\n"
+            "  -DLLAMA_BUILD_BORINGSSL=ON\n"
+            "  -DLLAMA_BUILD_LIBRESSL=ON\n"
+            "or ensure dev files of an OpenSSL-compatible library are available when building."
+        );
+    }
+#endif
+
     httplib::Client cli(parts.scheme + "://" + parts.host);
 
     if (!parts.user.empty()) {

+ 1 - 1
vendor/cpp-httplib/CMakeLists.txt

@@ -142,7 +142,7 @@ elseif (LLAMA_OPENSSL)
             target_link_libraries(${TARGET} PUBLIC OpenSSL::SSL OpenSSL::Crypto)
         endif()
     else()
-        message(STATUS "OpenSSL not found, SSL support disabled")
+        message(WARNING "OpenSSL not found, HTTPS support disabled")
     endif()
 endif()