Files
go-away/utils/http_modern.go
WeebDataHoarder 0ca8e277f9 Patches to bring compatibility to Go 1.22
* Disabled container building
* No TLS Fingerprinting
* HTTP/2 H2C uses golang.org/x/net/http2/h2c
* html DOM walking uses custom function instead of iterator
* Pinned these packages to latest compatible releases:
 * github.com/go-jose/go-jose/v4 v4.0.5
 * golang.org/x/crypto v0.33.0
 * golang.org/x/net v0.37.0
 * golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac
 * golang.org/x/text v0.22.0
 * google.golang.org/genproto/googleapis v0.0.0-20240826202546-f6391c0de4c7
2025-05-04 15:43:36 +02:00

30 lines
496 B
Go

//go:build !go1.22 && !go1.23
package utils
import (
"crypto/tls"
"net/http"
)
func NewServer(handler http.Handler, tlsConfig *tls.Config) *http.Server {
if tlsConfig == nil {
proto := new(http.Protocols)
proto.SetHTTP1(true)
proto.SetUnencryptedHTTP2(true)
h1s := &http.Server{
Handler: handler,
Protocols: proto,
}
return h1s
} else {
server := &http.Server{
TLSConfig: tlsConfig,
Handler: handler,
}
applyTLSFingerprinter(server)
return server
}
}