Trait HttpRequest

Source
pub trait HttpRequest {
    type Stream: HttpStream;
    type Error: From<Error> + Into<<Self::Stream as HttpStream>::Error>;

    // Required methods
    fn apply_headers(
        &mut self,
        boundary: &str,
        content_len: Option<u64>,
    ) -> bool;
    fn open_stream(self) -> Result<Self::Stream, Self::Error>;
}
Expand description

A trait describing an HTTP request that can be used to send multipart data.

Required Associated Types§

Source

type Stream: HttpStream

The HTTP stream type that can be opend by this request, to which the multipart data will be written.

Source

type Error: From<Error> + Into<<Self::Stream as HttpStream>::Error>

The error type for this request. Must be compatible with io::Error as well as Self::HttpStream::Error

Required Methods§

Source

fn apply_headers(&mut self, boundary: &str, content_len: Option<u64>) -> bool

Set the Content-Type header to multipart/form-data and supply the boundary value. If content_len is given, set the Content-Length header to its value.

Return true if any and all sanity checks passed and the stream is ready to be opened, or false otherwise.

Source

fn open_stream(self) -> Result<Self::Stream, Self::Error>

Open the request stream and return it or any error otherwise.

Implementations on Foreign Types§

Source§

impl HttpRequest for ()

Source§

type Stream = Sink

Source§

type Error = Error

Source§

fn apply_headers(&mut self, _: &str, _: Option<u64>) -> bool

Source§

fn open_stream(self) -> Result<Self::Stream, Self::Error>

Source§

impl HttpRequest for Request<Fresh>

§Feature: hyper
Source§

fn apply_headers(&mut self, boundary: &str, content_len: Option<u64>) -> bool

§Panics

If self.method() != Method::Post.

Source§

type Stream = Request<Streaming>

Source§

type Error = Error

Source§

fn open_stream(self) -> Result<Self::Stream, Self::Error>

Implementors§