From f7d929f0cff76b24b30f0d71c9cb840000a10ad3 Mon Sep 17 00:00:00 2001 From: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com> Date: Thu, 9 Jan 2025 16:07:17 -0500 Subject: [PATCH] feat: Add a `Form::into_reader()` method on blocking multipart forms. (#2524) An example use case is compressing multipart form data with zstd. The entire contents of the payload have to be compressed together, which requires accessing the contents of the `Form`. The existing reader functionality already implements what we need, but just isn't publicly accessible. This PR adds a `pub` method for it. --- src/blocking/multipart.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/blocking/multipart.rs b/src/blocking/multipart.rs index fc3222bec..b3f6cbe3d 100644 --- a/src/blocking/multipart.rs +++ b/src/blocking/multipart.rs @@ -148,6 +148,11 @@ impl Form { Reader::new(self) } + /// Produce a reader over the multipart form data. + pub fn into_reader(self) -> impl Read { + self.reader() + } + // If predictable, computes the length the request will have // The length should be predictable if only String and file fields have been added, // but not if a generic reader has been added;