diff options
| author | Damien Neil <dneil@google.com> | 2024-05-29 09:24:20 -0700 |
|---|---|---|
| committer | Damien Neil <dneil@google.com> | 2024-11-05 22:14:59 +0000 |
| commit | bfc8f28068c4aff44aded67aef12e56ecc843717 (patch) | |
| tree | d689a3e8af0036e9276aa45c5193df8f1349d6f3 /src/net/http/http_test.go | |
| parent | 635c2dce04259f2c84aeac543f0305b3e7c8ed7b (diff) | |
| download | go-bfc8f28068c4aff44aded67aef12e56ecc843717.tar.xz | |
net/http: add Protocols field to Server and Transport
Support configuring which HTTP version(s) a server or client use
via an explicit set of protocols. The Protocols field takes
precedence over TLSNextProto and ForceAttemptHTTP2.
Fixes #67814
Change-Id: I09ece88f78ad4d98ca1f213157b5f62ae11e063f
Reviewed-on: https://go-review.googlesource.com/c/go/+/607496
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/net/http/http_test.go')
| -rw-r--r-- | src/net/http/http_test.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/net/http/http_test.go b/src/net/http/http_test.go index 777634bbb2..5aba3ed5a6 100644 --- a/src/net/http/http_test.go +++ b/src/net/http/http_test.go @@ -187,6 +187,28 @@ func TestNoUnicodeStrings(t *testing.T) { } } +func TestProtocols(t *testing.T) { + var p Protocols + if p.HTTP1() { + t.Errorf("zero-value protocols: p.HTTP1() = true, want false") + } + p.SetHTTP1(true) + p.SetHTTP2(true) + if !p.HTTP1() { + t.Errorf("initialized protocols: p.HTTP1() = false, want true") + } + if !p.HTTP2() { + t.Errorf("initialized protocols: p.HTTP2() = false, want true") + } + p.SetHTTP1(false) + if p.HTTP1() { + t.Errorf("after unsetting HTTP1: p.HTTP1() = true, want false") + } + if !p.HTTP2() { + t.Errorf("after unsetting HTTP1: p.HTTP2() = false, want true") + } +} + const redirectURL = "/thisaredirect细雪withasciilettersのけぶabcdefghijk.html" func BenchmarkHexEscapeNonASCII(b *testing.B) { |
