summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/reverseproxy
diff options
context:
space:
mode:
authorMarten Seemann <martenseemann@gmail.com>2023-07-21 21:00:48 -0700
committerGitHub <noreply@github.com>2023-07-21 22:00:48 -0600
commitf45a6de20dd19e82e58c85b37e03957b2203b544 (patch)
treecc8152b73fd31c09111dfb0034960a0c20d6ff67 /modules/caddyhttp/reverseproxy
parentb51dc5d5d0b8764165170af1f54b77d6de8cb5a1 (diff)
go.mod: Update quic-go to v0.37.0, bump to Go 1.20 minimum (#5644)
* update quic-go to v0.37.0 * Bump to Go 1.20 * Bump golangci-lint version, yml syntax consistency * Use skip-pkg-cache workaround * Workaround needed for both? * Seeding weakrand is no longer necessary --------- Co-authored-by: Matt Holt <mholt@users.noreply.github.com> Co-authored-by: Francis Lavoie <lavofr@gmail.com>
Diffstat (limited to 'modules/caddyhttp/reverseproxy')
-rw-r--r--modules/caddyhttp/reverseproxy/reverseproxy.go39
-rw-r--r--modules/caddyhttp/reverseproxy/selectionpolicies.go3
2 files changed, 15 insertions, 27 deletions
diff --git a/modules/caddyhttp/reverseproxy/reverseproxy.go b/modules/caddyhttp/reverseproxy/reverseproxy.go
index 2fd0aae..d1c9352 100644
--- a/modules/caddyhttp/reverseproxy/reverseproxy.go
+++ b/modules/caddyhttp/reverseproxy/reverseproxy.go
@@ -27,7 +27,6 @@ import (
"net/netip"
"net/textproto"
"net/url"
- "runtime"
"strconv"
"strings"
"sync"
@@ -43,13 +42,7 @@ import (
"golang.org/x/net/http/httpguts"
)
-var supports1xx bool
-
func init() {
- // Caddy requires at least Go 1.18, but Early Hints requires Go 1.19; thus we can simply check for 1.18 in version string
- // TODO: remove this once our minimum Go version is 1.19
- supports1xx = !strings.Contains(runtime.Version(), "go1.18")
-
caddy.RegisterModule(Handler{})
}
@@ -752,25 +745,23 @@ func (h *Handler) reverseProxy(rw http.ResponseWriter, req *http.Request, origRe
server := req.Context().Value(caddyhttp.ServerCtxKey).(*caddyhttp.Server)
shouldLogCredentials := server.Logs != nil && server.Logs.ShouldLogCredentials
- if supports1xx {
- // Forward 1xx status codes, backported from https://github.com/golang/go/pull/53164
- trace := &httptrace.ClientTrace{
- Got1xxResponse: func(code int, header textproto.MIMEHeader) error {
- h := rw.Header()
- copyHeader(h, http.Header(header))
- rw.WriteHeader(code)
-
- // Clear headers coming from the backend
- // (it's not automatically done by ResponseWriter.WriteHeader() for 1xx responses)
- for k := range header {
- delete(h, k)
- }
+ // Forward 1xx status codes, backported from https://github.com/golang/go/pull/53164
+ trace := &httptrace.ClientTrace{
+ Got1xxResponse: func(code int, header textproto.MIMEHeader) error {
+ h := rw.Header()
+ copyHeader(h, http.Header(header))
+ rw.WriteHeader(code)
+
+ // Clear headers coming from the backend
+ // (it's not automatically done by ResponseWriter.WriteHeader() for 1xx responses)
+ for k := range header {
+ delete(h, k)
+ }
- return nil
- },
- }
- req = req.WithContext(httptrace.WithClientTrace(req.Context(), trace))
+ return nil
+ },
}
+ req = req.WithContext(httptrace.WithClientTrace(req.Context(), trace))
// if FlushInterval is explicitly configured to -1 (i.e. flush continuously to achieve
// low-latency streaming), don't let the transport cancel the request if the client
diff --git a/modules/caddyhttp/reverseproxy/selectionpolicies.go b/modules/caddyhttp/reverseproxy/selectionpolicies.go
index f89c48f..bc6de35 100644
--- a/modules/caddyhttp/reverseproxy/selectionpolicies.go
+++ b/modules/caddyhttp/reverseproxy/selectionpolicies.go
@@ -27,7 +27,6 @@ import (
"strconv"
"strings"
"sync/atomic"
- "time"
"github.com/caddyserver/caddy/v2"
"github.com/caddyserver/caddy/v2/caddyconfig"
@@ -48,8 +47,6 @@ func init() {
caddy.RegisterModule(QueryHashSelection{})
caddy.RegisterModule(HeaderHashSelection{})
caddy.RegisterModule(CookieHashSelection{})
-
- weakrand.Seed(time.Now().UTC().UnixNano())
}
// RandomSelection is a policy that selects