summaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-02-01 02:25:47 +0300
committerEd Tanous <ed@tanous.net>2024-03-19 03:27:05 +0300
commitb2896149c39967dd9d1ee79357bdc53537cfabd7 (patch)
treed63dd043c5219c7109e403189d12801a0a722e24 /http
parentc51afd54a55d5c8d6cb6e9583e209788f7996fe3 (diff)
downloadbmcweb-b2896149c39967dd9d1ee79357bdc53537cfabd7.tar.xz
Rename FileBody to HttpBody
Now that our custom body type does things more than files, it makes sense to rename it. This commit renames the header itself, then all instances of the class. Tested: Basic GET requests succeed. Change-Id: If4361ac8992fc7c268f48a336707f96e68d3576c Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'http')
-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
8 files changed, 25 insertions, 21 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)