summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2023-08-01 21:35:53 +0300
committerEd Tanous <ed@tanous.net>2023-08-23 19:55:21 +0300
commita716aa74954617e32a1d2e691d184580402b3eaf (patch)
tree836d67ff00ddb6611e69e7ce51d9f32901ba34e6 /include
parent3544d2a719c8bb7b07f9a39f61a3770ec84b909f (diff)
downloadbmcweb-a716aa74954617e32a1d2e691d184580402b3eaf.tar.xz
Move http client to URL
Type safety is a good thing. In: https://gerrit.openbmc.org/c/openbmc/bmcweb/+/65606 It was found that splitting out the URI into encoded pieces in the early phase removed some information we needed, namely whether or not a URI was ipv6. This commit changes http client such that it passes all the information through, with the correct type, rather than passing in hostname, port, path, and ssl separately. Opportunistically, because a number of log lines are changing, this uses the opportunity to remove a number of calls to std::to_string, and rely on std::format instead. Now that we no longer use custom URI splitting code, the ValidateAndSplitUrl() method can be removed, given that our validation now happens in the URI class. Tested: Aggregation works properly when satellite URIs are queried. Change-Id: I9f605863179af54c5af2719bc5ce9d29cbfffab7 Signed-off-by: Ed Tanous <edtanous@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/async_resolve.hpp5
-rw-r--r--include/event_service_store.hpp11
2 files changed, 12 insertions, 4 deletions
diff --git a/include/async_resolve.hpp b/include/async_resolve.hpp
index 3f31e1383f..71d2497e26 100644
--- a/include/async_resolve.hpp
+++ b/include/async_resolve.hpp
@@ -63,7 +63,7 @@ class Resolver
// This function is kept using snake case so that it is interoperable with
// boost::asio::ip::tcp::resolver
// NOLINTNEXTLINE(readability-identifier-naming)
- void async_resolve(const std::string& host, std::string_view port,
+ void async_resolve(std::string_view host, std::string_view port,
ResolveHandler&& handler)
{
BMCWEB_LOG_DEBUG("Trying to resolve: {}:{}", host, port);
@@ -82,7 +82,8 @@ class Resolver
uint64_t flag = 0;
crow::connections::systemBus->async_method_call(
- [host, portNum, handler{std::forward<ResolveHandler>(handler)}](
+ [host{std::string(host)}, portNum,
+ handler{std::forward<ResolveHandler>(handler)}](
const boost::system::error_code& ec,
const std::vector<
std::tuple<int32_t, int32_t, std::vector<uint8_t>>>& resp,
diff --git a/include/event_service_store.hpp b/include/event_service_store.hpp
index 61f1ac7b0f..8b24fcbe83 100644
--- a/include/event_service_store.hpp
+++ b/include/event_service_store.hpp
@@ -3,6 +3,7 @@
#include <boost/beast/http/fields.hpp>
#include <boost/container/flat_map.hpp>
+#include <boost/url/parse.hpp>
#include <nlohmann/json.hpp>
namespace persistent_data
@@ -11,7 +12,7 @@ namespace persistent_data
struct UserSubscription
{
std::string id;
- std::string destinationUrl;
+ boost::urls::url destinationUrl;
std::string protocol;
std::string retryPolicy;
std::string customText;
@@ -48,7 +49,13 @@ struct UserSubscription
{
continue;
}
- subvalue->destinationUrl = *value;
+ boost::urls::result<boost::urls::url> url =
+ boost::urls::parse_absolute_uri(*value);
+ if (!url)
+ {
+ continue;
+ }
+ subvalue->destinationUrl = std::move(*url);
}
else if (element.key() == "Protocol")
{