Skip to content

feat: HTTP/1.1 persistent connections (keep-alive)#53

Merged
mgrossmann merged 2 commits intomainfrom
issue-52-keepalive
Apr 9, 2026
Merged

feat: HTTP/1.1 persistent connections (keep-alive)#53
mgrossmann merged 2 commits intomainfrom
issue-52-keepalive

Conversation

@mgrossmann
Copy link
Copy Markdown
Contributor

@mgrossmann mgrossmann commented Apr 9, 2026

Summary

  • Implements HTTP/1.1 persistent connections — reduces TCP handshakes for multi-resource page loads
  • HTTP/1.1 clients default to keep-alive, HTTP/1.0 clients default to close
  • Configurable via Parmlib: KEEPALIVE_TIMEOUT=5, KEEPALIVE_MAX=100
  • Worker pool exhaustion mitigated by short idle timeout and request limit
  • CGI modules (mvsMF) are unaffected

Changed files

File Change
include/httpd.h New HTTPC fields: keepalive, request_count. New HTTPD config: cfg_keepalive_timeout, cfg_keepalive_max
include/httpcgi.h Mirror HTTPC layout changes
src/httpin.c Determine keepalive from version + Connection header, enforce max requests, close (not reset) on idle timeout
src/httpresp.c Send Connection: keep-alive or Connection: close based on flag
src/httprese.c If keepalive: increment request_count, reset per-request state, transition to CSTATE_IN
src/httpgets.c Use cfg_keepalive_timeout for idle wait between keep-alive requests
src/httpprm.c Defaults (5s/100), Parmlib parser for KEEPALIVE_TIMEOUT/KEEPALIVE_MAX, startup log
samplib/httpprm0 Add KEEPALIVE_TIMEOUT and KEEPALIVE_MAX to sample config

Test results

  • Browser DevTools: connection reuse (single TCP for HTML+CSS+JS+images)
  • curl -v --http1.1 multiple requests → Connection: keep-alive header
  • curl -v --http1.0Connection: close, no keep-alive
  • Connection closes after KEEPALIVE_TIMEOUT idle (default 5s)
  • Connection closes after KEEPALIVE_MAX requests (default 100)
  • mvsMF JSON endpoints work identically
  • Zowe CLI — no regressions
  • 9+ concurrent connections don't deadlock worker pool

Fixes #52

- 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
@mgrossmann mgrossmann merged commit ed17d05 into main Apr 9, 2026
1 check failed
@mgrossmann mgrossmann deleted the issue-52-keepalive branch April 9, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Phase 4: Persistent Connections (Keep-Alive)

1 participant