Update reqwest to 0.11

This commit is contained in:
messense 2022-03-30 10:15:35 +08:00
parent 70384a5fbf
commit 548ea65072
No known key found for this signature in database
GPG key ID: BB41A8A2C716CCA9
4 changed files with 254 additions and 443 deletions

656
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -16,7 +16,7 @@ url = "2"
percent-encoding = "2.1"
[dependencies.reqwest]
version = "0.10.1"
version = "0.11.0"
optional = true
features = ["blocking"]
@ -29,4 +29,4 @@ default = ["reqwest", "futures"]
unstable = []
[dev-dependencies]
tokio = "0.2.11"
tokio = "1.17.0"

View file

@ -41,40 +41,47 @@ impl fmt::Display for WarningReason {
match self {
Self::InvalidDirectiveFormat => {
write!(f, "Invalid directive format.")
},
}
Self::DirectiveKeyIsEmpty => {
write!(f, "Directive key is empty.")
},
}
Self::UnsupportedDirectiveKey(key) => {
write!(f, "Directive key `{}` is not suppored by this parser.", key)
},
}
Self::UserAgentCannotBeEmpty => {
write!(f, "Passed directive key is `User-Agent` and passed value is empty.")
},
}
Self::DirectiveWithoutUserAgent => {
write!(f, "It is impossible to process this directive before `User-Agent` directive has not been processed.")
},
write!(
f,
"It is impossible to process this directive before `User-Agent` directive has not been processed."
)
}
Self::ParseCrawlDelayError(err) => {
write!(f, "It is impossible to process the `Crawl-Delay` directive because of an error when parsing a floating point number: {}", err)
},
}
Self::WrongRequestRateFormat => {
write!(f, "Incorrect format of the `Request-Rate` directive")
},
}
Self::ParseRequestRate(err) => {
write!(f, "Incorrect format of the `Request-Rate` directive: {}", err)
},
}
Self::ParseUrl(err) => {
write!(f, "Parsing URL error: {}", err)
},
}
Self::WrongCleanParamFormat => {
write!(f, "Incorrect format of the `Clean-Param` directive.")
},
}
Self::IgnoredCleanParams(ref params) => {
write!(f, "Directive `Clean-Param` directive has incorrect parameters: {:?}", params)
},
write!(
f,
"Directive `Clean-Param` directive has incorrect parameters: {:?}",
params
)
}
Self::WrongPathFormat => {
write!(f, "Error in URL path format.")
},
}
}
}
}

View file

@ -7,7 +7,7 @@ use url::{Host, Origin};
#[test]
fn test_reqwest_async() {
let mut runtime = Runtime::new().unwrap();
let runtime = Runtime::new().unwrap();
let client = Client::new();
let robots_txt_url = Url::parse("https://www.python.org/robots.txt").unwrap();
let robots_txt_response = runtime.block_on(client.fetch_robots_txt(robots_txt_url.origin()).unwrap());