Struct actix_web::client::ClientRequestBuilder [−][src]
pub struct ClientRequestBuilder { /* fields omitted */ }
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
ⓘImportant traits for &'a mut Rpub 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.
ⓘImportant traits for &'a mut Rpub 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.
ⓘImportant traits for &'a mut Rpub 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
ⓘImportant traits for &'a mut Rpub 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(); }
ⓘImportant traits for &'a mut Rpub 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.
ⓘImportant traits for &'a mut Rpub 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.
ⓘImportant traits for &'a mut Rpub 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.
ⓘImportant traits for &'a mut Rpub fn chunked(&mut self) -> &mut Self
[src]
pub fn chunked(&mut self) -> &mut Self
Enables automatic chunked transfer encoding
ⓘImportant traits for &'a mut Rpub fn upgrade(&mut self) -> &mut Self
[src]
pub fn upgrade(&mut self) -> &mut Self
Enable connection upgrade
ⓘImportant traits for &'a mut Rpub 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
ⓘImportant traits for &'a mut Rpub fn content_length(&mut self, len: u64) -> &mut Self
[src]
pub fn content_length(&mut self, len: u64) -> &mut Self
Set content length
ⓘImportant traits for &'a mut R
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(); }
ⓘImportant traits for &'a mut Rpub 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.
ⓘImportant traits for &'a mut Rpub fn disable_decompress(&mut self) -> &mut Self
[src]
pub fn disable_decompress(&mut self) -> &mut Self
Disable automatic decompress response body
ⓘImportant traits for &'a mut Rpub 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
ⓘImportant traits for &'a mut Rpub 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.
ⓘImportant traits for &'a mut Rpub 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
ⓘImportant traits for &'a mut Rpub 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
ⓘImportant traits for &'a mut Rpub 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
.
ⓘImportant traits for &'a mut Rpub 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 Debug for ClientRequestBuilder
[src]
impl Debug for ClientRequestBuilder
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
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.
Auto Trait Implementations
impl !Send for ClientRequestBuilder
impl !Send for ClientRequestBuilder
impl !Sync for ClientRequestBuilder
impl !Sync for ClientRequestBuilder