Redfish Aggregation: Fixup aggregated URIs

URIs in the responses returned with Redfish Aggregation enabled will
potentially be incorrect since ones from satellite BMCs will not
include the associated prefix such as "5B247A_" in the resource ID
portion of the URIs.

This patch fixes those links so that they include their BMC's
associated prefix.  Note that a future patch will be needed to add
prefixes to aggregated resources that would appear under collection
URIs such as "/redfish/v1/Chassis".

Tested:
Requests were sent to URIs associated with the aggregating BMC and a
satellite BMC denoted as "5B247A".  The URIs in the responses
were successfully updated such that "5B247A_" was added for
satellite resources.

Signed-off-by: Carson Labrado <clabrado@google.com>
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ib4f976fab1ca1e8603f7cf55292732ffb71cd03e
diff --git a/http/utility.hpp b/http/utility.hpp
index 2ba9b0e..d4b9b67 100644
--- a/http/utility.hpp
+++ b/http/utility.hpp
@@ -672,6 +672,36 @@
     return details::readUrlSegments(urlView, {std::forward<Args>(args)...});
 }
 
+inline boost::urls::url replaceUrlSegment(const boost::urls::url_view& urlView,
+                                          const uint replaceLoc,
+                                          const std::string_view newSegment)
+{
+    const boost::urls::segments_view& urlSegments = urlView.segments();
+    boost::urls::url url("/");
+
+    if (!urlSegments.is_absolute())
+    {
+        return url;
+    }
+
+    boost::urls::segments_view::iterator it = urlSegments.begin();
+    boost::urls::segments_view::iterator end = urlSegments.end();
+
+    for (uint idx = 0; it != end; it++, idx++)
+    {
+        if (idx == replaceLoc)
+        {
+            url.segments().push_back(newSegment);
+        }
+        else
+        {
+            url.segments().push_back(*it);
+        }
+    }
+
+    return url;
+}
+
 inline std::string setProtocolDefaults(const boost::urls::url_view& url)
 {
     if (url.scheme() == "https")