[−][src]Struct actix_web::client::ClientRequestBuilder
An HTTP Client request builder
This type can be used to construct an instance of ClientRequest
through a
builder-like pattern.
Methods
impl ClientRequestBuilder
[src]
impl ClientRequestBuilder
pub fn uri<U: AsRef<str>>(&mut self, uri: U) -> &mut Self
[src]
pub fn uri<U: AsRef<str>>(&mut self, uri: U) -> &mut Self
Set HTTP URI of request.
pub fn method(&mut self, method: Method) -> &mut Self
[src]
pub fn method(&mut self, method: Method) -> &mut Self
Set HTTP method of this request.
pub fn get_method(&mut self) -> &Method
[src]
pub fn get_method(&mut self) -> &Method
Set HTTP method of this request.
pub fn version(&mut self, version: Version) -> &mut Self
[src]
pub fn version(&mut self, version: Version) -> &mut Self
Set HTTP version of this request.
By default requests's HTTP version depends on network stream
pub fn header<K, V>(&mut self, key: K, value: V) -> &mut Self where
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
[src]
pub fn header<K, V>(&mut self, key: K, value: V) -> &mut Self where
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
Append a header.
Header gets appended to existing header.
To override header use set_header()
method.
use http::header; fn main() { let req = ClientRequest::build() .header("X-TEST", "value") .header(header::CONTENT_TYPE, "application/json") .finish() .unwrap(); }
pub fn set_header<K, V>(&mut self, key: K, value: V) -> &mut Self where
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
[src]
pub fn set_header<K, V>(&mut self, key: K, value: V) -> &mut Self where
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
Set a header.
pub fn set_header_if_none<K, V>(&mut self, key: K, value: V) -> &mut Self where
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
[src]
pub fn set_header_if_none<K, V>(&mut self, key: K, value: V) -> &mut Self where
HeaderName: HttpTryFrom<K>,
V: IntoHeaderValue,
Set a header only if it is not yet set.
pub fn content_encoding(&mut self, enc: ContentEncoding) -> &mut Self
[src]
pub fn content_encoding(&mut self, enc: ContentEncoding) -> &mut Self
Set content encoding.
By default ContentEncoding::Identity
is used.
pub fn chunked(&mut self) -> &mut Self
[src]
pub fn chunked(&mut self) -> &mut Self
Enables automatic chunked transfer encoding
pub fn upgrade(&mut self) -> &mut Self
[src]
pub fn upgrade(&mut self) -> &mut Self
Enable connection upgrade
pub fn content_type<V>(&mut self, value: V) -> &mut Self where
HeaderValue: HttpTryFrom<V>,
[src]
pub fn content_type<V>(&mut self, value: V) -> &mut Self where
HeaderValue: HttpTryFrom<V>,
Set request's content type
pub fn content_length(&mut self, len: u64) -> &mut Self
[src]
pub fn content_length(&mut self, len: u64) -> &mut Self
Set content length
Set a cookie
use actix_web::{client, http}; fn main() { let req = client::ClientRequest::build() .cookie( http::Cookie::build("name", "value") .domain("www.rust-lang.org") .path("/") .secure(true) .http_only(true) .finish(), ) .finish() .unwrap(); }
pub fn no_default_headers(&mut self) -> &mut Self
[src]
pub fn no_default_headers(&mut self) -> &mut Self
Do not add default request headers.
By default Accept-Encoding
and User-Agent
headers are set.
pub fn disable_decompress(&mut self) -> &mut Self
[src]
pub fn disable_decompress(&mut self) -> &mut Self
Disable automatic decompress response body
pub fn write_buffer_capacity(&mut self, cap: usize) -> &mut Self
[src]
pub fn write_buffer_capacity(&mut self, cap: usize) -> &mut Self
Set write buffer capacity
Default buffer capacity is 32kb
pub fn timeout(&mut self, timeout: Duration) -> &mut Self
[src]
pub fn timeout(&mut self, timeout: Duration) -> &mut Self
Set request timeout
Request timeout is a total time before response should be received. Default value is 5 seconds.
pub fn with_connector(&mut self, conn: Addr<ClientConnector>) -> &mut Self
[src]
pub fn with_connector(&mut self, conn: Addr<ClientConnector>) -> &mut Self
Send request using custom connector
pub fn with_connection(&mut self, conn: Connection) -> &mut Self
[src]
pub fn with_connection(&mut self, conn: Connection) -> &mut Self
Send request using existing Connection
pub fn if_true<F>(&mut self, value: bool, f: F) -> &mut Self where
F: FnOnce(&mut ClientRequestBuilder),
[src]
pub fn if_true<F>(&mut self, value: bool, f: F) -> &mut Self where
F: FnOnce(&mut ClientRequestBuilder),
This method calls provided closure with builder reference if
value is true
.
pub fn if_some<T, F>(&mut self, value: Option<T>, f: F) -> &mut Self where
F: FnOnce(T, &mut ClientRequestBuilder),
[src]
pub fn if_some<T, F>(&mut self, value: Option<T>, f: F) -> &mut Self where
F: FnOnce(T, &mut ClientRequestBuilder),
This method calls provided closure with builder reference if
value is Some
.
pub fn body<B: Into<Body>>(&mut self, body: B) -> Result<ClientRequest, Error>
[src]
pub fn body<B: Into<Body>>(&mut self, body: B) -> Result<ClientRequest, Error>
Set a body and generate ClientRequest
.
ClientRequestBuilder
can not be used after this call.
pub fn json<T: Serialize>(&mut self, value: T) -> Result<ClientRequest, Error>
[src]
pub fn json<T: Serialize>(&mut self, value: T) -> Result<ClientRequest, Error>
Set a JSON body and generate ClientRequest
ClientRequestBuilder
can not be used after this call.
pub fn form<T: Serialize>(&mut self, value: T) -> Result<ClientRequest, Error>
[src]
pub fn form<T: Serialize>(&mut self, value: T) -> Result<ClientRequest, Error>
Set a urlencoded body and generate ClientRequest
ClientRequestBuilder
can not be used after this call.
pub fn streaming<S, E>(&mut self, stream: S) -> Result<ClientRequest, Error> where
S: Stream<Item = Bytes, Error = E> + 'static,
E: Into<Error>,
[src]
pub fn streaming<S, E>(&mut self, stream: S) -> Result<ClientRequest, Error> where
S: Stream<Item = Bytes, Error = E> + 'static,
E: Into<Error>,
Set a streaming body and generate ClientRequest
.
ClientRequestBuilder
can not be used after this call.
pub fn finish(&mut self) -> Result<ClientRequest, Error>
[src]
pub fn finish(&mut self) -> Result<ClientRequest, Error>
Set an empty body and generate ClientRequest
ClientRequestBuilder
can not be used after this call.
pub fn take(&mut self) -> ClientRequestBuilder
[src]
pub fn take(&mut self) -> ClientRequestBuilder
This method construct new ClientRequestBuilder
Trait Implementations
impl<'a, S: 'static> From<&'a HttpRequest<S>> for ClientRequestBuilder
[src]
impl<'a, S: 'static> From<&'a HttpRequest<S>> for ClientRequestBuilder
Create ClientRequestBuilder
from HttpRequest
It is useful for proxy requests. This implementation copies all request headers and the method.
fn from(req: &'a HttpRequest<S>) -> ClientRequestBuilder
[src]
fn from(req: &'a HttpRequest<S>) -> ClientRequestBuilder
Performs the conversion.
impl Debug for ClientRequestBuilder
[src]
impl Debug for ClientRequestBuilder
Auto Trait Implementations
impl !Send for ClientRequestBuilder
impl !Send for ClientRequestBuilder
impl !Sync for ClientRequestBuilder
impl !Sync for ClientRequestBuilder
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> Erased for T
impl<T> Erased for T