caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
58.66k stars 4.05k forks source link

Proposal: export more HTTP/3 related interfaces for caddy plugins to use #6017

Open WeidiDeng opened 11 months ago

WeidiDeng commented 11 months ago

There are several popular projects that utilize many of quic-go's implementation of http3 features that currently can't be used by caddy modules, limiting how caddy can be extended.

For example, ssh3 uses StreamHijacker to handle tcp and udp forwarding using an on-going quic.Connection. It uses http3.Hijacker to establish ssh3 sessions. We should also export a caddyhttp.Unwrap function to extract the underlying http.ResponseWriter in this case.

hysteria, a proxy protocol, uses StreamHijacker as well to handle tcp traffic forwarding. It uses a fork of quic-go which implemented bbr congestion control, but most of the interfaces are the same as the original quic-go.

webtransport-go uses http3.HTTPStreamer to take over the http stream. Currently if we enable logging, request body will be wrapped and we (lose the access)[https://github.com/caddyserver/caddy/blob/master/modules/caddyhttp/server.go#L322] to the underlying io.ReadCloser.

mholt commented 8 months ago

I'm open to this. As long as it would work generally (for example, if wrapped more than once, will Unwrap still work?).