Skip to content

Commit

Permalink
simplications
Browse files Browse the repository at this point in the history
  • Loading branch information
cwaldren-ld committed Nov 12, 2024
1 parent 21b8629 commit 22b5c5a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions libs/internal/include/launchdarkly/network/asio_requester.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> const& port) {
Expand Down
8 changes: 5 additions & 3 deletions libs/server-sent-events/src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<boost::urls::url_view> const& url) {
if (url->has_port() && url->port() != "80" && url->port() != "443") {
Expand Down Expand Up @@ -662,11 +664,11 @@ std::shared_ptr<Client> 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_);
}
Expand Down

0 comments on commit 22b5c5a

Please sign in to comment.