bmcweb: /s/boost::string_view/std::string_view/g
With boost 1.69, we get the new option, BOOST_BEAST_USE_STD_STRING_VIEW
which allows us to use std::string for all beast interfaces, instead of
boost string_view. This was originally intended to try to reduce the
binary size, but the comparison shows only a minor improvement.
boost::string_view: 7420780 bytes
std::string_view: 7419948 bytes
832 bytes saved ! ! ! ! !
So instead, we will use the argument that it's more standard and easier
for people to grok.
Tested By:
Pulled down some bmcweb endpoints, and observed no change. Because the
two objects are essentially drop in replacements for one another, there
should be no change.
Change-Id: I001e8cf2a0124de4792a7154bf246e3c35ef3f97
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/include/token_authorization_middleware.hpp b/include/token_authorization_middleware.hpp
index b186a5f..c5c6523 100644
--- a/include/token_authorization_middleware.hpp
+++ b/include/token_authorization_middleware.hpp
@@ -39,7 +39,7 @@
}
if (ctx.session == nullptr)
{
- boost::string_view authHeader = req.getHeaderValue("Authorization");
+ std::string_view authHeader = req.getHeaderValue("Authorization");
if (!authHeader.empty())
{
// Reject any kind of auth other than basic or token
@@ -104,12 +104,12 @@
private:
const std::shared_ptr<crow::persistent_data::UserSession>
- performBasicAuth(boost::string_view auth_header) const
+ performBasicAuth(std::string_view auth_header) const
{
BMCWEB_LOG_DEBUG << "[AuthMiddleware] Basic authentication";
std::string authData;
- boost::string_view param = auth_header.substr(strlen("Basic "));
+ std::string_view param = auth_header.substr(strlen("Basic "));
if (!crow::utility::base64Decode(param, authData))
{
return nullptr;
@@ -146,11 +146,11 @@
}
const std::shared_ptr<crow::persistent_data::UserSession>
- performTokenAuth(boost::string_view auth_header) const
+ performTokenAuth(std::string_view auth_header) const
{
BMCWEB_LOG_DEBUG << "[AuthMiddleware] Token authentication";
- boost::string_view token = auth_header.substr(strlen("Token "));
+ std::string_view token = auth_header.substr(strlen("Token "));
auto session =
persistent_data::SessionStore::getInstance().loginSessionByToken(
token);
@@ -162,7 +162,7 @@
{
BMCWEB_LOG_DEBUG << "[AuthMiddleware] X-Auth-Token authentication";
- boost::string_view token = req.getHeaderValue("X-Auth-Token");
+ std::string_view token = req.getHeaderValue("X-Auth-Token");
if (token.empty())
{
return nullptr;
@@ -178,7 +178,7 @@
{
BMCWEB_LOG_DEBUG << "[AuthMiddleware] Cookie authentication";
- boost::string_view cookieValue = req.getHeaderValue("Cookie");
+ std::string_view cookieValue = req.getHeaderValue("Cookie");
if (cookieValue.empty())
{
return nullptr;
@@ -195,7 +195,7 @@
{
endIndex = cookieValue.size();
}
- boost::string_view authKey =
+ std::string_view authKey =
cookieValue.substr(startIndex, endIndex - startIndex);
const std::shared_ptr<crow::persistent_data::UserSession> session =
@@ -209,7 +209,7 @@
// RFC7231 defines methods that need csrf protection
if (req.method() != "GET"_method)
{
- boost::string_view csrf = req.getHeaderValue("X-XSRF-TOKEN");
+ std::string_view csrf = req.getHeaderValue("X-XSRF-TOKEN");
// Make sure both tokens are filled
if (csrf.empty() || session->csrfToken.empty())
{
@@ -274,9 +274,9 @@
BMCWEB_ROUTE(app, "/login")
.methods(
"POST"_method)([&](const crow::Request& req, crow::Response& res) {
- boost::string_view contentType = req.getHeaderValue("content-type");
- boost::string_view username;
- boost::string_view password;
+ std::string_view contentType = req.getHeaderValue("content-type");
+ std::string_view username;
+ std::string_view password;
bool looksLikeIbm = false;