[−][src]Struct tauri_api::http::HttpRequestBuilder
The builder for HttpRequestOptions.
Examples
let mut builder = HttpRequestBuilder::new("GET", "http://example.com"); let option = builder.response_type(ResponseType::Text) .follow_redirects(false) .build(); if let Ok(response) = make_request(option) { println!("Response: {}", response); } else { println!("Something Happened!"); }
Fields
method: String
The request method (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, CONNECT or TRACE)
url: String
The request URL
params: Option<HashMap<String, String>>
The request query params
headers: Option<HashMap<String, String>>
The request headers
body: Option<Value>
The request body
follow_redirects: Option<bool>
Whether to follow redirects or not
max_redirections: Option<u32>
Max number of redirections to follow
connect_timeout: Option<u64>
Connect timeout for the request
read_timeout: Option<u64>
Read timeout for the request
timeout: Option<u64>
Timeout for the whole request
allow_compression: Option<bool>
Whether the request will announce that it accepts compression
body_type: Option<BodyType>
The body type (defaults to Auto)
response_type: Option<ResponseType>
The response type (defaults to Json)
Implementations
impl HttpRequestBuilder
[src]
pub fn new(method: impl Into<String>, url: impl Into<String>) -> Self
[src]
Initializes a new instance of the HttpRequestBuilder.
pub fn params(self, params: HashMap<String, String>) -> Self
[src]
Sets the request params.
pub fn headers(self, headers: HashMap<String, String>) -> Self
[src]
Sets the request headers.
pub fn body(self, body: Value) -> Self
[src]
Sets the request body.
pub fn follow_redirects(self, follow_redirects: bool) -> Self
[src]
Sets whether the request should follow redirects or not.
pub fn max_redirections(self, max_redirections: u32) -> Self
[src]
Sets the maximum number of redirections.
pub fn connect_timeout(self, connect_timeout: u64) -> Self
[src]
Sets the connection timeout.
pub fn read_timeout(self, read_timeout: u64) -> Self
[src]
Sets the read timeout.
pub fn timeout(self, timeout: u64) -> Self
[src]
Sets the general request timeout.
pub fn allow_compression(self, allow_compression: bool) -> Self
[src]
Sets whether the request allows compressed responses or not.
pub fn body_type(self, body_type: BodyType) -> Self
[src]
Sets the type of the request body.
pub fn response_type(self, response_type: ResponseType) -> Self
[src]
Sets the type of the response. Interferes with the way we read the response.
pub fn build(self) -> HttpRequestOptions
[src]
Builds the HttpRequestOptions.
Auto Trait Implementations
impl RefUnwindSafe for HttpRequestBuilder
impl Send for HttpRequestBuilder
impl Sync for HttpRequestBuilder
impl Unpin for HttpRequestBuilder
impl UnwindSafe for HttpRequestBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> 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.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,