Expand description
Connection: keep-alive hint middleware.
Adds explicit Connection: keep-alive and Keep-Alive: timeout=N, max=M
response headers when enabled via the MOCKFORGE_HTTP_KEEPALIVE_HINT
environment variable (or the --http-keepalive-hint CLI flag, when wired).
This is a workaround for proxies that:
- Speak HTTP/1.0 upstream by default (hyper closes the connection after one
response unless the request carried
Connection: keep-alive). - Cache the keep-alive policy from the response headers rather than the
HTTP version. F5/Avi/HAProxy in some configurations look at the
Keep- Aliveresponse header to decide whether to pool the upstream socket.
Issue #79 — Srikanth’s round-3 reply: proxy observed FIN from MockForge after every 200 response, then RST when it reused the socket. Root cause is upstream HTTP/1.1 not being negotiated. We can’t force hyper to keep the connection alive after an HTTP/1.0 request, but we can advertise our preferred policy in the response so proxies that read it adjust.
Functions§
- is_
keepalive_ hint_ enabled - Is the keepalive hint enabled? Reads
MOCKFORGE_HTTP_KEEPALIVE_HINTonce per startup process. Truthy values:1,true,yes,on. - keepalive_
hint_ middleware - Middleware: stamp
Connection: keep-aliveandKeep-Alive: timeout=…, max=…on every response. Does NOT override an upstream-setConnection: closeheader.