aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/httptest
diff options
context:
space:
mode:
authorapocelipes <seve3r@outlook.com>2025-02-05 00:37:18 +0000
committerGopher Robot <gobot@golang.org>2025-02-04 17:20:47 -0800
commita1ea78c470d3136b7aed42a4d8b94497563f98ea (patch)
treeeeff0948e18d8ac6087b9120f0be65ab64fd13af /src/net/http/httptest
parent0e35fb2f99ce4c249c0a42ad93a597835ae742b5 (diff)
downloadgo-a1ea78c470d3136b7aed42a4d8b94497563f98ea.tar.xz
net: use strings.SplitSeq and bytes.SplitSeq
Replace `for _, s := range {strings, bytes}.Split(v, sep)` with `for s := range {strings, bytes}.SplitSeq(v, sep)`, to simplify the code and reduce some memory allocations. Change-Id: Idead4de1e3928fc75cc5ba8caeff85542f1243d5 GitHub-Last-Rev: 5fb196a073e7583b23b1ebb446d6c067580ed63a GitHub-Pull-Request: golang/go#71554 Reviewed-on: https://go-review.googlesource.com/c/go/+/646216 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/net/http/httptest')
-rw-r--r--src/net/http/httptest/recorder.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/net/http/httptest/recorder.go b/src/net/http/httptest/recorder.go
index dd51901b0d..17aa70f067 100644
--- a/src/net/http/httptest/recorder.go
+++ b/src/net/http/httptest/recorder.go
@@ -207,7 +207,7 @@ func (rw *ResponseRecorder) Result() *http.Response {
if trailers, ok := rw.snapHeader["Trailer"]; ok {
res.Trailer = make(http.Header, len(trailers))
for _, k := range trailers {
- for _, k := range strings.Split(k, ",") {
+ for k := range strings.SplitSeq(k, ",") {
k = http.CanonicalHeaderKey(textproto.TrimString(k))
if !httpguts.ValidTrailerHeader(k) {
// Ignore since forbidden by RFC 7230, section 4.1.2.