Skip to content

Commit

Permalink
feat: Add a Form::into_reader() method on blocking multipart forms. (
Browse files Browse the repository at this point in the history
…#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.
  • Loading branch information
obi1kenobi authored Jan 9, 2025
1 parent 8b8fdd2 commit f7d929f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/blocking/multipart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f7d929f

Please sign in to comment.