From 8d2b4de7a660493631771cae10fa6ef4a3a86728 Mon Sep 17 00:00:00 2001 From: woodser Date: Sat, 17 Aug 2024 08:09:45 -0400 Subject: [PATCH] assign default port for http and https clients --- contrib/epee/src/abstract_http_client.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/epee/src/abstract_http_client.cpp b/contrib/epee/src/abstract_http_client.cpp index 8897ad9ae8..00663302dd 100644 --- a/contrib/epee/src/abstract_http_client.cpp +++ b/contrib/epee/src/abstract_http_client.cpp @@ -125,6 +125,11 @@ namespace http http::url_content parsed{}; const bool r = parse_url(address, parsed); CHECK_AND_ASSERT_MES(r, false, "failed to parse url: " << address); + if (parsed.port == 0 && (parsed.schema == "http" || parsed.schema == "https")) + { + struct servent *serv = getservbyname(parsed.schema.c_str(), "tcp"); + parsed.port = ntohs(serv->s_port); + } set_server(std::move(parsed.host), std::to_string(parsed.port), std::move(user), std::move(ssl_options)); return true; }