feat: HTTP/1.1 persistent connections (keep-alive)#53
Merged
mgrossmann merged 2 commits intomainfrom Apr 9, 2026
Merged
Conversation
- New HTTPC fields: keepalive (0x53), request_count (0x54) - New HTTPD config: cfg_keepalive_timeout (default 5s), cfg_keepalive_max (default 100 requests) - Parmlib keywords: KEEPALIVE_TIMEOUT, KEEPALIVE_MAX - httpin.c: determine keepalive from request version and Connection header. HTTP/1.1 defaults to keep-alive, HTTP/1.0 defaults to close. Enforce max request limit. Keep-alive idle timeout goes to CSTATE_CLOSE (not RESET). - httpresp.c: send Connection: keep-alive or close based on httpc->keepalive flag - httprese.c: if keepalive, increment request_count, reset per-request state, set start time, transition to CSTATE_IN. Worker loop re-enters http_in for next request on same socket. - httpgets.c: use cfg_keepalive_timeout for idle wait between keep-alive requests (shorter than cfg_client_timeout) CGI modules (mvsMF) are unaffected — keepalive is transparent to the request processing pipeline. Fixes #52
Add the new keep-alive configuration keywords to the sample Parmlib member with their default values (5s timeout, 100 max requests per connection). Ref #52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
KEEPALIVE_TIMEOUT=5,KEEPALIVE_MAX=100Changed files
include/httpd.hkeepalive,request_count. New HTTPD config:cfg_keepalive_timeout,cfg_keepalive_maxinclude/httpcgi.hsrc/httpin.csrc/httpresp.cConnection: keep-aliveorConnection: closebased on flagsrc/httprese.csrc/httpgets.ccfg_keepalive_timeoutfor idle wait between keep-alive requestssrc/httpprm.csamplib/httpprm0Test results
curl -v --http1.1multiple requests →Connection: keep-aliveheadercurl -v --http1.0→Connection: close, no keep-aliveFixes #52