Skip to content

Commit

Permalink
adjust expectations to deal with reqwest Content-Length
Browse files Browse the repository at this point in the history
In short, reqwest sends a `content-length: 0` header in GET
requests for a reason maybe related to this issue:

seanmonstar/reqwest#1971

For now, let's ignore Content-Length header lines.
  • Loading branch information
Byron committed Mar 21, 2024
1 parent 369cf1b commit 3b8f39d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gix-transport/tests/client/blocking_io/http/mod.rs
Expand Up @@ -160,6 +160,7 @@ fn http_authentication_error_can_be_differentiated_and_identity_is_transmitted()
.received_as_string()
.lines()
.map(str::to_lowercase)
.filter(ignore_reqwest_content_length)
.collect::<HashSet<_>>(),
format!(
"GET /path/not-important/info/refs?service=git-upload-pack HTTP/1.1
Expand Down Expand Up @@ -187,6 +188,7 @@ Authorization: Basic dXNlcjpwYXNzd29yZA==
.lines()
.map(str::to_lowercase)
.filter(|l| !l.starts_with("expect: "))
.filter(ignore_reqwest_content_length)
.collect::<HashSet<_>>();
// On linux on CI, for some reason, it won't have this chunk id here, but
// it has it whenever and where-ever I run it.
Expand Down Expand Up @@ -337,6 +339,7 @@ fn handshake_v1() -> crate::Result {
.received_as_string()
.lines()
.map(str::to_lowercase)
.filter(ignore_reqwest_content_length)
.collect::<HashSet<_>>(),
format!(
"GET /path/not/important/due/to/mock/info/refs?service=git-upload-pack HTTP/1.1
Expand Down Expand Up @@ -550,6 +553,7 @@ fn handshake_and_lsrefs_and_fetch_v2_impl(handshake_fixture: &str) -> crate::Res
.received_as_string()
.lines()
.map(str::to_lowercase)
.filter(ignore_reqwest_content_length)
.collect::<HashSet<_>>(),
format!(
"GET /path/not/important/due/to/mock/info/refs?service=git-upload-pack HTTP/1.1
Expand Down Expand Up @@ -680,3 +684,7 @@ fn check_content_type_is_case_insensitive() -> crate::Result {
assert!(result.is_ok());
Ok(())
}

fn ignore_reqwest_content_length(header_line: &String) -> bool {
header_line != "content-length: 0"
}

0 comments on commit 3b8f39d

Please sign in to comment.