feat: enable H2C for the HTTP server (#8861)
This PR adds HTTP/2 Cleartext (H2C) support for the HTTP server, this allows for reverse proxies to use HTTP/2 instead. ## Test 1. Start Forgejo. 2. Run `curl --http2-prior-knowledge http://localhost:3000`. 3. Observe it doesn't return a error. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8861 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: sim <git@sgougeon.fr> Co-committed-by: sim <git@sgougeon.fr>
This commit is contained in:
parent
f9a6657248
commit
b9bd821fb2
1 changed files with 5 additions and 0 deletions
|
@ -16,6 +16,11 @@ func newHTTPServer(network, address, name string, handler http.Handler) (*Server
|
|||
Handler: handler,
|
||||
BaseContext: func(net.Listener) context.Context { return GetManager().HammerContext() },
|
||||
}
|
||||
// Enable H2C for HTTP server
|
||||
httpServer.Protocols = new(http.Protocols)
|
||||
httpServer.Protocols.SetHTTP1(true)
|
||||
httpServer.Protocols.SetHTTP2(true)
|
||||
httpServer.Protocols.SetUnencryptedHTTP2(true)
|
||||
server.OnShutdown = func() {
|
||||
httpServer.SetKeepAlivesEnabled(false)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue