Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 3 commits into from
Jul 15, 2025
Merged

Add HTTP multipart writer #2110

merged 3 commits into from
Jul 15, 2025

Conversation

Neverlord
Copy link
Member

Closes #2073.

Adds a convenience API for writing an HTTP multipart body.

Copy link

codecov bot commented Jul 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.62%. Comparing base (ab8a744) to head (e24470a).
Report is 8 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Neverlord Neverlord requested a review from Copilot July 12, 2025 09:46
Copilot

This comment was marked as outdated.

Co-authored-by: Copilot <[email protected]>
@Neverlord Neverlord requested review from riemass and Copilot July 12, 2025 09:48
Copy link
Contributor

@Copilot Copilot AI left a 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 and header_builder for constructing multipart request bodies, with tests covering various payload/header scenarios.
  • Refactors multipart_reader to use the new callback_ref_impl wrapper and updates callback.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 like header_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 a callback reference rather than a function pointer.
  /// @param fn Function to call for each part

Copy link
Member

@riemass riemass left a 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*

@Neverlord Neverlord force-pushed the issue/2073-writer branch from 8133de4 to e24470a Compare July 14, 2025 18:14
Copy link
Member

@riemass riemass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@Neverlord Neverlord merged commit 890807a into main Jul 15, 2025
9 checks passed
@Neverlord Neverlord deleted the issue/2073-writer branch July 15, 2025 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support HTTP multipart requests
2 participants