mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2026-07-02 17:37:37 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3dac55cb19 | |||
| bbb2c6d127 |
@@ -19,6 +19,10 @@ type Config struct {
|
|||||||
// GZIP compression support
|
// GZIP compression support
|
||||||
GZIP bool
|
GZIP bool
|
||||||
|
|
||||||
|
// HTTP2 enables HTTP/2 with the Extended CONNECT protocol (RFC 8441) for WebSocket support.
|
||||||
|
// Requires TLS; pair with SSLCert/SSLKey, SelfSignedSSL, or AutoTLS.
|
||||||
|
HTTP2 bool
|
||||||
|
|
||||||
// TLS/HTTPS configuration options (mutually exclusive)
|
// TLS/HTTPS configuration options (mutually exclusive)
|
||||||
// Option 1: Provide certificate and key files directly
|
// Option 1: Provide certificate and key files directly
|
||||||
SSLCert string
|
SSLCert string
|
||||||
|
|||||||
+27
-3
@@ -8,6 +8,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"syscall"
|
"syscall"
|
||||||
@@ -461,15 +462,38 @@ func newInstance(cfg Config) (*serverInstance, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create gracefulServer
|
// Create gracefulServer
|
||||||
gracefulSrv := &gracefulServer{
|
httpServer := &http.Server{
|
||||||
server: &http.Server{
|
|
||||||
Addr: addr,
|
Addr: addr,
|
||||||
Handler: handler,
|
Handler: handler,
|
||||||
ReadTimeout: cfg.ReadTimeout,
|
ReadTimeout: cfg.ReadTimeout,
|
||||||
WriteTimeout: cfg.WriteTimeout,
|
WriteTimeout: cfg.WriteTimeout,
|
||||||
IdleTimeout: cfg.IdleTimeout,
|
IdleTimeout: cfg.IdleTimeout,
|
||||||
TLSConfig: tlsConfig,
|
TLSConfig: tlsConfig,
|
||||||
},
|
}
|
||||||
|
|
||||||
|
// Enable HTTP/2 with Extended CONNECT (RFC 8441) for WebSocket-over-H2 support.
|
||||||
|
// The GODEBUG=http2xconnect=1 flag is read by net/http's init(); setting it here
|
||||||
|
// ensures it propagates to subprocesses and any future process restarts.
|
||||||
|
// For the current process, set GODEBUG=http2xconnect=1 in the environment before launch.
|
||||||
|
if cfg.HTTP2 {
|
||||||
|
if existing := os.Getenv("GODEBUG"); !strings.Contains(existing, "http2xconnect=1") {
|
||||||
|
if existing == "" {
|
||||||
|
os.Setenv("GODEBUG", "http2xconnect=1")
|
||||||
|
} else {
|
||||||
|
os.Setenv("GODEBUG", existing+",http2xconnect=1")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if httpServer.HTTP2 == nil {
|
||||||
|
httpServer.HTTP2 = &http.HTTP2Config{}
|
||||||
|
}
|
||||||
|
httpServer.Protocols.SetHTTP2(true)
|
||||||
|
httpServer.Protocols.SetUnencryptedHTTP2(true)
|
||||||
|
} else {
|
||||||
|
httpServer.Protocols.SetHTTP2(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
gracefulSrv := &gracefulServer{
|
||||||
|
server: httpServer,
|
||||||
shutdownTimeout: cfg.ShutdownTimeout,
|
shutdownTimeout: cfg.ShutdownTimeout,
|
||||||
drainTimeout: cfg.DrainTimeout,
|
drainTimeout: cfg.DrainTimeout,
|
||||||
shutdownComplete: make(chan struct{}),
|
shutdownComplete: make(chan struct{}),
|
||||||
|
|||||||
Reference in New Issue
Block a user