| #include "http_request.hpp" | |
| #include <string_view> | |
| #include <system_error> | |
| #include <utility> | |
| #ifdef BMCWEB_ENABLE_GRPC | |
| #include "absl/log/log.h" // NOLINT | |
| #endif | |
| namespace crow { | |
| Request::Request( | |
| boost::beast::http::request<boost::beast::http::string_body> reqIn, | |
| std::error_code& ec) | |
| : req(std::move(reqIn)) { | |
| if (!setUrlInfo()) { | |
| ec = std::make_error_code(std::errc::invalid_argument); | |
| } | |
| #ifdef BMCWEB_ENABLE_GRPC | |
| LOG(INFO) << "=> HTTP: Request: path: target: " << this->target(); | |
| #endif | |
| } | |
| Request::Request(std::string_view bodyIn, std::error_code& ec) | |
| : req({}, bodyIn) { | |
| if (!setUrlInfo()) { | |
| ec = std::make_error_code(std::errc::invalid_argument); | |
| } | |
| #ifdef BMCWEB_ENABLE_GRPC | |
| LOG(INFO) << "=> HTTP: Request: path: target: " << this->target(); | |
| #endif | |
| } | |
| bool Request::setUrlInfo() { | |
| auto result = boost::urls::parse_relative_ref(target()); | |
| if (!result) { | |
| return false; | |
| } | |
| urlBase = *result; | |
| return true; | |
| } | |
| } // namespace crow |