Skip to content

Commit 5369c99

Browse files
committed
Auto merge of #12726 - ehuss:fix-token_not_logged, r=arlosi
Fix spurious errors with networking tests. This fixes an issue where some networking tests could behave erratically. In particular, the `registry_auth::token_not_logged` has been failing somewhat often (see #12639). The issue is that curl can behave inconsistently based on whether or not it immediately detects that the connection has closed or not, which is not done consistently. HTTP 1.1 defaults to `Connection: open`, so this mini HTTP server was essentially not standards compliant. `Connection: close` tells curl to expect the connection to close ([ref](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Connection)).
2 parents 25dcec9 + ebea09d commit 5369c99

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

crates/cargo-test-support/src/registry.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ impl HttpServer {
781781
let buf = buf.get_mut();
782782
write!(buf, "HTTP/1.1 {}\r\n", response.code).unwrap();
783783
write!(buf, "Content-Length: {}\r\n", response.body.len()).unwrap();
784+
write!(buf, "Connection: close\r\n").unwrap();
784785
for header in response.headers {
785786
write!(buf, "{}\r\n", header).unwrap();
786787
}

tests/testsuite/publish.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,6 +1965,7 @@ Caused by:
19651965
headers:
19661966
<tab>HTTP/1.1 400
19671967
<tab>Content-Length: 7
1968+
<tab>Connection: close
19681969
<tab>
19691970
body:
19701971
go away

0 commit comments

Comments
 (0)