Skip to content

Commit

Permalink
Fix cached 200 status code handling (#958)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mre committed Feb 22, 2023
1 parent 123742a commit b653a0a
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/builder/Cargo.toml
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion examples/client_pool/Cargo.toml
Expand Up @@ -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"] }
2 changes: 1 addition & 1 deletion examples/collect_links/Cargo.toml
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion examples/extract/Cargo.toml
Expand Up @@ -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"] }
2 changes: 1 addition & 1 deletion examples/simple/Cargo.toml
Expand Up @@ -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"] }
4 changes: 2 additions & 2 deletions lychee-bin/Cargo.toml
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion lychee-bin/tests/cli.rs
Expand Up @@ -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!(
Expand Down
2 changes: 1 addition & 1 deletion lychee-lib/Cargo.toml
Expand Up @@ -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"
Expand Down
7 changes: 3 additions & 4 deletions lychee-lib/src/types/status.rs
Expand Up @@ -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)))
Expand Down

0 comments on commit b653a0a

Please sign in to comment.