diff --git a/libs/server-sent-events/src/client.cpp b/libs/server-sent-events/src/client.cpp index 9d66c8c07..cb8d87b8d 100644 --- a/libs/server-sent-events/src/client.cpp +++ b/libs/server-sent-events/src/client.cpp @@ -589,11 +589,22 @@ std::shared_ptr Builder::build() { request.set(http::field::host, host); request.target(uri_components->encoded_target()); + if (uri_components->has_scheme()) { + if (!(uri_components->scheme() == "http" || + uri_components->scheme() == "https")) { + return nullptr; + } + } + + // The resolver accepts either a port number or a service name. If the + // URL specifies a port, use that - otherwise, pass in the scheme as the + // service name (which will be either http or https due to the check + // above.) std::string service = uri_components->has_port() ? uri_components->port() : uri_components->scheme(); std::optional ssl; - if (service == "https") { + if (uri_components->scheme() == "https") { ssl = launchdarkly::foxy::make_ssl_ctx(ssl::context::tlsv12_client); ssl->set_default_verify_paths(); }