[−][src]Struct lynx::Request
Request
is the main way of performing requests.
Use one of its contructors to create a request and then use the send
method
to send the Request
and get the status, headers and response.
Methods
impl Request
[src]
pub fn new(base_url: &str, method: Method) -> Request
[src]
Create a new Request
with the base URL and the given method.
pub fn get(base_url: &str) -> Request
[src]
Create a new Request
with the GET method.
pub fn post(base_url: &str) -> Request
[src]
Create a new Request
with the POST method.
pub fn put(base_url: &str) -> Request
[src]
Create a new Request
with the PUT method.
pub fn delete(base_url: &str) -> Request
[src]
Create a new Request
with the DELETE method.
pub fn head(base_url: &str) -> Request
[src]
Create a new Request
with the HEAD method.
pub fn options(base_url: &str) -> Request
[src]
Create a new Request
with the OPTIONS method.
pub fn patch(base_url: &str) -> Request
[src]
Create a new Request
with the PATCH method.
pub fn trace(base_url: &str) -> Request
[src]
Create a new Request
with the TRACE method.
pub fn param<V>(&mut self, key: &str, value: V) where
V: Display,
[src]
V: Display,
Associate a query string parameter to the given value.
The same key can be used multiple times.
pub fn header<H, V>(&mut self, header: H, value: V) -> HttpResult where
H: IntoHeaderName,
V: HttpTryInto<HeaderValue>,
[src]
H: IntoHeaderName,
V: HttpTryInto<HeaderValue>,
Modify a header for this Request
.
If the header is already present, the value will be replaced. If you wish to append a new header,
use header_append
.
pub fn header_append<H, V>(&mut self, header: H, value: V) -> HttpResult where
H: IntoHeaderName,
V: HttpTryInto<HeaderValue>,
[src]
H: IntoHeaderName,
V: HttpTryInto<HeaderValue>,
Append a new header to this Request
.
The new header is always appended to the Request
, even if the header already exists.
pub fn body(&mut self, body: impl AsRef<[u8]>)
[src]
Set the body of this request.
The can be a &[u8]
or a str
, anything that's a sequence of bytes.
pub fn follow_redirects(&mut self, follow_redirects: bool)
[src]
Sets if this Request
should follow redirects, 3xx codes.
This value defaults to true.
pub fn default_charset(&mut self, default_charset: Option<Charset>)
[src]
Set the default charset to use while parsing the response of this Request
.
If the response does not say which charset it uses, this charset will be used to decode the request.
This value defaults to None
, in which case ISO-8859-1 is used.
pub fn allow_compression(&mut self, allow_compression: bool)
[src]
Sets if this Request
will announce that it accepts compression.
This value defaults to true. Note that this only lets the browser know that this Request
supports
compression, the server might choose not to compress the content.
pub fn send(self) -> HttpResult<(StatusCode, HeaderMap, ResponseReader)>
[src]
Send this Request
to the server.
This method consumes the object so that it cannot be used after sending the request.
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto 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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,