From 22b5c5a8303f9254021e2199c87af92b0e12ff39 Mon Sep 17 00:00:00 2001 From: Casey Waldren Date: Tue, 12 Nov 2024 14:28:05 -0800 Subject: [PATCH] simplications --- .../include/launchdarkly/network/asio_requester.hpp | 2 ++ libs/server-sent-events/src/client.cpp | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/internal/include/launchdarkly/network/asio_requester.hpp b/libs/internal/include/launchdarkly/network/asio_requester.hpp index 46fcd3400..50bb7f340 100644 --- a/libs/internal/include/launchdarkly/network/asio_requester.hpp +++ b/libs/internal/include/launchdarkly/network/asio_requester.hpp @@ -65,6 +65,8 @@ static http::verb ConvertMethod(HttpMethod method) { launchdarkly::detail::unreachable(); } +// Returns the host with a port appended, if the port is not 80 or 443. +// Although not strictly necessary, it is meant to match what browsers do. static std::string HostWithOptionalPort( std::string host, std::optional const& port) { diff --git a/libs/server-sent-events/src/client.cpp b/libs/server-sent-events/src/client.cpp index cd39354b0..815275d93 100644 --- a/libs/server-sent-events/src/client.cpp +++ b/libs/server-sent-events/src/client.cpp @@ -591,6 +591,8 @@ Builder& Builder::custom_ca_file(std::string path) { return *this; } +// Returns the host with a port appended, if the port is not 80 or 443. +// Although not strictly necessary, it is meant to match what browsers do. std::string host_with_optional_port( boost::system::result const& url) { if (url->has_port() && url->port() != "80" && url->port() != "443") { @@ -662,11 +664,11 @@ std::shared_ptr Builder::build() { tcp_host = http_proxy_components->host(); - // If they didn't specify a port, then the uri is of the form - // [http://]foo.bar at this point. Use port 80 if not specified. + // If they didn't specify a port, use the scheme as the service + // (which we've enforced to be http above.) tcp_port = http_proxy_components->has_port() ? http_proxy_components->port() - : "80"; + : http_proxy_components->scheme(); request.target(url_); }