Skip to main content

Module conn_diagnostics

Module conn_diagnostics 

Source
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 + Connection header + selected hop-by-hop headers, then the response’s Connection header (which is what determines whether hyper will FIN the socket).
is_conn_log_enabled
Is the connection-diagnostics log enabled? Reads MOCKFORGE_HTTP_LOG_CONN once per call (cheap — env::var is a hash lookup; we don’t bother caching).