pub struct Request { /* private fields */ }Expand description
A runtime-neutral HTTP request.
Implementations§
Source§impl Request
impl Request
pub fn new(method: HttpMethod, target: impl Into<String>) -> Self
pub fn get(target: impl Into<String>) -> Self
pub fn head(target: impl Into<String>) -> Self
pub fn post(target: impl Into<String>) -> Self
pub fn put(target: impl Into<String>) -> Self
pub fn patch(target: impl Into<String>) -> Self
pub fn delete(target: impl Into<String>) -> Self
pub fn options(target: impl Into<String>) -> Self
pub fn trace(target: impl Into<String>) -> Self
pub fn connect(target: impl Into<String>) -> Self
pub const fn method(&self) -> HttpMethod
pub fn target(&self) -> &str
pub fn path(&self) -> &str
pub fn header(self, name: impl AsRef<str>, value: impl Into<String>) -> Self
pub fn body(self, body: impl Into<Vec<u8>>) -> Self
Sourcepub const fn peer_addr(self, peer_addr: SocketAddr) -> Self
pub const fn peer_addr(self, peer_addr: SocketAddr) -> Self
Sets the direct peer address for in-memory adapter tests.
Sourcepub fn scheme(self, scheme: impl Into<String>) -> Self
pub fn scheme(self, scheme: impl Into<String>) -> Self
Sets the original transport scheme for in-memory adapter tests.
Sourcepub fn json(self, value: &impl Serialize) -> Result<Self, Error>
pub fn json(self, value: &impl Serialize) -> Result<Self, Error>
Serializes a JSON body and sets its media type.
§Errors
Returns the serialization error if value cannot be encoded as JSON.
pub fn get_header(&self, name: &str) -> Option<&str>
pub fn headers(&self) -> &BTreeMap<String, String>
pub fn body_bytes(&self) -> &[u8] ⓘ
Trait Implementations§
impl Eq for Request
Source§impl HttpRequestView for Request
impl HttpRequestView for Request
fn method(&self) -> HttpMethod
fn target(&self) -> &str
fn header_value(&self, name: &str, index: usize) -> Option<&str>
fn body(&self) -> &[u8] ⓘ
Source§fn peer_addr(&self) -> Option<SocketAddr>
fn peer_addr(&self) -> Option<SocketAddr>
Address of the direct network peer, when known by the adapter.
Source§fn take_body_stream(&self) -> Option<StreamingBody>
fn take_body_stream(&self) -> Option<StreamingBody>
Transfers a pull-based request body to the operation, when supported.
impl StructuralPartialEq for Request
Auto Trait Implementations§
impl Freeze for Request
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnsafeUnpin for Request
impl UnwindSafe for Request
Blanket Implementations§
Source§impl<T> BackgroundExt for T
impl<T> BackgroundExt for T
fn background(self, task: BackgroundTask) -> Background<Self>
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