pub struct HttpRequestBuilder { /* private fields */ }Expand description
Builder for HttpRequest.
Implementations§
Source§impl HttpRequestBuilder
impl HttpRequestBuilder
Sourcepub fn header(
&mut self,
name: impl Into<String>,
value: impl Into<String>,
) -> &mut Self
pub fn header( &mut self, name: impl Into<String>, value: impl Into<String>, ) -> &mut Self
Appends a header to the request.
Both name and value are accepted as plain strings with no validation.
HttpRequestBuilder constructs protocol-layer values (primarily for tests),
not validated HTTP requests, so arbitrary strings — including deliberately
malformed ones — are allowed.
For validated header setting in app code, use
crate::command::RequestBuilder::header, which panics on invalid values.
Sourcepub fn json(&mut self, body: impl Serialize) -> &mut Self
pub fn json(&mut self, body: impl Serialize) -> &mut Self
Sets the body of the request to the JSON representation of the given value.
§Panics
Panics if the serialization fails.
Sourcepub fn build(&self) -> HttpRequest
pub fn build(&self) -> HttpRequest
Trait Implementations§
Source§impl Clone for HttpRequestBuilder
impl Clone for HttpRequestBuilder
Source§fn clone(&self) -> HttpRequestBuilder
fn clone(&self) -> HttpRequestBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for HttpRequestBuilder
impl RefUnwindSafe for HttpRequestBuilder
impl Send for HttpRequestBuilder
impl Sync for HttpRequestBuilder
impl Unpin for HttpRequestBuilder
impl UnsafeUnpin for HttpRequestBuilder
impl UnwindSafe for HttpRequestBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more