[−][src]Struct yukikaze::client::request::Builder
Http request builder.
Each method that may cause troubles shall panic.
Methods
impl Builder
[src]
pub fn new(uri: Uri, method: Method) -> Self
[src]
Starts process of creating request.
pub fn extensions(&self) -> &Extensions
[src]
Retrieves reference to http extension map
pub fn extensions_mut(&mut self) -> &mut Extensions
[src]
Retrieves mutable reference to http extension map
pub fn headers(&mut self) -> &mut HeaderMap
[src]
Gets reference to headers.
pub fn if_some<T, F: FnOnce(T, Self) -> Self>(
self,
value: Option<T>,
cb: F
) -> Self
[src]
self,
value: Option<T>,
cb: F
) -> Self
Invokes closure with value
and Self
as arguments, if value
contains something
pub fn set_header<K: IntoHeaderName, V>(self, key: K, value: V) -> Self where
HeaderValue: HttpTryFrom<V>,
[src]
HeaderValue: HttpTryFrom<V>,
Sets new header to request.
If header exists, it replaces it.
Panics
- On attempt to set invalid header value.
pub fn set_header_if_none<K: AsHeaderName, V>(self, key: K, value: V) -> Self where
HeaderValue: HttpTryFrom<V>,
[src]
HeaderValue: HttpTryFrom<V>,
Sets new header to request, only if it wasn't set previously.
Panics
- On attempt to set invalid header value.
pub fn set_etag<E: EtagMode>(self, etag: &EntityTag, _: E) -> Self
[src]
Sets ETag value into corresponding header.
If it is set, then value is appended to existing header as per standard after semicolon.
pub fn set_date<E: DateMode>(self, date: HttpDate, _: E) -> Self
[src]
Sets HttpDate value into corresponding header.
pub fn set_cookie_jar(self, jar: CookieJar) -> Self
[src]
Sets cookie jar to request.
If jar already exists, the cookies from jar are appended.
pub fn add_cookie(self, cookie: Cookie<'static>) -> Self
[src]
Adds cookie.
pub fn content_len(self, len: u64) -> Self
[src]
Sets Content-Length
header.
It replaces previous one, if there was any.
pub fn accept_encoding(self, encoding: ContentEncoding) -> Self
[src]
Sets Accept-Encoding
header.
Replaces previous value, if any.
pub fn content_disposition(self, disp: &ContentDisposition) -> Self
[src]
Sets Content-Disposition
header.
Replaces previous value, if any.
pub fn basic_auth<U: Display, P: Display>(
self,
username: U,
password: Option<P>
) -> Self
[src]
self,
username: U,
password: Option<P>
) -> Self
Adds basic authentication header.
pub fn bearer_auth(self, token: &str) -> Self
[src]
Adds bearer authentication header.
Generally tokens already contain only valid symbols for header. So the function doesn't encode it using base64.
pub fn query<Q: Serialize>(self, query: &Q) -> Self
[src]
Sets request's query by overwriting existing one, if any.
Panics
- If unable to encode data.
- If URI creation fails
pub fn upgrade<U: Upgrade>(self, _: U, options: U::Options) -> Request
[src]
pub fn body<B: Into<Bytes>>(self, body: Option<B>) -> Request
[src]
Creates request with specified body.
Adds Content-Length
if not specified by user.
Following RFC, adds zero length only for PUT
and POST
requests
pub fn form<F: Serialize>(self, body: &F) -> Result<Request, Error>
[src]
Creates request with Form payload.
pub fn json<J: Serialize>(self, body: &J) -> Result<Request>
[src]
Creates request with JSON payload.
pub fn multipart(self, body: Form) -> Request
[src]
Creates request with multipart body.
pub fn empty(self) -> Request
[src]
Creates request with no body.
Explicitly sets Content-Length
to 0, if necessary
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.