pub trait AsSendBody: Private { }Expand description
Trait for common types to send in POST, PUT or PATCH.
Sending common data types such as String, &str or &[u8] require no further wrapping
and can be sent either by RequestBuilder::send() or using the
http crate Request directly (see example below).
Implemented for:
&str&String&Vec<u8>&File&TcpStream&[u8]Response<Body>StringVec<u8>FileStdinTcpStreamUnixStream(not on windows)&[u8; N]()
§Example
These two examples are equivalent.
let data: &[u8] = b"My special request body data";
let response = ureq::post("https://httpbin.org/post")
.send(data)?;Using http crate API
use ureq::http;
let data: &[u8] = b"My special request body data";
let request = http::Request::post("https://httpbin.org/post")
.body(data)?;
let response = ureq::run(request)?;Implementations on Foreign Types§
impl AsSendBody for &str
impl AsSendBody for &String
impl AsSendBody for &Vec<u8>
impl AsSendBody for &File
impl AsSendBody for &TcpStream
impl AsSendBody for &[u8]
impl AsSendBody for ()
impl AsSendBody for String
impl AsSendBody for Vec<u8>
impl AsSendBody for File
impl AsSendBody for Stdin
impl AsSendBody for TcpStream
impl AsSendBody for UnixStream
Available on
target_family=unix only.