mirror of
https://github.com/golang/go.git
synced 2026-04-02 09:20:29 +09:00
net/http/internal/http2: remove TestServerHandleCustomConn
This test exercises the ability to provide a non-*tls.Conn to the HTTP/2 server. This is not currently supported by net/http.Server (although it would be nice to have), so drop the test. For #67810 Change-Id: Ica5b0bcceddbb75dcc2b4d5f69fad8676a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/751307 Reviewed-by: Nicholas Husin <nsh@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Nicholas Husin <husin@google.com>
This commit is contained in:
committed by
Gopher Robot
parent
dab0ba481c
commit
d6d0f5e08d
@@ -3508,81 +3508,6 @@ func BenchmarkServer_PostRequest(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
type connStateConn struct {
|
||||
net.Conn
|
||||
cs tls.ConnectionState
|
||||
}
|
||||
|
||||
func (c connStateConn) ConnectionState() tls.ConnectionState { return c.cs }
|
||||
|
||||
// golang.org/issue/12737 -- handle any net.Conn, not just
|
||||
// *tls.Conn.
|
||||
func TestServerHandleCustomConn(t *testing.T) { synctestTest(t, testServerHandleCustomConn) }
|
||||
func testServerHandleCustomConn(t testing.TB) {
|
||||
var s Server
|
||||
c1, c2 := net.Pipe()
|
||||
clientDone := make(chan struct{})
|
||||
handlerDone := make(chan struct{})
|
||||
var req *http.Request
|
||||
go func() {
|
||||
defer close(clientDone)
|
||||
defer c2.Close()
|
||||
fr := NewFramer(c2, c2)
|
||||
io.WriteString(c2, ClientPreface)
|
||||
fr.WriteSettings()
|
||||
fr.WriteSettingsAck()
|
||||
f, err := fr.ReadFrame()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
if sf, ok := f.(*SettingsFrame); !ok || sf.IsAck() {
|
||||
t.Errorf("Got %v; want non-ACK SettingsFrame", SummarizeFrame(f))
|
||||
return
|
||||
}
|
||||
f, err = fr.ReadFrame()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
if sf, ok := f.(*SettingsFrame); !ok || !sf.IsAck() {
|
||||
t.Errorf("Got %v; want ACK SettingsFrame", SummarizeFrame(f))
|
||||
return
|
||||
}
|
||||
var henc hpackEncoder
|
||||
fr.WriteHeaders(HeadersFrameParam{
|
||||
StreamID: 1,
|
||||
BlockFragment: henc.encodeHeaderRaw(t, ":method", "GET", ":path", "/", ":scheme", "https", ":authority", "foo.com"),
|
||||
EndStream: true,
|
||||
EndHeaders: true,
|
||||
})
|
||||
go io.Copy(io.Discard, c2)
|
||||
<-handlerDone
|
||||
}()
|
||||
const testString = "my custom ConnectionState"
|
||||
const cipher_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 = 0xC02F // defined in ciphers.go
|
||||
fakeConnState := tls.ConnectionState{
|
||||
ServerName: testString,
|
||||
Version: tls.VersionTLS12,
|
||||
CipherSuite: cipher_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
|
||||
}
|
||||
go s.ServeConn(connStateConn{c1, fakeConnState}, &ServeConnOpts{
|
||||
BaseConfig: &http.Server{
|
||||
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
defer close(handlerDone)
|
||||
req = r
|
||||
}),
|
||||
}})
|
||||
<-clientDone
|
||||
|
||||
if req.TLS == nil {
|
||||
t.Fatalf("Request.TLS is nil. Got: %#v", req)
|
||||
}
|
||||
if req.TLS.ServerName != testString {
|
||||
t.Fatalf("Request.TLS = %+v; want ServerName of %q", req.TLS, testString)
|
||||
}
|
||||
}
|
||||
|
||||
// golang.org/issue/14214
|
||||
func TestServer_Rejects_ConnHeaders(t *testing.T) { synctestTest(t, testServer_Rejects_ConnHeaders) }
|
||||
func testServer_Rejects_ConnHeaders(t testing.TB) {
|
||||
|
||||
Reference in New Issue
Block a user