]> Cypherpunks repositories - gostls13.git/commit
net/http: make the zero value of CrossOriginProtection work
authorAustin Clements <austin@google.com>
Tue, 10 Jun 2025 16:26:03 +0000 (12:26 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 10 Jun 2025 18:09:07 +0000 (11:09 -0700)
commit1cafdfb63bb9b8825c5f4143d154bce3b82ed6a1
treec416fe12abefe398ac87e60c08922200177ec881
parenta35701b3525ccd140995a216758760c60e7c58d7
net/http: make the zero value of CrossOriginProtection work

Currently, CrossOriginProtection must be constructed by
NewCrossOriginProtection. If you try to use the zero value, most
methods will panic with a nil dereference.

This CL makes CrossOriginProtection use on-demand initialization
instead, so the zero value has the same semantics as the value
currently returned by NewCrossOriginProtection. Now,
NewCrossOriginProtection just constructs the zero value.

We keep NewCrossOriginProtection by analogy to NewServeMux.

Updates #73626
Fixes #74089.

Change-Id: Ia80183eb6bfdafb0e002271c0b25c2d6230a159a
Reviewed-on: https://go-review.googlesource.com/c/go/+/680396
Auto-Submit: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
src/net/http/csrf.go