-
Notifications
You must be signed in to change notification settings - Fork 14
buffer-param #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
buffer-param #154
Changes from all commits
174da59
c4e736e
31d052d
1783f3d
2c08daf
4930234
57c0538
02b8647
998f8cb
0ea6d15
fc56858
249160a
e2e576d
c73f392
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| * text=auto eol=lf |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,10 @@ | ||
| { | ||
| "version": 8, | ||
| "configurePresets": [ | ||
| { | ||
| "name": "Custom configure preset", | ||
| "displayName": "Custom configure preset", | ||
| "description": "Sets Ninja generator, build and install directory", | ||
| "generator": "Ninja", | ||
| "binaryDir": "${sourceDir}/out/build/${presetName}", | ||
| "cacheVariables": { | ||
| "CMAKE_BUILD_TYPE": "Debug", | ||
| "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| "version": 6, | ||
| "cmakeMinimumRequired": { | ||
| "major": 3, | ||
| "minor": 25, | ||
| "patch": 0 | ||
| }, | ||
| "configurePresets": [], | ||
| "buildPresets": [] | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,18 +8,10 @@ | |||||||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #include "message.hpp" | ||||||||||||||||||||||||||||||||||
| #include "mime_type.hpp" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #include <boost/capy/file.hpp> | ||||||||||||||||||||||||||||||||||
| #include <boost/http/field.hpp> | ||||||||||||||||||||||||||||||||||
| #include <boost/system/system_error.hpp> | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
Comment on lines
10
to
13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a file-level implementation overview after the includes. This file contains non-trivial request/body handling logic but lacks the required high-level /* */ overview comment. As per coding guidelines, non-trivial implementation files should include a post-include overview. 📝 Suggested addition `#include` "message.hpp"
`#include` <boost/http/field.hpp>
+/*
+ * High-level overview:
+ * - Implements string_body helpers used for request setup.
+ * - Computes Content-Length and starts the serializer for message bodies.
+ */
namespace capy = boost::capy;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| #include <filesystem> | ||||||||||||||||||||||||||||||||||
| #include <iostream> | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| namespace capy = boost::capy; | ||||||||||||||||||||||||||||||||||
| namespace fs = std::filesystem; | ||||||||||||||||||||||||||||||||||
| using system_error = boost::system::system_error; | ||||||||||||||||||||||||||||||||||
| namespace capy = boost::capy; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| string_body::string_body(std::string body, std::string content_type) | ||||||||||||||||||||||||||||||||||
| : body_{ std::move(body) } | ||||||||||||||||||||||||||||||||||
|
|
@@ -53,79 +45,6 @@ string_body::body() const noexcept | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| file_body::file_body(std::string path) | ||||||||||||||||||||||||||||||||||
| : path_{ std::move(path) } | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| http::method | ||||||||||||||||||||||||||||||||||
| file_body::method() const noexcept | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| return http::method::put; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| core::string_view | ||||||||||||||||||||||||||||||||||
| file_body::content_type() const noexcept | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| return mime_type(path_); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| std::uint64_t | ||||||||||||||||||||||||||||||||||
| file_body::content_length() const | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| return fs::file_size(path_); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| http::file_source | ||||||||||||||||||||||||||||||||||
| file_body::body() const | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| boost::capy::file file; | ||||||||||||||||||||||||||||||||||
| error_code ec; | ||||||||||||||||||||||||||||||||||
| file.open(path_.c_str(), boost::capy::file_mode::read, ec); | ||||||||||||||||||||||||||||||||||
| if(ec) | ||||||||||||||||||||||||||||||||||
| throw system_error{ ec }; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| return http::file_source{ std::move(file), content_length() }; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| boost::http::source::results | ||||||||||||||||||||||||||||||||||
| stdin_body::source::on_read(capy::mutable_buffer mb) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| std::cin.read(static_cast<char*>(mb.data()), mb.size()); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| return { .ec = {}, | ||||||||||||||||||||||||||||||||||
| .bytes = static_cast<std::size_t>(std::cin.gcount()), | ||||||||||||||||||||||||||||||||||
| .finished = std::cin.eof() }; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| http::method | ||||||||||||||||||||||||||||||||||
| stdin_body::method() const noexcept | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| return http::method::put; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| core::string_view | ||||||||||||||||||||||||||||||||||
| stdin_body::content_type() const noexcept | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| return "application/octet-stream"; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| boost::optional<std::size_t> | ||||||||||||||||||||||||||||||||||
| stdin_body::content_length() const noexcept | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| return boost::none; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| stdin_body::source | ||||||||||||||||||||||||||||||||||
| stdin_body::body() const | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| return {}; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| void | ||||||||||||||||||||||||||||||||||
| message::set_headers(http::request& request) const | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
|
|
@@ -138,20 +57,11 @@ message::set_headers(http::request& request) const | |||||||||||||||||||||||||||||||||
| request.set_method(f.method()); | ||||||||||||||||||||||||||||||||||
| request.set(field::content_type, f.content_type()); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| boost::optional<std::size_t> content_length = | ||||||||||||||||||||||||||||||||||
| f.content_length(); | ||||||||||||||||||||||||||||||||||
| if(content_length.has_value()) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| request.set_content_length(content_length.value()); | ||||||||||||||||||||||||||||||||||
| if(content_length.value() >= 1024 * 1024 && | ||||||||||||||||||||||||||||||||||
| request.version() == http::version::http_1_1) | ||||||||||||||||||||||||||||||||||
| request.set(field::expect, "100-continue"); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| request.set_chunked(true); | ||||||||||||||||||||||||||||||||||
| std::size_t content_length = f.content_length(); | ||||||||||||||||||||||||||||||||||
| request.set_content_length(content_length); | ||||||||||||||||||||||||||||||||||
| if(content_length >= 1024 * 1024 && | ||||||||||||||||||||||||||||||||||
| request.version() == http::version::http_1_1) | ||||||||||||||||||||||||||||||||||
| request.set(field::expect, "100-continue"); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| body_); | ||||||||||||||||||||||||||||||||||
|
|
@@ -167,8 +77,7 @@ message::start_serializer( | |||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| if constexpr(!std::is_same_v<decltype(f), const std::monostate&>) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| serializer.start<std::decay_t<decltype(f.body())>>( | ||||||||||||||||||||||||||||||||||
| request, f.body()); | ||||||||||||||||||||||||||||||||||
| serializer.start(request, f.body()); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: cppalliance/beast2
Length of output: 450
CMakePresets.json requires CMake 3.25.0 but CMakeLists.txt only supports up to 3.20.
The schema version 6 and
cmakeMinimumRequired3.25.0 in CMakePresets.json create an incompatibility: the main CMakeLists.txt declarescmake_minimum_required(VERSION 3.8...3.20), which allows CMake up to 3.20. Users with CMake 3.21–3.24 will be unable to use presets while the main build remains compatible.Either update CMakeLists.txt to require CMake 3.25.0, or lower CMakePresets.json's
cmakeMinimumRequiredto match the actual project minimum (3.8).🤖 Prompt for AI Agents