From 58fbf6cad41c1cc49441a512f0d05b8648aaa67f Mon Sep 17 00:00:00 2001 From: StimeKe Date: Wed, 22 May 2024 16:53:26 +0800 Subject: [PATCH] Fixed not get port when obtaining the host. --- src/slic3r/Utils/OctoPrint.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/slic3r/Utils/OctoPrint.cpp b/src/slic3r/Utils/OctoPrint.cpp index 04a0d0187f4..06aa4685893 100644 --- a/src/slic3r/Utils/OctoPrint.cpp +++ b/src/slic3r/Utils/OctoPrint.cpp @@ -55,8 +55,15 @@ std::string get_host_from_url(const std::string& url_in) char* host; rc = curl_url_get(hurl, CURLUPART_HOST, &host, 0); if (rc == CURLUE_OK) { - out = host; - curl_free(host); + char* port; + rc = curl_url_get(hurl, CURLUPART_PORT, &port, 0); + if (rc == CURLUE_OK && port != nullptr) { + out = std::string(host) + ":" + port; + curl_free(port); + } else { + out = host; + curl_free(host); + } } else BOOST_LOG_TRIVIAL(error) << "OctoPrint get_host_from_url: failed to get host form URL " << url;