1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-09-01 01:16:59 +02:00

response header rework (#1869)

This commit is contained in:
Rob Ede
2021-01-15 02:11:10 +00:00
committed by GitHub
parent 4edeb5ce47
commit b1dd8d28bc
76 changed files with 1568 additions and 1347 deletions

View File

@@ -7,7 +7,7 @@
//! # async fn main() -> Result<(), awc::error::SendRequestError> {
//! let mut client = awc::Client::default();
//! let response = client.get("http://www.rust-lang.org") // <- Create request builder
//! .header("User-Agent", "Actix-web")
//! .insert_header(("User-Agent", "Actix-web"))
//! .send() // <- Send http request
//! .await?;
//!
@@ -134,7 +134,7 @@ use self::connect::{Connect, ConnectorWrapper};
/// let mut client = Client::default();
///
/// let res = client.get("http://www.rust-lang.org") // <- Create request builder
/// .header("User-Agent", "Actix-web")
/// .insert_header(("User-Agent", "Actix-web"))
/// .send() // <- Send http request
/// .await; // <- send request and wait for response
///
@@ -182,8 +182,8 @@ impl Client {
{
let mut req = ClientRequest::new(method, url, self.0.clone());
for (key, value) in self.0.headers.iter() {
req = req.set_header_if_none(key.clone(), value.clone());
for header in self.0.headers.iter() {
req = req.insert_header_if_none(header);
}
req
}
@@ -198,8 +198,8 @@ impl Client {
<Uri as TryFrom<U>>::Error: Into<HttpError>,
{
let mut req = self.request(head.method.clone(), url);
for (key, value) in head.headers.iter() {
req = req.set_header_if_none(key.clone(), value.clone());
for header in head.headers.iter() {
req = req.insert_header_if_none(header);
}
req
}