Skip to content

Commit

Permalink
Remove NEW_BOOST_URL macro
Browse files Browse the repository at this point in the history
Now that the subtree update is done, this define is no longer needed.

Tested: Code compiles.  Noop.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Idc5d7ef69c009982a2476fadc1d95e3280bfff48
  • Loading branch information
edtanous committed Feb 4, 2022
1 parent c419c75 commit 50b8a43
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 127 deletions.
21 changes: 1 addition & 20 deletions http/http_request.hpp
Expand Up @@ -23,9 +23,7 @@ struct Request
boost::beast::http::fields& fields;
std::string_view url{};
boost::urls::url_view urlView{};
#ifndef NEW_BOOST_URL
boost::urls::query_params_view urlParams{};
#endif

bool isSecure{false};

const std::string& body;
Expand Down Expand Up @@ -100,7 +98,6 @@ struct Request
}

private:
#ifdef NEW_BOOST_URL
bool setUrlInfo()
{
auto result = boost::urls::parse_relative_ref(
Expand All @@ -115,22 +112,6 @@ struct Request
urlView.encoded_path().size());
return true;
}
#else
bool setUrlInfo()
{
boost::urls::error_code ec;
urlView = boost::urls::parse_relative_ref(
boost::urls::string_view(target().data(), target().size()), ec);
if (ec)
{
return false;
}
url = std::string_view(urlView.encoded_path().data(),
urlView.encoded_path().size());
urlParams = urlView.query_params();
return true;
}
#endif
};

} // namespace crow
54 changes: 1 addition & 53 deletions redfish-core/lib/log_services.hpp
Expand Up @@ -181,7 +181,7 @@ inline static bool getEntryTimestamp(sd_journal* journal,
entryTimestamp = crow::utility::getDateTimeUint(timestamp / 1000 / 1000);
return true;
}
#ifdef NEW_BOOST_URL

static bool getSkipParam(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const crow::Request& req, uint64_t& skip)
{
Expand Down Expand Up @@ -225,58 +225,6 @@ static bool getTopParam(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
return true;
}

#else

static bool getSkipParam(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const crow::Request& req, uint64_t& skip)
{
boost::urls::query_params_view::iterator it = req.urlParams.find("$skip");
if (it != req.urlParams.end())
{
std::string skipParam = it->value();
char* ptr = nullptr;
skip = std::strtoul(skipParam.c_str(), &ptr, 10);
if (skipParam.empty() || *ptr != '\0')
{

messages::queryParameterValueTypeError(
asyncResp->res, std::string(skipParam), "$skip");
return false;
}
}
return true;
}

static constexpr const uint64_t maxEntriesPerPage = 1000;
static bool getTopParam(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const crow::Request& req, uint64_t& top)
{
boost::urls::query_params_view::iterator it = req.urlParams.find("$top");
if (it != req.urlParams.end())
{
std::string topParam = it->value();
char* ptr = nullptr;
top = std::strtoul(topParam.c_str(), &ptr, 10);
if (topParam.empty() || *ptr != '\0')
{
messages::queryParameterValueTypeError(
asyncResp->res, std::string(topParam), "$top");
return false;
}
if (top < 1U || top > maxEntriesPerPage)
{

messages::queryParameterOutOfRange(
asyncResp->res, std::to_string(top), "$top",
"1-" + std::to_string(maxEntriesPerPage));
return false;
}
}
return true;
}

#endif

inline static bool getUniqueEntryID(sd_journal* journal, std::string& entryID,
const bool firstEntry = true)
{
Expand Down
54 changes: 0 additions & 54 deletions redfish-core/lib/virtual_media.hpp
Expand Up @@ -31,7 +31,6 @@ namespace redfish
/**
* @brief Function extracts transfer protocol name from URI.
*/
#ifdef NEW_BOOST_URL
inline std::string getTransferProtocolTypeFromUri(const std::string& imageUri)
{
boost::urls::result<boost::urls::url_view> url =
Expand All @@ -52,29 +51,6 @@ inline std::string getTransferProtocolTypeFromUri(const std::string& imageUri)

return "None";
}
#else
inline std::string getTransferProtocolTypeFromUri(const std::string& imageUri)
{
boost::urls::error_code ec;
boost::urls::url_view url =
boost::urls::parse_uri(boost::string_view(imageUri), ec);
if (ec)
{
return "None";
}
boost::string_view scheme = url.scheme();
if (scheme == "smb")
{
return "CIFS";
}
if (scheme == "https")
{
return "HTTPS";
}

return "None";
}
#endif

/**
* @brief Read all known properties from VM object interfaces
Expand Down Expand Up @@ -329,7 +305,6 @@ enum class TransferProtocol
* @brief Function extracts transfer protocol type from URI.
*
*/
#ifdef NEW_BOOST_URL
inline std::optional<TransferProtocol>
getTransferProtocolFromUri(const std::string& imageUri)
{
Expand All @@ -356,35 +331,6 @@ inline std::optional<TransferProtocol>

return {};
}
#else
inline std::optional<TransferProtocol>
getTransferProtocolFromUri(const std::string& imageUri)
{
boost::urls::error_code ec;
boost::urls::url_view url =
boost::urls::parse_uri(boost::string_view(imageUri), ec);
if (ec)
{
return {};
}

boost::string_view scheme = url.scheme();
if (scheme == "smb")
{
return TransferProtocol::smb;
}
if (scheme == "https")
{
return TransferProtocol::https;
}
if (!scheme.empty())
{
return TransferProtocol::invalid;
}

return {};
}
#endif

/**
* @brief Function convert transfer protocol from string param.
Expand Down

0 comments on commit 50b8a43

Please sign in to comment.