pub struct Multipart<'n, 'd> { /* private fields */ }
Expand description
A multipart request which writes all fields at once upon being provided an output stream.
Sacrifices static dispatch for support for dynamic construction. Reusable.
§Lifetimes
'n
: Lifetime for field names; will only escape this struct inLazyIoError<'n>
.'d
: Lifetime for data: will only escape this struct inPreparedFields<'d>
.
Implementations§
Source§impl<'n, 'd> Multipart<'n, 'd>
impl<'n, 'd> Multipart<'n, 'd>
Sourcepub fn client_request<U: IntoUrl>(
&mut self,
client: &Client,
url: U,
) -> HyperResult<Response>
pub fn client_request<U: IntoUrl>( &mut self, client: &Client, url: U, ) -> HyperResult<Response>
§Feature: hyper
Complete a POST request with the given hyper::client::Client
and URL.
Supplies the fields in the body, optionally setting the content-length header if applicable (all added fields were text or files, i.e. no streams).
Sourcepub fn client_request_mut<U: IntoUrl, F: FnOnce(RequestBuilder<'_>) -> RequestBuilder<'_>>(
&mut self,
client: &Client,
url: U,
mut_fn: F,
) -> HyperResult<Response>
pub fn client_request_mut<U: IntoUrl, F: FnOnce(RequestBuilder<'_>) -> RequestBuilder<'_>>( &mut self, client: &Client, url: U, mut_fn: F, ) -> HyperResult<Response>
§Feature: hyper
Complete a POST request with the given hyper::client::Client
and URL;
allows mutating the hyper::client::RequestBuilder
via the passed closure.
Note that the body, and the ContentType
and ContentLength
headers will be
overwritten, either by this method or by Hyper.
Source§impl<'n, 'd> Multipart<'n, 'd>
impl<'n, 'd> Multipart<'n, 'd>
Sourcepub fn add_text<N, T>(&mut self, name: N, text: T) -> &mut Self
pub fn add_text<N, T>(&mut self, name: N, text: T) -> &mut Self
Add a text field to this request.
Sourcepub fn add_stream<N, R, F>(
&mut self,
name: N,
stream: R,
filename: Option<F>,
mime: Option<Mime>,
) -> &mut Self
pub fn add_stream<N, R, F>( &mut self, name: N, stream: R, filename: Option<F>, mime: Option<Mime>, ) -> &mut Self
Add a generic stream field to this request,
Sourcepub fn send<R: HttpRequest>(
&mut self,
req: R,
) -> Result<<R::Stream as HttpStream>::Response, LazyError<'n, <R::Stream as HttpStream>::Error>>
pub fn send<R: HttpRequest>( &mut self, req: R, ) -> Result<<R::Stream as HttpStream>::Response, LazyError<'n, <R::Stream as HttpStream>::Error>>
Convert req
to HttpStream
, write out the fields in this request, and finish the
request, returning the response if successful, or the first error encountered.
If any files were added by path they will now be opened for reading.
Sourcepub fn prepare(&mut self) -> LazyIoResult<'n, PreparedFields<'d>>
pub fn prepare(&mut self) -> LazyIoResult<'n, PreparedFields<'d>>
Export the multipart data contained in this lazy request as an adaptor which implements Read
.
During this step, if any files were added by path then they will be opened for reading and their length measured.