mirror of
https://github.com/danbulant/robotparser-rs
synced 2026-06-24 17:21:45 +00:00
Update reqwest to 0.11
This commit is contained in:
parent
70384a5fbf
commit
548ea65072
4 changed files with 254 additions and 443 deletions
656
Cargo.lock
generated
656
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -16,7 +16,7 @@ url = "2"
|
||||||
percent-encoding = "2.1"
|
percent-encoding = "2.1"
|
||||||
|
|
||||||
[dependencies.reqwest]
|
[dependencies.reqwest]
|
||||||
version = "0.10.1"
|
version = "0.11.0"
|
||||||
optional = true
|
optional = true
|
||||||
features = ["blocking"]
|
features = ["blocking"]
|
||||||
|
|
||||||
|
|
@ -29,4 +29,4 @@ default = ["reqwest", "futures"]
|
||||||
unstable = []
|
unstable = []
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = "0.2.11"
|
tokio = "1.17.0"
|
||||||
|
|
|
||||||
|
|
@ -41,40 +41,47 @@ impl fmt::Display for WarningReason {
|
||||||
match self {
|
match self {
|
||||||
Self::InvalidDirectiveFormat => {
|
Self::InvalidDirectiveFormat => {
|
||||||
write!(f, "Invalid directive format.")
|
write!(f, "Invalid directive format.")
|
||||||
},
|
}
|
||||||
Self::DirectiveKeyIsEmpty => {
|
Self::DirectiveKeyIsEmpty => {
|
||||||
write!(f, "Directive key is empty.")
|
write!(f, "Directive key is empty.")
|
||||||
},
|
}
|
||||||
Self::UnsupportedDirectiveKey(key) => {
|
Self::UnsupportedDirectiveKey(key) => {
|
||||||
write!(f, "Directive key `{}` is not suppored by this parser.", key)
|
write!(f, "Directive key `{}` is not suppored by this parser.", key)
|
||||||
},
|
}
|
||||||
Self::UserAgentCannotBeEmpty => {
|
Self::UserAgentCannotBeEmpty => {
|
||||||
write!(f, "Passed directive key is `User-Agent` and passed value is empty.")
|
write!(f, "Passed directive key is `User-Agent` and passed value is empty.")
|
||||||
},
|
}
|
||||||
Self::DirectiveWithoutUserAgent => {
|
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) => {
|
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)
|
write!(f, "It is impossible to process the `Crawl-Delay` directive because of an error when parsing a floating point number: {}", err)
|
||||||
},
|
}
|
||||||
Self::WrongRequestRateFormat => {
|
Self::WrongRequestRateFormat => {
|
||||||
write!(f, "Incorrect format of the `Request-Rate` directive")
|
write!(f, "Incorrect format of the `Request-Rate` directive")
|
||||||
},
|
}
|
||||||
Self::ParseRequestRate(err) => {
|
Self::ParseRequestRate(err) => {
|
||||||
write!(f, "Incorrect format of the `Request-Rate` directive: {}", err)
|
write!(f, "Incorrect format of the `Request-Rate` directive: {}", err)
|
||||||
},
|
}
|
||||||
Self::ParseUrl(err) => {
|
Self::ParseUrl(err) => {
|
||||||
write!(f, "Parsing URL error: {}", err)
|
write!(f, "Parsing URL error: {}", err)
|
||||||
},
|
}
|
||||||
Self::WrongCleanParamFormat => {
|
Self::WrongCleanParamFormat => {
|
||||||
write!(f, "Incorrect format of the `Clean-Param` directive.")
|
write!(f, "Incorrect format of the `Clean-Param` directive.")
|
||||||
},
|
}
|
||||||
Self::IgnoredCleanParams(ref params) => {
|
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 => {
|
Self::WrongPathFormat => {
|
||||||
write!(f, "Error in URL path format.")
|
write!(f, "Error in URL path format.")
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use url::{Host, Origin};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_reqwest_async() {
|
fn test_reqwest_async() {
|
||||||
let mut runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let client = Client::new();
|
let client = Client::new();
|
||||||
let robots_txt_url = Url::parse("https://www.python.org/robots.txt").unwrap();
|
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());
|
let robots_txt_response = runtime.block_on(client.fetch_robots_txt(robots_txt_url.origin()).unwrap());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue