filter: blocklist downloads never reuse a pooled connection, the peer closes it between passes
Gates / frontend (push) Successful in 2m3s
Gates / test (push) Successful in 2m34s
Gates / test-aarch64 (push) Successful in 8m20s
Gates / package (push) Successful in 4m20s
Gates / container (push) Successful in 12s
CI / gates (push) Successful in 30m24s

This commit is contained in:
2026-09-12 15:07:55 +02:00
parent f4562cac26
commit f6fa43a8b4
5 changed files with 94 additions and 10 deletions
+17 -5
View File
@@ -1,9 +1,12 @@
//! Blocklist download over HTTP/1.1.
//!
//! One `Fetcher` wraps a caller-owned `std.http.Client`, which owns the
//! connection pool and the CA bundle, exactly as `upstream/doh_client.zig`
//! does. This file knows nothing about parsing, files or the database: it GETs
//! a URL and streams the bytes into a writer the caller supplies.
//! One `Fetcher` wraps a caller-owned `std.http.Client`, which owns the CA
//! bundle, as `upstream/doh_client.zig` does. Nothing here is pooled: every
//! request asks for `connection: close`, and the caller is expected to give
//! this file a client whose pool holds nothing (`free_size = 0`, set at the
//! one construction site in `app.zig`). This file knows nothing about parsing,
//! files or the database: it GETs a URL and streams the bytes into a writer
//! the caller supplies.
//!
//! The body is never held whole. A blocklist can reach `max_body_bytes`, and
//! the caller writes into a temporary file anyway, so nothing here allocates.
@@ -109,7 +112,16 @@ pub const Fetcher = struct {
const uri = parseUrl(url) catch |err| return self.record(err, .connect, err, null, 0);
var req = self.http.request(.GET, uri, .{
.keep_alive = true,
// Sends `connection: close`, so the peer ends the connection and
// `release` destroys it rather than pooling it (`Client.zig:133`,
// `:1167`). A pass runs once a day: a kept connection is one the
// peer has already closed by the next pass, and `std.http.Client`
// never retries a reused connection that reaches EOF before the
// first head byte — it returns `error.HttpConnectionClosing` and
// the source fails for the day. This flag cannot carry that alone,
// because `request` takes a pooled connection before it reads the
// flag; `app.zig` empties the pool itself.
.keep_alive = false,
.headers = .{
// Identity only: a compressed transfer encoding would need
// `Response.readerDecompressing`, a decompression buffer and a