Struct multipart::client::SizedRequest
[−]
[src]
pub struct SizedRequest<R> { // some fields omitted }
A wrapper around a request object that measures the request body and sets the Content-Length
header to its size in bytes.
Sized requests are more human-readable and use less bandwidth (as chunking adds visual noise and overhead), but they must be able to load their entirety, including the contents of all files and streams, into memory so the request body can be measured.
You should really only use sized requests if you intend to inspect the data manually on the server side, as it will produce a more human-readable request body. Also, of course, if the server doesn't support chunked requests or otherwise rejects them.
Trait Implementations
impl<R> Write for SizedRequest<R>
[src]
fn write(&mut self, data: &[u8]) -> Result<usize>
Write a buffer into this object, returning how many bytes were written. Read more
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0
Attempts to write an entire buffer into this write. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0
Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0
Creates a "by reference" adaptor for this instance of Write
. Read more
impl<R: HttpRequest> HttpRequest for SizedRequest<R> where R::Stream::Error: From<R::Error>
[src]
type Stream = Self
The HTTP stream type that can be opend by this request, to which the multipart data will be written. Read more
type Error = R::Error
The error type for this request. Must be compatible with io::Error
as well as Self::HttpStream::Error
Read more
fn apply_headers(&mut self, boundary: &str, _content_len: Option<u64>) -> bool
SizedRequest
ignores _content_len
because it sets its own later.
fn open_stream(self) -> Result<Self, Self::Error>
Open the request stream and return it or any error otherwise.
impl<R: HttpRequest> HttpStream for SizedRequest<R> where R::Stream::Error: From<R::Error>
[src]
type Request = Self
The request type that opened this stream.
type Response = R::Stream::Response
The response type that will be returned after the request is completed.
type Error = R::Stream::Error
The error type for this stream. Must be compatible with io::Error
as well as Self::Request::Error
. Read more
fn finish(self) -> Result<Self::Response, Self::Error>
Finalize and close the stream and return the response object, or any error otherwise.