-
Notifications
You must be signed in to change notification settings - Fork 557
Add HTTP multipart writer #2110
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2110 +/- ##
==========================================
+ Coverage 72.57% 72.62% +0.05%
==========================================
Files 635 637 +2
Lines 30474 30524 +50
Branches 3291 3291
==========================================
+ Hits 22115 22168 +53
Misses 6453 6453
+ Partials 1906 1903 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <[email protected]>
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.
Pull Request Overview
Adds a new HTTP multipart writer utility alongside updates to the reader callback API and build configuration.
- Introduces
multipart_writer
andheader_builder
for constructing multipart request bodies, with tests covering various payload/header scenarios. - Refactors
multipart_reader
to use the newcallback_ref_impl
wrapper and updatescallback.hpp
to support reference-based callbacks. - Updates CMakeLists to include new files and documents the addition in CHANGELOG.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
libcaf_net/caf/net/http/multipart_writer.hpp | New class definitions for multipart_writer and nested header_builder |
libcaf_net/caf/net/http/multipart_writer.cpp | Implementation of the writer, including header writing and payload appending |
libcaf_net/caf/net/http/multipart_writer.test.cpp | Comprehensive tests for writer capabilities (no headers, single header, builder function, custom reset) |
libcaf_net/caf/net/http/multipart_reader.hpp | Updated for_each and do_parse to use callback_ref_impl |
libcaf_core/caf/callback.hpp | Added callback_ref_impl to wrap function objects by reference |
libcaf_net/CMakeLists.txt | Registered new source and test files |
CHANGELOG.md | Added entry for the new multipart reader and writer |
Comments suppressed due to low confidence (4)
libcaf_net/caf/net/http/multipart_writer.hpp:24
- Add a brief doxygen comment explaining the purpose of
header_builder::add
and that it returns a reference for method chaining.
header_builder& add(std::string_view key, std::string_view value);
libcaf_net/caf/net/http/multipart_writer.test.cpp:107
- Consider adding a test case that chains calls to
header_builder::add
, e.g.,w.add(...).add(...);
, to verify the chaining behavior.
w.add("Content-Type", "text/plain");
libcaf_net/caf/net/http/multipart_writer.cpp:65
- [nitpick] The variable name
kvp
is a bit vague; consider renaming to something more descriptive likeheader_pair
.
auto kvp = kvp_t{key, value};
libcaf_net/caf/net/http/multipart_reader.hpp:64
- Update the doc comment for
do_parse
to describe the callback signature (header&&, const_byte_span
) and note that it takes acallback
reference rather than a function pointer.
/// @param fn Function to call for each part
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.
Found a nit. I believe we can avoid the void*
8133de4
to
e24470a
Compare
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.
Looks good.
Closes #2073.
Adds a convenience API for writing an HTTP multipart body.