summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--http/http2_connection.hpp4
-rw-r--r--http/http_body.hpp (renamed from http/http_file_body.hpp)8
-rw-r--r--http/http_client.hpp11
-rw-r--r--http/http_connection.hpp5
-rw-r--r--http/http_request.hpp6
-rw-r--r--http/http_response.hpp4
-rw-r--r--http/server_sent_event.hpp3
-rw-r--r--http/websocket.hpp5
-rw-r--r--meson.build2
-rw-r--r--redfish-core/lib/certificate_service.hpp18
-rw-r--r--test/http/http_body_test.cpp (renamed from test/http/http_file_body_test.cpp)42
-rw-r--r--test/http/http_response_test.cpp17
12 files changed, 65 insertions, 60 deletions
diff --git a/http/http2_connection.hpp b/http/http2_connection.hpp
index 97dcf4e2bb..ed3748059b 100644
--- a/http/http2_connection.hpp
+++ b/http/http2_connection.hpp
@@ -39,7 +39,7 @@ struct Http2StreamData
{
Request req{};
Response res{};
- std::optional<bmcweb::FileBody::writer> writer;
+ std::optional<bmcweb::HttpBody::writer> writer;
};
template <typename Adaptor, typename Handler>
@@ -173,7 +173,7 @@ class HTTP2Connection :
}
Http2StreamData& stream = it->second;
crow::Response& res = stream.res;
- http::response<bmcweb::FileBody>& fbody = res.response;
+ http::response<bmcweb::HttpBody>& fbody = res.response;
stream.writer.emplace(fbody.base(), fbody.body());
nghttp2_data_provider dataPrd{
diff --git a/http/http_file_body.hpp b/http/http_body.hpp
index 17554a4e9b..84351ee303 100644
--- a/http/http_file_body.hpp
+++ b/http/http_body.hpp
@@ -14,7 +14,7 @@
namespace bmcweb
{
-struct FileBody
+struct HttpBody
{
class writer;
class reader;
@@ -27,7 +27,7 @@ enum class EncodingType
Base64,
};
-class FileBody::value_type
+class HttpBody::value_type
{
boost::beast::file_posix fileHandle;
std::optional<size_t> fileSize;
@@ -155,7 +155,7 @@ class FileBody::value_type
}
};
-class FileBody::writer
+class HttpBody::writer
{
public:
using const_buffers_type = boost::asio::const_buffer;
@@ -236,7 +236,7 @@ class FileBody::writer
}
};
-class FileBody::reader
+class HttpBody::reader
{
value_type& value;
diff --git a/http/http_client.hpp b/http/http_client.hpp
index 6f42f3ef6e..2d03487e84 100644
--- a/http/http_client.hpp
+++ b/http/http_client.hpp
@@ -16,6 +16,7 @@
#pragma once
#include "async_resolve.hpp"
+#include "http_body.hpp"
#include "http_response.hpp"
#include "logging.hpp"
#include "ssl_key_handler.hpp"
@@ -116,10 +117,10 @@ struct ConnectionPolicy
struct PendingRequest
{
- boost::beast::http::request<bmcweb::FileBody> req;
+ boost::beast::http::request<bmcweb::HttpBody> req;
std::function<void(bool, uint32_t, Response&)> callback;
PendingRequest(
- boost::beast::http::request<bmcweb::FileBody>&& reqIn,
+ boost::beast::http::request<bmcweb::HttpBody>&& reqIn,
const std::function<void(bool, uint32_t, Response&)>& callbackIn) :
req(std::move(reqIn)),
callback(callbackIn)
@@ -138,8 +139,8 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo>
uint32_t connId;
// Data buffers
- http::request<bmcweb::FileBody> req;
- using parser_type = http::response_parser<bmcweb::FileBody>;
+ http::request<bmcweb::HttpBody> req;
+ using parser_type = http::response_parser<bmcweb::HttpBody>;
std::optional<parser_type> parser;
boost::beast::flat_static_buffer<httpReadBufferSize> buffer;
Response res;
@@ -733,7 +734,7 @@ class ConnectionPool : public std::enable_shared_from_this<ConnectionPool>
const std::function<void(Response&)>& resHandler)
{
// Construct the request to be sent
- boost::beast::http::request<bmcweb::FileBody> thisReq(
+ boost::beast::http::request<bmcweb::HttpBody> thisReq(
verb, destUri.encoded_target(), 11, "", httpHeader);
thisReq.set(boost::beast::http::field::host,
destUri.encoded_host_address());
diff --git a/http/http_connection.hpp b/http/http_connection.hpp
index ed3dc07573..d60e74b9a5 100644
--- a/http/http_connection.hpp
+++ b/http/http_connection.hpp
@@ -5,6 +5,7 @@
#include "authentication.hpp"
#include "complete_response_fields.hpp"
#include "http2_connection.hpp"
+#include "http_body.hpp"
#include "http_response.hpp"
#include "http_utility.hpp"
#include "logging.hpp"
@@ -611,8 +612,8 @@ class Connection :
Handler* handler;
// Making this a std::optional allows it to be efficiently destroyed and
// re-created on Connection reset
- std::optional<boost::beast::http::request_parser<bmcweb::FileBody>> parser;
- std::optional<boost::beast::http::response_serializer<bmcweb::FileBody>>
+ std::optional<boost::beast::http::request_parser<bmcweb::HttpBody>> parser;
+ std::optional<boost::beast::http::response_serializer<bmcweb::HttpBody>>
serializer;
boost::beast::flat_static_buffer<8192> buffer;
diff --git a/http/http_request.hpp b/http/http_request.hpp
index 9cd4a0c656..ee940d658b 100644
--- a/http/http_request.hpp
+++ b/http/http_request.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "common.hpp"
+#include "http_body.hpp"
#include "sessions.hpp"
#include <boost/asio/io_context.hpp>
@@ -8,7 +9,6 @@
#include <boost/beast/http/message.hpp>
#include <boost/beast/websocket.hpp>
#include <boost/url/url.hpp>
-#include <http_file_body.hpp>
#include <string>
#include <string_view>
@@ -19,7 +19,7 @@ namespace crow
struct Request
{
- boost::beast::http::request<bmcweb::FileBody> req;
+ boost::beast::http::request<bmcweb::HttpBody> req;
private:
boost::urls::url urlBase{};
@@ -33,7 +33,7 @@ struct Request
std::shared_ptr<persistent_data::UserSession> session;
std::string userRole{};
- Request(boost::beast::http::request<bmcweb::FileBody> reqIn,
+ Request(boost::beast::http::request<bmcweb::HttpBody> reqIn,
std::error_code& ec) :
req(std::move(reqIn))
{
diff --git a/http/http_response.hpp b/http/http_response.hpp
index dca7682a98..afd51c1420 100644
--- a/http/http_response.hpp
+++ b/http/http_response.hpp
@@ -1,5 +1,5 @@
#pragma once
-#include "http_file_body.hpp"
+#include "http_body.hpp"
#include "logging.hpp"
#include "utils/hex_utils.hpp"
@@ -23,7 +23,7 @@ struct Response
template <typename Adaptor, typename Handler>
friend class crow::Connection;
- http::response<bmcweb::FileBody> response;
+ http::response<bmcweb::HttpBody> response;
nlohmann::json jsonValue;
using fields_type = http::header<false, http::fields>;
diff --git a/http/server_sent_event.hpp b/http/server_sent_event.hpp
index 730bdce51f..a8bccdb450 100644
--- a/http/server_sent_event.hpp
+++ b/http/server_sent_event.hpp
@@ -1,4 +1,5 @@
#pragma once
+#include "http_body.hpp"
#include "http_request.hpp"
#include "http_response.hpp"
@@ -272,7 +273,7 @@ class ConnectionImpl : public Connection
Adaptor adaptor;
- using BodyType = bmcweb::FileBody;
+ using BodyType = bmcweb::HttpBody;
boost::beast::http::response<BodyType> res;
std::optional<boost::beast::http::response_serializer<BodyType>> serializer;
boost::asio::io_context& ioc;
diff --git a/http/websocket.hpp b/http/websocket.hpp
index 388a3e4031..d232c02330 100644
--- a/http/websocket.hpp
+++ b/http/websocket.hpp
@@ -1,5 +1,6 @@
#pragma once
#include "async_resp.hpp"
+#include "http_body.hpp"
#include "http_request.hpp"
#include <boost/asio/buffer.hpp>
@@ -128,7 +129,7 @@ class ConnectionImpl : public Connection
}));
// Make a pointer to keep the req alive while we accept it.
- using Body = boost::beast::http::request<bmcweb::FileBody>;
+ using Body = boost::beast::http::request<bmcweb::HttpBody>;
std::unique_ptr<Body> mobile = std::make_unique<Body>(req.req);
Body* ptr = mobile.get();
// Perform the websocket upgrade
@@ -227,7 +228,7 @@ class ConnectionImpl : public Connection
void acceptDone(const std::shared_ptr<Connection>& /*self*/,
const std::unique_ptr<
- boost::beast::http::request<bmcweb::FileBody>>& /*req*/,
+ boost::beast::http::request<bmcweb::HttpBody>>& /*req*/,
const boost::system::error_code& ec)
{
if (ec)
diff --git a/meson.build b/meson.build
index d644b79b22..487ec1f07f 100644
--- a/meson.build
+++ b/meson.build
@@ -431,7 +431,7 @@ srcfiles_unittest = files(
'test/http/verb_test.cpp',
'test/http/server_sent_event_test.cpp',
'test/http/mutual_tls_meta.cpp',
- 'test/http/http_file_body_test.cpp',
+ 'test/http/http_body_test.cpp',
'test/include/dbus_utility_test.cpp',
'test/include/google/google_service_root_test.cpp',
'test/include/json_html_serializer.cpp',
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index 8bdcb53626..a176dd5f93 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -913,9 +913,9 @@ inline void handleHTTPSCertificateCollectionPost(
asyncResp->res.jsonValue["Name"] = "HTTPS Certificate";
asyncResp->res.jsonValue["Description"] = "HTTPS Certificate";
- std::string certFileBody = getCertificateFromReqBody(asyncResp, req);
+ std::string certHttpBody = getCertificateFromReqBody(asyncResp, req);
- if (certFileBody.empty())
+ if (certHttpBody.empty())
{
BMCWEB_LOG_ERROR("Cannot get certificate from request body.");
messages::unrecognizedRequestBody(asyncResp->res);
@@ -923,7 +923,7 @@ inline void handleHTTPSCertificateCollectionPost(
}
std::shared_ptr<CertificateFile> certFile =
- std::make_shared<CertificateFile>(certFileBody);
+ std::make_shared<CertificateFile>(certHttpBody);
crow::connections::systemBus->async_method_call(
[asyncResp, certFile](const boost::system::error_code& ec,
@@ -1019,9 +1019,9 @@ inline void handleLDAPCertificateCollectionPost(
{
return;
}
- std::string certFileBody = getCertificateFromReqBody(asyncResp, req);
+ std::string certHttpBody = getCertificateFromReqBody(asyncResp, req);
- if (certFileBody.empty())
+ if (certHttpBody.empty())
{
BMCWEB_LOG_ERROR("Cannot get certificate from request body.");
messages::unrecognizedRequestBody(asyncResp->res);
@@ -1029,7 +1029,7 @@ inline void handleLDAPCertificateCollectionPost(
}
std::shared_ptr<CertificateFile> certFile =
- std::make_shared<CertificateFile>(certFileBody);
+ std::make_shared<CertificateFile>(certHttpBody);
crow::connections::systemBus->async_method_call(
[asyncResp, certFile](const boost::system::error_code& ec,
@@ -1141,9 +1141,9 @@ inline void handleTrustStoreCertificateCollectionPost(
{
return;
}
- std::string certFileBody = getCertificateFromReqBody(asyncResp, req);
+ std::string certHttpBody = getCertificateFromReqBody(asyncResp, req);
- if (certFileBody.empty())
+ if (certHttpBody.empty())
{
BMCWEB_LOG_ERROR("Cannot get certificate from request body.");
messages::unrecognizedRequestBody(asyncResp->res);
@@ -1151,7 +1151,7 @@ inline void handleTrustStoreCertificateCollectionPost(
}
std::shared_ptr<CertificateFile> certFile =
- std::make_shared<CertificateFile>(certFileBody);
+ std::make_shared<CertificateFile>(certHttpBody);
crow::connections::systemBus->async_method_call(
[asyncResp, certFile](const boost::system::error_code& ec,
const std::string& objectPath) {
diff --git a/test/http/http_file_body_test.cpp b/test/http/http_body_test.cpp
index 4eaa93bac2..6367cf9409 100644
--- a/test/http/http_file_body_test.cpp
+++ b/test/http/http_body_test.cpp
@@ -1,5 +1,5 @@
#include "file_test_utilities.hpp"
-#include "http_file_body.hpp"
+#include "http_body.hpp"
#include <boost/system/error_code.hpp>
@@ -17,58 +17,58 @@ namespace bmcweb
namespace
{
-TEST(HttpFileBodyValueType, MoveString)
+TEST(HttpHttpBodyValueType, MoveString)
{
- FileBody::value_type value("teststring");
+ HttpBody::value_type value("teststring");
// Move constructor
- FileBody::value_type value2(std::move(value));
+ HttpBody::value_type value2(std::move(value));
EXPECT_EQ(value2.encodingType, EncodingType::Raw);
EXPECT_EQ(value2.str(), "teststring");
EXPECT_EQ(value2.payloadSize(), 10);
}
-TEST(HttpFileBodyValueType, MoveOperatorString)
+TEST(HttpHttpBodyValueType, MoveOperatorString)
{
- FileBody::value_type value;
+ HttpBody::value_type value;
value.str() = "teststring";
// Move constructor
- FileBody::value_type value2 = std::move(value);
+ HttpBody::value_type value2 = std::move(value);
EXPECT_EQ(value2.encodingType, EncodingType::Raw);
EXPECT_EQ(value2.str(), "teststring");
EXPECT_EQ(value2.payloadSize(), 10);
}
-TEST(HttpFileBodyValueType, copysignl)
+TEST(HttpHttpBodyValueType, copysignl)
{
- FileBody::value_type value;
+ HttpBody::value_type value;
value.str() = "teststring";
// Move constructor
- FileBody::value_type value2(value);
+ HttpBody::value_type value2(value);
EXPECT_EQ(value2.encodingType, EncodingType::Raw);
EXPECT_EQ(value2.str(), "teststring");
EXPECT_EQ(value2.payloadSize(), 10);
}
-TEST(HttpFileBodyValueType, CopyOperatorString)
+TEST(HttpHttpBodyValueType, CopyOperatorString)
{
- FileBody::value_type value;
+ HttpBody::value_type value;
value.str() = "teststring";
// Move constructor
- FileBody::value_type value2 = value;
+ HttpBody::value_type value2 = value;
EXPECT_EQ(value2.encodingType, EncodingType::Raw);
EXPECT_EQ(value2.str(), "teststring");
EXPECT_EQ(value2.payloadSize(), 10);
}
-TEST(HttpFileBodyValueType, MoveFile)
+TEST(HttpHttpBodyValueType, MoveFile)
{
- FileBody::value_type value(EncodingType::Base64);
+ HttpBody::value_type value(EncodingType::Base64);
std::string filepath = makeFile("teststring");
boost::system::error_code ec;
value.open(filepath.c_str(), boost::beast::file_mode::read, ec);
ASSERT_FALSE(ec);
// Move constructor
- FileBody::value_type value2(std::move(value));
+ HttpBody::value_type value2(std::move(value));
std::array<char, 11> buffer{};
size_t out = value2.file().read(buffer.data(), buffer.size(), ec);
ASSERT_FALSE(ec);
@@ -83,15 +83,15 @@ TEST(HttpFileBodyValueType, MoveFile)
EXPECT_EQ(value2.payloadSize(), 16);
}
-TEST(HttpFileBodyValueType, MoveOperatorFile)
+TEST(HttpHttpBodyValueType, MoveOperatorFile)
{
- FileBody::value_type value(EncodingType::Base64);
+ HttpBody::value_type value(EncodingType::Base64);
std::string filepath = makeFile("teststring");
boost::system::error_code ec;
value.open(filepath.c_str(), boost::beast::file_mode::read, ec);
ASSERT_FALSE(ec);
// Move constructor
- FileBody::value_type value2 = std::move(value);
+ HttpBody::value_type value2 = std::move(value);
std::array<char, 11> buffer{};
size_t out = value2.file().read(buffer.data(), buffer.size(), ec);
ASSERT_FALSE(ec);
@@ -105,9 +105,9 @@ TEST(HttpFileBodyValueType, MoveOperatorFile)
EXPECT_EQ(value2.payloadSize(), 16);
}
-TEST(HttpFileBodyValueType, SetFd)
+TEST(HttpBodyValueType, SetFd)
{
- FileBody::value_type value(EncodingType::Base64);
+ HttpBody::value_type value(EncodingType::Base64);
std::string filepath = makeFile("teststring");
boost::system::error_code ec;
diff --git a/test/http/http_response_test.cpp b/test/http/http_response_test.cpp
index c5bfbdca99..457cd7a924 100644
--- a/test/http/http_response_test.cpp
+++ b/test/http/http_response_test.cpp
@@ -2,6 +2,7 @@
#include "boost/beast/core/flat_buffer.hpp"
#include "boost/beast/http/serializer.hpp"
#include "file_test_utilities.hpp"
+#include "http/http_body.hpp"
#include "http/http_response.hpp"
#include <filesystem>
@@ -24,11 +25,11 @@ void verifyHeaders(crow::Response& res)
EXPECT_EQ(res.result(), boost::beast::http::status::ok);
}
-std::string getData(boost::beast::http::response<bmcweb::FileBody>& m)
+std::string getData(boost::beast::http::response<bmcweb::HttpBody>& m)
{
std::string ret;
- boost::beast::http::response_serializer<bmcweb::FileBody> sr{m};
+ boost::beast::http::response_serializer<bmcweb::HttpBody> sr{m};
sr.split(true);
auto reader = [&sr, &ret](const boost::system::error_code& ec2,
@@ -73,7 +74,7 @@ TEST(HttpResponse, StringBody)
EXPECT_EQ(*res.body(), bodyvalue);
verifyHeaders(res);
}
-TEST(HttpResponse, FileBody)
+TEST(HttpResponse, HttpBody)
{
crow::Response res;
addHeaders(res);
@@ -83,7 +84,7 @@ TEST(HttpResponse, FileBody)
verifyHeaders(res);
std::filesystem::remove(path);
}
-TEST(HttpResponse, FileBodyWithFd)
+TEST(HttpResponse, HttpBodyWithFd)
{
crow::Response res;
addHeaders(res);
@@ -95,7 +96,7 @@ TEST(HttpResponse, FileBodyWithFd)
std::filesystem::remove(path);
}
-TEST(HttpResponse, Base64FileBodyWithFd)
+TEST(HttpResponse, Base64HttpBodyWithFd)
{
crow::Response res;
addHeaders(res);
@@ -145,7 +146,7 @@ TEST(HttpResponse, StringBodyWriterLarge)
testFileData(res, data);
}
-TEST(HttpResponse, Base64FileBodyWriter)
+TEST(HttpResponse, Base64HttpBodyWriter)
{
crow::Response res;
std::string data = "sample text";
@@ -157,7 +158,7 @@ TEST(HttpResponse, Base64FileBodyWriter)
std::filesystem::remove(path);
}
-TEST(HttpResponse, Base64FileBodyWriterLarge)
+TEST(HttpResponse, Base64HttpBodyWriterLarge)
{
crow::Response res;
std::string data = generateBigdata();
@@ -174,7 +175,7 @@ TEST(HttpResponse, Base64FileBodyWriterLarge)
std::filesystem::remove(path);
}
-TEST(HttpResponse, FileBodyWriterLarge)
+TEST(HttpResponse, HttpBodyWriterLarge)
{
crow::Response res;
std::string data = generateBigdata();