mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-09-11 10:45:42 +03:00
add support for plain h2c
This commit is contained in:
parent
42bd0615c2
commit
95771c7aba
@ -15,6 +15,8 @@ import (
|
||||
"github.com/AdguardTeam/golibs/log"
|
||||
"github.com/AdguardTeam/golibs/netutil"
|
||||
"github.com/NYTimes/gziphandler"
|
||||
"golang.org/x/net/http2"
|
||||
"golang.org/x/net/http2/h2c"
|
||||
)
|
||||
|
||||
// HTTP scheme constants.
|
||||
@ -167,12 +169,15 @@ func (web *Web) Start() {
|
||||
printHTTPAddresses(schemeHTTP)
|
||||
errs := make(chan error, 2)
|
||||
|
||||
// h2s adds support for plain h2c
|
||||
h2s := &http2.Server{}
|
||||
|
||||
hostStr := web.conf.BindHost.String()
|
||||
// we need to have new instance, because after Shutdown() the Server is not usable
|
||||
web.httpServer = &http.Server{
|
||||
ErrorLog: log.StdLog("web: plain", log.DEBUG),
|
||||
Addr: netutil.JoinHostPort(hostStr, web.conf.BindPort),
|
||||
Handler: withMiddlewares(Context.mux, limitRequestBody),
|
||||
Handler: h2c.NewHandler(withMiddlewares(Context.mux, limitRequestBody), h2s),
|
||||
ReadTimeout: web.conf.ReadTimeout,
|
||||
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
|
||||
WriteTimeout: web.conf.WriteTimeout,
|
||||
@ -202,10 +207,13 @@ func (web *Web) startBetaServer(hostStr string) {
|
||||
return
|
||||
}
|
||||
|
||||
// h2s adds support for plain h2c
|
||||
h2s := &http2.Server{}
|
||||
|
||||
web.httpServerBeta = &http.Server{
|
||||
ErrorLog: log.StdLog("web: plain: beta", log.DEBUG),
|
||||
Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort),
|
||||
Handler: withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
|
||||
Handler: h2c.NewHandler(withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta), h2s),
|
||||
ReadTimeout: web.conf.ReadTimeout,
|
||||
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
|
||||
WriteTimeout: web.conf.WriteTimeout,
|
||||
|
Loading…
Reference in New Issue
Block a user