diff --git a/src/async_impl/multipart.rs b/src/async_impl/multipart.rs index a51b5ce25..394c8dd4c 100644 --- a/src/async_impl/multipart.rs +++ b/src/async_impl/multipart.rs @@ -72,6 +72,17 @@ impl Form { self.inner.boundary() } + /// Set the boundary that this form will use. By default the boundary is a + /// long random string to minimize the risk of the boundary appearing in + /// the body content. + /// + /// **Setting a custom boundary incurs significant risk of generating + /// corrupted bodies.** Only use this if you need it and you understand the + /// risk! + pub fn set_boundary(&mut self, boundary: impl Into) { + self.inner.boundary = boundary.into(); + } + /// Add a data field with supplied name and value. /// /// # Examples diff --git a/src/blocking/multipart.rs b/src/blocking/multipart.rs index b3f6cbe3d..4ad56299b 100644 --- a/src/blocking/multipart.rs +++ b/src/blocking/multipart.rs @@ -79,6 +79,17 @@ impl Form { self.inner.boundary() } + /// Set the boundary that this form will use. By default the boundary is a + /// long random string to minimize the risk of the boundary appearing in + /// the body content. + /// + /// **Setting a custom boundary incurs significant risk of generating + /// corrupted bodies.** Only use this if you need it and you understand the + /// risk! + pub fn set_boundary(&mut self, boundary: impl Into) { + self.inner.boundary = boundary.into(); + } + /// Add a data field with supplied name and value. /// /// # Examples