-
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
buffer-param #154
Changes from all commits
174da59
c4e736e
31d052d
1783f3d
2c08daf
4930234
57c0538
02b8647
998f8cb
0ea6d15
fc56858
249160a
e2e576d
c73f392
6195d0c
d48d3a1
44db682
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 |
|---|---|---|
|
|
@@ -153,7 +153,6 @@ connect_socks5_proxy( | |
| asio::awaitable<void> | ||
| connect_http_proxy( | ||
| const operation_config& oc, | ||
| capy::polystore& capy_ctx, | ||
| asio::ip::tcp::socket& stream, | ||
| const urls::url_view& url, | ||
| const urls::url_view& proxy) | ||
|
|
@@ -190,8 +189,8 @@ connect_http_proxy( | |
| request.set(field::proxy_authorization, basic_auth); | ||
| } | ||
|
|
||
| auto serializer = http::serializer{ capy_ctx }; | ||
| auto parser = http::response_parser{ capy_ctx }; | ||
| auto serializer = http::serializer{}; | ||
| auto parser = http::response_parser{}; | ||
|
Comment on lines
+192
to
+193
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 brief implementation overview block after the includes. 📝 Suggested block comment `#include` <boost/url.hpp>
+/*
+Overview:
+ - Establishes TCP connections (direct, HTTP proxy, SOCKS5).
+ - Performs CONNECT handshake for HTTP proxies.
+ - Upgrades to TLS when required.
+*/🤖 Prompt for AI Agents |
||
|
|
||
| serializer.start(request); | ||
| co_await beast2::async_write(stream, serializer); | ||
|
|
@@ -225,7 +224,6 @@ asio::awaitable<void> | |
| connect( | ||
| const operation_config& oc, | ||
| ssl::context& ssl_ctx, | ||
| capy::polystore& capy_ctx, | ||
| any_stream& stream, | ||
| urls::url url) | ||
| { | ||
|
|
@@ -261,7 +259,7 @@ connect( | |
| { | ||
| if(oc.proxy.scheme() == "http") | ||
| { | ||
| co_await connect_http_proxy(oc, capy_ctx, socket, url, oc.proxy); | ||
| co_await connect_http_proxy(oc, socket, url, oc.proxy); | ||
| } | ||
| else if(oc.proxy.scheme() == "socks5") | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,8 +31,8 @@ | |
| #include <boost/capy/buffers.hpp> | ||
| #include <boost/beast2.hpp> | ||
| #include <boost/http.hpp> | ||
| #include <boost/capy/brotli/decode.hpp> | ||
| #include <boost/capy/zlib/inflate.hpp> | ||
| #include <boost/http/brotli/decode.hpp> | ||
| #include <boost/http/zlib/inflate.hpp> | ||
|
Comment on lines
+34
to
+35
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 brief implementation overview block after the includes. 📝 Suggested block comment `#include` <boost/url/url.hpp>
+/*
+Overview:
+ - Builds requests, manages redirects, cookies, and retries.
+ - Streams responses with optional progress reporting.
+ - Installs parser/serializer services and decoders for content encodings.
+*/🤖 Prompt for AI Agents |
||
| #include <boost/scope/scope_exit.hpp> | ||
| #include <boost/scope/scope_fail.hpp> | ||
| #include <boost/url/parse.hpp> | ||
|
|
@@ -45,13 +45,13 @@ namespace capy = boost::capy; | |
| namespace scope = boost::scope; | ||
| using system_error = boost::system::system_error; | ||
|
|
||
| #ifdef BOOST_CAPY_HAS_ZLIB | ||
| #ifdef BOOST_HTTP_HAS_ZLIB | ||
| constexpr bool capy_has_zlib = true; | ||
| #else | ||
| constexpr bool capy_has_zlib = false; | ||
| #endif | ||
|
|
||
| #ifdef BOOST_CAPY_HAS_BROTLI | ||
| #ifdef BOOST_HTTP_HAS_BROTLI | ||
| constexpr bool capy_has_brotli = true; | ||
| #else | ||
| constexpr bool capy_has_brotli = false; | ||
|
|
@@ -345,15 +345,14 @@ perform_request( | |
| boost::optional<cookie_jar>& cookie_jar, | ||
| core::string_view exp_cookies, | ||
| ssl::context& ssl_ctx, | ||
| capy::polystore& capy_ctx, | ||
| message msg, | ||
| request_opt request_opt) | ||
| { | ||
| using field = http::field; | ||
| auto executor = co_await asio::this_coro::executor; | ||
| auto stream = any_stream{ asio::ip::tcp::socket{ executor } }; | ||
| auto parser = http::response_parser{ capy_ctx }; | ||
| auto serializer = http::serializer{ capy_ctx }; | ||
| auto parser = http::response_parser{}; | ||
| auto serializer = http::serializer{}; | ||
|
|
||
| urls::url url = [&]() | ||
| { | ||
|
|
@@ -376,26 +375,7 @@ perform_request( | |
|
|
||
| if(!request_opt.input.empty()) | ||
| { | ||
| msg = [&]() -> message | ||
| { | ||
| if(request_opt.input == "-") | ||
| return stdin_body{}; | ||
|
|
||
| auto path = request_opt.input; | ||
|
|
||
| // Append filename to URL if missing | ||
| auto segs = url.encoded_segments(); | ||
| if(segs.empty()) | ||
| { | ||
| segs.push_back(path.filename().string()); | ||
| } | ||
| else if(auto back = --segs.end(); back->empty()) | ||
| { | ||
| segs.replace(back, path.filename().string()); | ||
| } | ||
|
|
||
| return file_body{ path.string() }; | ||
| }(); | ||
| throw std::runtime_error{ "File upload is not available" }; | ||
| } | ||
|
|
||
| fs::path output_path = [&]() | ||
|
|
@@ -465,7 +445,7 @@ perform_request( | |
|
|
||
| co_await asio::co_spawn( | ||
| executor, | ||
| connect(oc, ssl_ctx, capy_ctx, stream, url), | ||
| connect(oc, ssl_ctx, stream, url), | ||
| asio::cancel_after(oc.connect_timeout)); | ||
|
|
||
| if(oc.recvpersecond) | ||
|
|
@@ -759,7 +739,6 @@ co_main(int argc, char* argv[]) | |
|
|
||
| auto executor = co_await asio::this_coro::executor; | ||
| auto task_group = ::task_group{ executor, oc.parallel_max }; | ||
| auto capy_ctx = capy::polystore{}; | ||
| auto cookie_jar = boost::optional<::cookie_jar>{}; | ||
| auto header_output = boost::optional<any_ostream>{}; | ||
| auto exp_cookies = std::string{}; | ||
|
|
@@ -778,22 +757,22 @@ co_main(int argc, char* argv[]) | |
| if constexpr(capy_has_brotli) | ||
| { | ||
| cfg.apply_brotli_decoder = true; | ||
| capy::brotli::install_decode_service(capy_ctx); | ||
| http::brotli::install_decode_service(); | ||
| } | ||
| if constexpr(capy_has_zlib) | ||
| { | ||
| cfg.apply_deflate_decoder = true; | ||
| cfg.apply_gzip_decoder = true; | ||
| capy::zlib::install_inflate_service(capy_ctx); | ||
| http::zlib::install_inflate_service(); | ||
| } | ||
| http::install_parser_service(capy_ctx, cfg); | ||
| http::install_parser_service(cfg); | ||
| } | ||
|
|
||
| // serializer service | ||
| { | ||
| http::serializer::config cfg; | ||
| cfg.payload_buffer = 1024 * 1024; | ||
| http::install_serializer_service(capy_ctx, cfg); | ||
| http::install_serializer_service(cfg); | ||
| } | ||
|
|
||
| if(!oc.headerfile.empty()) | ||
|
|
@@ -831,7 +810,6 @@ co_main(int argc, char* argv[]) | |
| cookie_jar, | ||
| exp_cookies, | ||
| ssl_ctx, | ||
| capy_ctx, | ||
| oc.msg, | ||
| ropt.value()); | ||
| }; | ||
|
|
||
| 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