Summary
CGI modules call http_printf() without setting Content-Length or Transfer-Encoding: chunked. With Connection: keep-alive, the browser waits until KEEPALIVE_TIMEOUT (~5s) because it has no way to know when the response body ends.
curl: no chunk, no close, no size. Assume close to signal end
Affected Modules
HTTPDMTT, HTTPDSRV, HTTPDM, HTTPJES2, HTTPDSL, HTTPLUA, HTTPREXX
mvsMF is not affected (sets Content-Length itself via sendDefaultHeaders()).
Root Cause
The chunked fallback is only implemented in httpget.c for static files. CGI modules take a different code path and don't get automatic chunked encoding.
Proposed Fix
The chunked fallback must happen at a central point — not just in httpget.c. When response headers have been sent without Content-Length or Transfer-Encoding, HTTPD must automatically insert Transfer-Encoding: chunked and set httpc->chunked = 1.
Option A: An http_end_headers() function that all code paths (httpget.c, CGI modules) pass through before sending body data. This function checks whether Content-Length or chunked is set, and inserts the chunked header if needed.
Option B: In httpsend.c — when the first data chunk is sent and neither content_length_set nor chunked is set, automatically send the Transfer-Encoding: chunked header and switch to chunked mode.
Important: HTTP/1.0 clients must not receive chunked encoding (as before).
Acceptance Criteria
Summary
CGI modules call
http_printf()without settingContent-LengthorTransfer-Encoding: chunked. WithConnection: keep-alive, the browser waits until KEEPALIVE_TIMEOUT (~5s) because it has no way to know when the response body ends.curl:
no chunk, no close, no size. Assume close to signal endAffected Modules
HTTPDMTT, HTTPDSRV, HTTPDM, HTTPJES2, HTTPDSL, HTTPLUA, HTTPREXX
mvsMF is not affected (sets Content-Length itself via
sendDefaultHeaders()).Root Cause
The chunked fallback is only implemented in
httpget.cfor static files. CGI modules take a different code path and don't get automatic chunked encoding.Proposed Fix
The chunked fallback must happen at a central point — not just in
httpget.c. When response headers have been sent withoutContent-LengthorTransfer-Encoding, HTTPD must automatically insertTransfer-Encoding: chunkedand sethttpc->chunked = 1.Option A: An
http_end_headers()function that all code paths (httpget.c, CGI modules) pass through before sending body data. This function checks whether Content-Length or chunked is set, and inserts the chunked header if needed.Option B: In
httpsend.c— when the first data chunk is sent and neithercontent_length_setnorchunkedis set, automatically send theTransfer-Encoding: chunkedheader and switch to chunked mode.Important: HTTP/1.0 clients must not receive chunked encoding (as before).
Acceptance Criteria
Transfer-Encoding: chunked