perf(http): enable HTTP/1.1 keep-alive
Enable HTTP/1.1 on the WebUI server so browsers can reuse TCP
connections across normal API/static requests. Tighten response framing
by adding Content-Length to short manual responses and marking
SSE/streaming responses as Connection: close, keeping HTTP/1.1 message
boundaries unambiguous.
Verified:
- python3 -m py_compile server.py api/auth.py api/routes.py api/kanban_bridge.py
- pytest tests/test_auth_*.py tests/test_*sse*.py tests/test_pr1350_*.py
tests/test_pr1355_sse_handler_no_deadlock.py tests/test_kanban_bridge.py
tests/test_logs_ui_static.py tests/test_onboarding_static.py
tests/test_regressions.py tests/test_1038_pwa_auth_redirect.py
tests/test_issue1623_sse_heartbeat_alignment.py
→ 239 passed, 1 skipped
This commit is contained in:
@@ -170,6 +170,13 @@ class QuietHTTPServer(ThreadingHTTPServer):
|
||||
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
# HTTP/1.1 enables keep-alive connection reuse — major latency win on
|
||||
# high-RTT links where every saved TCP handshake is 2×RTT. Each response
|
||||
# MUST declare framing (Content-Length, Transfer-Encoding: chunked, or
|
||||
# Connection: close) so the client knows where the message ends. Helpers
|
||||
# j()/t() emit Content-Length; SSE/streaming endpoints emit
|
||||
# Connection: close because the body has no terminator. See PR notes.
|
||||
protocol_version = "HTTP/1.1"
|
||||
timeout = 30 # seconds — kills idle/incomplete connections to prevent thread exhaustion
|
||||
|
||||
def setup(self):
|
||||
|
||||
Reference in New Issue
Block a user