Fix cached 200 status code handling (#958)

* Fix cached 200 status code handling

Assert that code 200 never needs to be explicitly accepted for cached response
to match the behavior of uncached checks

* Bump version to v0.11.1
This commit is contained in:
Matthias Endler 2023-02-23 00:25:53 +01:00 committed by GitHub
parent 123742a8b4
commit b653a0a1ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 15 additions and 16 deletions

4
Cargo.lock generated
View file

@ -1968,7 +1968,7 @@ dependencies = [
[[package]]
name = "lychee"
version = "0.11.0"
version = "0.11.1"
dependencies = [
"anyhow",
"assert_cmd",
@ -2010,7 +2010,7 @@ dependencies = [
[[package]]
name = "lychee-lib"
version = "0.11.0"
version = "0.11.1"
dependencies = [
"async-stream",
"cached",

View file

@ -271,7 +271,7 @@ Options:
-u, --user-agent <USER_AGENT>
User agent
[default: lychee/0.11.0]
[default: lychee/0.11.1]
-i, --insecure
Proceed for server connections considered insecure (invalid TLS)

View file

@ -8,7 +8,7 @@ name = "builder"
path = "builder.rs"
[dependencies]
lychee-lib = { path = "../../lychee-lib", version = "0.11.0" }
lychee-lib = { path = "../../lychee-lib", version = "0.11.1" }
tokio = { version = "1.25.0", features = ["full"] }
regex = "1.7.1"
http = "0.2.9"

View file

@ -10,5 +10,5 @@ path = "client_pool.rs"
[dependencies]
futures = "0.3.26"
tokio-stream = "0.1.12"
lychee-lib = { path = "../../lychee-lib", version = "0.11.0" }
lychee-lib = { path = "../../lychee-lib", version = "0.11.1" }
tokio = { version = "1.25.0", features = ["full"] }

View file

@ -8,7 +8,7 @@ name = "collect_links"
path = "collect_links.rs"
[dependencies]
lychee-lib = { path = "../../lychee-lib", version = "0.11.0" }
lychee-lib = { path = "../../lychee-lib", version = "0.11.1" }
tokio = { version = "1.25.0", features = ["full"] }
regex = "1.7.1"
http = "0.2.9"

View file

@ -8,5 +8,5 @@ name = "extract"
path = "extract.rs"
[dependencies]
lychee-lib = { path = "../../lychee-lib", version = "0.11.0" }
lychee-lib = { path = "../../lychee-lib", version = "0.11.1" }
tokio = { version = "1.25.0", features = ["full"] }

View file

@ -8,5 +8,5 @@ name = "simple"
path = "simple.rs"
[dependencies]
lychee-lib = { path = "../../lychee-lib", version = "0.11.0" }
lychee-lib = { path = "../../lychee-lib", version = "0.11.1" }
tokio = { version = "1.25.0", features = ["full"] }

View file

@ -14,10 +14,10 @@ keywords = [
]
license = "Apache-2.0/MIT"
repository = "https://github.com/lycheeverse/lychee"
version = "0.11.0"
version = "0.11.1"
[dependencies]
lychee-lib = { path = "../lychee-lib", version = "0.11.0", default-features = false }
lychee-lib = { path = "../lychee-lib", version = "0.11.1", default-features = false }
anyhow = "1.0.69"
console = "0.15.5"
const_format = "0.2.30"

View file

@ -844,7 +844,7 @@ mod cli {
test_cmd
.arg("--no-progress")
.arg("--accept")
.arg("200,418,500")
.arg("418,500")
.assert()
.success()
.stdout(contains(format!(

View file

@ -14,7 +14,7 @@ keywords = [
]
license = "Apache-2.0/MIT"
repository = "https://github.com/lycheeverse/lychee"
version = "0.11.0"
version = "0.11.1"
[dependencies]
check-if-email-exists = "0.9.0"

View file

@ -97,10 +97,9 @@ impl Status {
pub fn from_cache_status(s: CacheStatus, accepted: Option<HashSet<u16>>) -> Self {
match s {
CacheStatus::Ok(code) => {
// Not sure if we should change the status based on the
// accepted status codes. If we find out that this is
// counter-intuitive, we can change it.
if accepted.map(|a| a.contains(&code)) == Some(true) {
if matches!(s, CacheStatus::Ok(_))
|| accepted.map(|a| a.contains(&code)) == Some(true)
{
return Self::Cached(CacheStatus::Ok(code));
};
Self::Cached(CacheStatus::Error(Some(code)))