Skip to content

Commit

Permalink
fix: handle service endpoints with custom ports correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
cwaldren-ld committed Apr 5, 2024
1 parent a5028cb commit 97461d1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion libs/server-sent-events/src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,11 +589,22 @@ std::shared_ptr<Client> 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::context> ssl;
if (service == "https") {
if (uri_components->scheme() == "https") {
ssl = launchdarkly::foxy::make_ssl_ctx(ssl::context::tlsv12_client);
ssl->set_default_verify_paths();
}
Expand Down

0 comments on commit 97461d1

Please sign in to comment.