$ show quic-go/webtransport-go
webtransport-go is a Go library implementing the WebTransport protocol over HTTP/3, based on quic-go. It provides both client and server functionality to establish WebTransport sessions over QUIC connections, supporting bidirectional and unidirectional streams, datagrams, and session flow control. The library follows draft-ietf-webtrans-http3-16 and includes mechanisms for capsule-based control messages, stream error mapping, and origin checking. It is used in production by projects like Centrifugo, go-libp2p, and MediaMTX. The architecture is modular, with separate components for session management, stream maps, flow control, and capsule parsing. The server integrates with http3.Server via ConfigureHTTP3Server and provides an Upgrade method on HTTP handlers. The client offers both one-shot Dial and multi-session NewClientConn. The codebase emphasizes correctness with extensive unit and integration tests, including tests for reordering, flow control, and error handling. Key design decisions include the use of goroutines for concurrent stream acceptance and capsule processing, channel-based notification for flow control updates, and careful handling of session close to ensure streams are properly terminated. The implementation handles edge cases like stream reordering before session establishment, deadline propagation, and graceful shutdown with configurable timeouts. The repository is well-maintained with active CI, linting, and dependency management. It demonstrates strong Go engineering practices with clean interfaces, proper error handling, and comprehensive test coverage.
The LLM identified 2 files worth highlighting for reuse:
Implements a generic data flow controller for outgoing and incoming data. The outgoing controller tracks sent bytes against a limit, provides a method to check if newly blocked, and allows updating the limit via a channel. The incoming controller tracks received bytes and queues window update capsules when the receive window drops below a threshold. This pattern is reusable for any protocol requiring per-connection or per-stream data flow control.
Implements parsing and serialization of WebTransport capsules sent on the CONNECT stream. It defines capsule types, handles unknown capsules by skipping them, and includes UTF-8 safe message truncation for close session capsules. The code demonstrates a clean pattern for extensible capsule parsing that could be adapted for other HTTP/3 capsule-based protocols.