summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/app.go
diff options
context:
space:
mode:
authorMatt Holt <mholt@users.noreply.github.com>2020-05-05 12:33:21 -0600
committerGitHub <noreply@github.com>2020-05-05 12:33:21 -0600
commit41c7bd27b495ab9b5edca7afb0cf99d5e1b52944 (patch)
treed282b0e87ff626a417a3314f83744037ff211aba /modules/caddyhttp/app.go
parent96d6d277a453a602b9ec49131d8e332ce7aefcad (diff)
httpserver: Add experimental H2C support (#3289)
* reverse_proxy: Initial attempt at H2C transport/client support (#3218) I have not tested this yet * Experimentally enabling H2C server support (closes #3227) See also #3218 I have not tested this * reverseproxy: Clean up H2C transport a bit * caddyhttp: Update godoc for h2c server; clarify experimental status * caddyhttp: Fix trailers when recording responses (fixes #3236) * caddyhttp: Tweak h2c config settings and docs
Diffstat (limited to 'modules/caddyhttp/app.go')
-rw-r--r--modules/caddyhttp/app.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/caddyhttp/app.go b/modules/caddyhttp/app.go
index 8e7f3ea..f695276 100644
--- a/modules/caddyhttp/app.go
+++ b/modules/caddyhttp/app.go
@@ -27,6 +27,8 @@ import (
"github.com/caddyserver/caddy/v2/modules/caddytls"
"github.com/lucas-clemente/quic-go/http3"
"go.uber.org/zap"
+ "golang.org/x/net/http2"
+ "golang.org/x/net/http2/h2c"
)
func init() {
@@ -282,6 +284,14 @@ func (app *App) Start() error {
Handler: srv,
}
+ // enable h2c if configured
+ if srv.AllowH2C {
+ h2server := &http2.Server{
+ IdleTimeout: time.Duration(srv.IdleTimeout),
+ }
+ s.Handler = h2c.NewHandler(srv, h2server)
+ }
+
for _, lnAddr := range srv.Listen {
listenAddr, err := caddy.ParseNetworkAddress(lnAddr)
if err != nil {