Skip to content

bitreq::Client only reuses an HTTP/1.1 connection when the response explicitly contains Connection: keep-alive #659

Description

@tnull

let mut found_keep_alive = false;
if let Some(header) = response.headers.get("connection") {
if header.eq_ignore_ascii_case("keep-alive") {
found_keep_alive = true;
}
}
if !found_keep_alive {
conn.permits.store(0, Ordering::Release);
conn.readable_request_id.store(usize::MAX, Ordering::Release);
} else {
conn.readable_request_id.fetch_add(1, Ordering::Release);

HTTP/1.1 connections are persistent by default unless Connection: close is present. Servers such as Caddy therefore omit Connection: keep-alive. bitreq consequently marks a healthy socket unusable and performs a new TCP and TLS handshake for the next request.

Expected behavior:

  • HTTP/1.1 or later: reuse unless Connection: close is present.
  • HTTP/1.0: require explicit Connection: keep-alive.

RFC 9112 §9.3: https://www.rfc-editor.org/rfc/rfc9112.html#section-9.3

Related: #562

Will see to fix as part of #564.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions