Remove namespace in http layer
Within this namespace, we don't need to call crow, we are already in the
crow namespace.
Tested: Code compiles.
Change-Id: Ida57624ef1157f98f2719b5c3af536aebaca601e
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/http/http2_connection.hpp b/http/http2_connection.hpp
index aeb46ab..4e3da8e 100644
--- a/http/http2_connection.hpp
+++ b/http/http2_connection.hpp
@@ -283,7 +283,7 @@
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
}
}
- crow::Request& thisReq = *it->second.req;
+ Request& thisReq = *it->second.req;
using boost::beast::http::field;
it->second.accept = thisReq.getHeaderValue(field::accept);
it->second.acceptEnc = thisReq.getHeaderValue(field::accept_encoding);
@@ -291,7 +291,7 @@
BMCWEB_LOG_DEBUG("Handling {} \"{}\"", logPtr(&thisReq),
thisReq.url().encoded_path());
- crow::Response& thisRes = it->second.res;
+ Response& thisRes = it->second.res;
thisRes.setCompleteRequestHandler(
[this, streamId](Response& completeRes) {
@@ -306,10 +306,10 @@
std::make_shared<bmcweb::AsyncResp>(std::move(it->second.res));
if constexpr (!BMCWEB_INSECURE_DISABLE_AUTH)
{
- thisReq.session = crow::authentication::authenticate(
+ thisReq.session = authentication::authenticate(
{}, asyncResp->res, thisReq.method(), thisReq.req, mtlsSession);
- if (!crow::authentication::isOnAllowlist(thisReq.url().path(),
- thisReq.method()) &&
+ if (!authentication::isOnAllowlist(thisReq.url().path(),
+ thisReq.method()) &&
thisReq.session == nullptr)
{
BMCWEB_LOG_WARNING("Authentication failed");
@@ -465,7 +465,7 @@
return -1;
}
- crow::Request& thisReq = *thisStream->second.req;
+ Request& thisReq = *thisStream->second.req;
if (nameSv == ":path")
{
diff --git a/http/http_connection.hpp b/http/http_connection.hpp
index 8f03e3e..64aac00 100644
--- a/http/http_connection.hpp
+++ b/http/http_connection.hpp
@@ -376,7 +376,7 @@
{
return;
}
- req = std::make_shared<crow::Request>(parser->release(), reqEc);
+ req = std::make_shared<Request>(parser->release(), reqEc);
if (reqEc)
{
BMCWEB_LOG_DEBUG("Request failed to construct{}", reqEc.message());
@@ -416,8 +416,8 @@
if (authenticationEnabled)
{
- if (!crow::authentication::isOnAllowlist(req->url().path(),
- req->method()) &&
+ if (!authentication::isOnAllowlist(req->url().path(),
+ req->method()) &&
req->session == nullptr)
{
BMCWEB_LOG_WARNING("Authentication failed");
@@ -433,7 +433,7 @@
auto asyncResp = std::make_shared<bmcweb::AsyncResp>();
BMCWEB_LOG_DEBUG("Setting completion handler");
asyncResp->res.setCompleteRequestHandler(
- [self(shared_from_this())](crow::Response& thisRes) {
+ [self(shared_from_this())](Response& thisRes) {
self->completeRequest(thisRes);
});
if (doUpgrade(asyncResp))
@@ -489,7 +489,7 @@
}
}
- void completeRequest(crow::Response& thisRes)
+ void completeRequest(Response& thisRes)
{
res = std::move(thisRes);
res.keepAlive(keepAlive);
@@ -938,12 +938,12 @@
boost::beast::flat_static_buffer<8192> buffer;
- std::shared_ptr<crow::Request> req;
+ std::shared_ptr<Request> req;
std::string accept;
std::string http2settings;
std::string acceptEncoding;
- crow::Response res;
+ Response res;
std::shared_ptr<persistent_data::UserSession> userSession;
std::shared_ptr<persistent_data::UserSession> mtlsSession;
diff --git a/http/http_response.hpp b/http/http_response.hpp
index 33f24b3..0d32982 100644
--- a/http/http_response.hpp
+++ b/http/http_response.hpp
@@ -43,7 +43,7 @@
struct Response
{
template <typename Adaptor, typename Handler>
- friend class crow::Connection;
+ friend class Connection;
http::response<bmcweb::HttpBody> response;
diff --git a/http/routing/sserule.hpp b/http/routing/sserule.hpp
index 9fb6ba3..5e9ba5e 100644
--- a/http/routing/sserule.hpp
+++ b/http/routing/sserule.hpp
@@ -54,9 +54,8 @@
}
private:
- std::function<void(crow::sse_socket::Connection&, const crow::Request&)>
- openHandler;
- std::function<void(crow::sse_socket::Connection&)> closeHandler;
+ std::function<void(sse_socket::Connection&, const Request&)> openHandler;
+ std::function<void(sse_socket::Connection&)> closeHandler;
};
} // namespace crow
diff --git a/http/routing/taggedrule.hpp b/http/routing/taggedrule.hpp
index b785d88..7066784 100644
--- a/http/routing/taggedrule.hpp
+++ b/http/routing/taggedrule.hpp
@@ -37,12 +37,12 @@
void operator()(Func&& f)
{
static_assert(
- std::is_invocable_v<Func, crow::Request,
+ std::is_invocable_v<Func, Request,
std::shared_ptr<bmcweb::AsyncResp>&, Args...>,
"Handler type is mismatched with URL parameters");
static_assert(
std::is_same_v<
- void, std::invoke_result_t<Func, crow::Request,
+ void, std::invoke_result_t<Func, Request,
std::shared_ptr<bmcweb::AsyncResp>&,
Args...>>,
"Handler function with response argument should have void return type");
@@ -83,7 +83,7 @@
}
private:
- std::function<void(const crow::Request&,
+ std::function<void(const Request&,
const std::shared_ptr<bmcweb::AsyncResp>&, Args...)>
handler;
};
diff --git a/http/routing/websocketrule.hpp b/http/routing/websocketrule.hpp
index 56bc6ca..b5ca92e 100644
--- a/http/routing/websocketrule.hpp
+++ b/http/routing/websocketrule.hpp
@@ -89,15 +89,15 @@
}
protected:
- std::function<void(crow::websocket::Connection&)> openHandler;
- std::function<void(crow::websocket::Connection&, const std::string&, bool)>
+ std::function<void(websocket::Connection&)> openHandler;
+ std::function<void(websocket::Connection&, const std::string&, bool)>
messageHandler;
- std::function<void(crow::websocket::Connection&, std::string_view,
- crow::websocket::MessageType type,
+ std::function<void(websocket::Connection&, std::string_view,
+ websocket::MessageType type,
std::function<void()>&& whenComplete)>
messageExHandler;
- std::function<void(crow::websocket::Connection&, const std::string&)>
+ std::function<void(websocket::Connection&, const std::string&)>
closeHandler;
- std::function<void(crow::websocket::Connection&)> errorHandler;
+ std::function<void(websocket::Connection&)> errorHandler;
};
} // namespace crow
diff --git a/test/http/crow_getroutes_test.cpp b/test/http/crow_getroutes_test.cpp
index 21bbbd1..8c21f59 100644
--- a/test/http/crow_getroutes_test.cpp
+++ b/test/http/crow_getroutes_test.cpp
@@ -34,7 +34,7 @@
App app;
BMCWEB_ROUTE(app, "/")
- ([](const crow::Request& /*req*/,
+ ([](const Request& /*req*/,
const std::shared_ptr<AsyncResp>& /*asyncResp*/) {});
// TODO: "/" doesn't get reported in |getRoutes| today. Uncomment this once
diff --git a/test/http/http_connection_test.cpp b/test/http/http_connection_test.cpp
index 69cf21a..cc3ebeb 100644
--- a/test/http/http_connection_test.cpp
+++ b/test/http/http_connection_test.cpp
@@ -79,8 +79,8 @@
std::bind_front(&ClockFake::getDateStr, &clock));
boost::asio::ssl::context context{boost::asio::ssl::context::tls};
- std::shared_ptr<crow::Connection<TestStream, FakeHandler>> conn =
- std::make_shared<crow::Connection<TestStream, FakeHandler>>(
+ std::shared_ptr<Connection<TestStream, FakeHandler>> conn =
+ std::make_shared<Connection<TestStream, FakeHandler>>(
&handler, HttpType::HTTP, std::move(timer), date,
boost::asio::ssl::stream<TestStream>(std::move(stream), context));
conn->disableAuth();
diff --git a/test/http/http_response_test.cpp b/test/http/http_response_test.cpp
index 8277a3f..62a95a4 100644
--- a/test/http/http_response_test.cpp
+++ b/test/http/http_response_test.cpp
@@ -17,15 +17,17 @@
#include <string>
#include "gtest/gtest.h"
+namespace crow
+{
namespace
{
-void addHeaders(crow::Response& res)
+void addHeaders(Response& res)
{
res.addHeader("myheader", "myvalue");
res.keepAlive(true);
res.result(boost::beast::http::status::ok);
}
-void verifyHeaders(crow::Response& res)
+void verifyHeaders(Response& res)
{
EXPECT_EQ(res.getHeaderValue("myheader"), "myvalue");
EXPECT_EQ(res.keepAlive(), true);
@@ -68,13 +70,13 @@
TEST(HttpResponse, Headers)
{
- crow::Response res;
+ Response res;
addHeaders(res);
verifyHeaders(res);
}
TEST(HttpResponse, StringBody)
{
- crow::Response res;
+ Response res;
addHeaders(res);
std::string_view bodyValue = "this is my new body";
res.write({bodyValue.data(), bodyValue.length()});
@@ -83,7 +85,7 @@
}
TEST(HttpResponse, HttpBody)
{
- crow::Response res;
+ Response res;
addHeaders(res);
TemporaryFileHandle temporaryFile("sample text");
res.openFile(temporaryFile.stringPath);
@@ -92,7 +94,7 @@
}
TEST(HttpResponse, HttpBodyWithFd)
{
- crow::Response res;
+ Response res;
addHeaders(res);
TemporaryFileHandle temporaryFile("sample text");
FILE* fd = fopen(temporaryFile.stringPath.c_str(), "r+");
@@ -103,7 +105,7 @@
TEST(HttpResponse, Base64HttpBodyWithFd)
{
- crow::Response res;
+ Response res;
addHeaders(res);
TemporaryFileHandle temporaryFile("sample text");
FILE* fd = fopen(temporaryFile.stringPath.c_str(), "r");
@@ -115,7 +117,7 @@
TEST(HttpResponse, BodyTransitions)
{
- crow::Response res;
+ Response res;
addHeaders(res);
TemporaryFileHandle temporaryFile("sample text");
res.openFile(temporaryFile.stringPath);
@@ -138,7 +140,7 @@
TEST(HttpResponse, StringBodyWriterLarge)
{
- crow::Response res;
+ Response res;
std::string data = generateBigdata();
res.write(std::string(data));
EXPECT_EQ(getData(res.response), data);
@@ -146,7 +148,7 @@
TEST(HttpResponse, Base64HttpBodyWriter)
{
- crow::Response res;
+ Response res;
std::string data = "sample text";
TemporaryFileHandle temporaryFile(data);
FILE* f = fopen(temporaryFile.stringPath.c_str(), "r+");
@@ -156,7 +158,7 @@
TEST(HttpResponse, Base64HttpBodyWriterLarge)
{
- crow::Response res;
+ Response res;
std::string data = generateBigdata();
TemporaryFileHandle temporaryFile(data);
@@ -166,12 +168,12 @@
ec);
EXPECT_EQ(ec.value(), 0);
res.openFd(file.native_handle(), bmcweb::EncodingType::Base64);
- EXPECT_EQ(getData(res.response), crow::utility::base64encode(data));
+ EXPECT_EQ(getData(res.response), utility::base64encode(data));
}
TEST(HttpResponse, HttpBodyWriterLarge)
{
- crow::Response res;
+ Response res;
std::string data = generateBigdata();
TemporaryFileHandle temporaryFile(data);
@@ -183,5 +185,5 @@
res.openFd(file.native_handle());
EXPECT_EQ(getData(res.response), data);
}
-
} // namespace
+} // namespace crow
diff --git a/test/http/router_test.cpp b/test/http/router_test.cpp
index 63b7c11..4371e7e 100644
--- a/test/http/router_test.cpp
+++ b/test/http/router_test.cpp
@@ -21,7 +21,7 @@
namespace
{
-using ::crow::utility::getParameterTag;
+using utility::getParameterTag;
TEST(Router, AllowHeader)
{
diff --git a/test/http/utility_test.cpp b/test/http/utility_test.cpp
index f369d8c..1a99d6d 100644
--- a/test/http/utility_test.cpp
+++ b/test/http/utility_test.cpp
@@ -22,8 +22,6 @@
namespace
{
-using ::crow::utility::getParameterTag;
-
TEST(Utility, Base64DecodeAuthString)
{
std::string authString("dXNlcm40bWU6cGFzc3cwcmQ=");