Skip to content

veb: support reusable takeover connections#27050

Merged
medvednikov merged 1 commit into
vlang:masterfrom
guweigang:codex/veb-reusable-takeover
May 2, 2026
Merged

veb: support reusable takeover connections#27050
medvednikov merged 1 commit into
vlang:masterfrom
guweigang:codex/veb-reusable-takeover

Conversation

@guweigang

Copy link
Copy Markdown
Contributor

Summary

This adds a reusable takeover mode for veb/fasthttp connections.

  • replace the boolean takeover state with explicit takeover modes in veb and fasthttp
  • add Context.takeover_conn_reusable() for handlers that write one complete response themselves and then return the connection to the server read loop
  • teach the fasthttp Linux and BSD backends to keep reusable takeover connections alive, while still honoring shutdown and Connection: close
  • add fasthttp and veb tests covering reusable takeover on a persistent TCP connection

Motivation

Context.takeover_conn() is useful for SSE and WebSocket-style flows where the handler fully owns the socket. Some streaming handlers write exactly one complete HTTP response, including a clear body boundary, and then want the server to continue serving later requests on the same connection.

The new reusable takeover mode represents that case directly without forcing the handler to close the connection.

Validation

./v test vlib/fasthttp vlib/veb/tests/persistent_connection_test.v vlib/veb/sse/sse_test.v vlib/veb/tests/veb_test.v
git diff --cached --check

@guweigang
guweigang marked this pull request as ready for review May 2, 2026 01:53
@medvednikov
medvednikov merged commit e632a84 into vlang:master May 2, 2026
38 of 81 checks passed
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.

2 participants