Expand description
Connection diagnostics middleware.
Logs the HTTP version and Connection header value MockForge sees on every
incoming request — the exact information needed to debug “why does
MockForge close the connection after each response?” scenarios.
Issue #79 — Srikanth’s round-5 reply: his PCAP showed HTTP/1.1 from the
proxy with no Connection header, but MockForge was sending FIN after each
response. The only way to confirm what MockForge actually sees on the wire
is to log the version + headers from hyper’s parsed view of the request.
Enabled by MOCKFORGE_HTTP_LOG_CONN=1 (and convenience aliases
true|yes|on). Off by default — the per-request log line is too noisy for
normal operation.
The emitted log uses INFO level so it surfaces under the default subscriber filter; the env var is the on/off switch.
Functions§
- conn_
diag_ middleware - Middleware: when enabled, log the request’s HTTP version +
Connectionheader + selected hop-by-hop headers, then the response’sConnectionheader (which is what determines whether hyper will FIN the socket). - is_
conn_ log_ enabled - Is the connection-diagnostics log enabled? Reads
MOCKFORGE_HTTP_LOG_CONNonce per call (cheap —env::varis a hash lookup; we don’t bother caching).