mirror of
https://github.com/golang/net.git
synced 2026-04-01 02:47:08 +09:00
http2: workaround TCPConn CloseWrite not being supported on Plan 9
This stops the tests from hanging on Plan 9. Fixes golang/go#35904 Updates golang/go#17906 Change-Id: I2bcbb131629b217a99f9496cda0399ce21eb3020 Reviewed-on: https://go-review.googlesource.com/c/net/+/209417 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
ef20fe5d79
commit
5ee1b9f485
@@ -832,6 +832,10 @@ func testTransportReqBodyAfterResponse(t *testing.T, status int) {
|
||||
ct := newClientTester(t)
|
||||
ct.client = func() error {
|
||||
defer ct.cc.(*net.TCPConn).CloseWrite()
|
||||
if runtime.GOOS == "plan9" {
|
||||
// CloseWrite not supported on Plan 9; Issue 17906
|
||||
defer ct.cc.(*net.TCPConn).Close()
|
||||
}
|
||||
defer close(clientDone)
|
||||
|
||||
var n int64 // atomic
|
||||
@@ -2693,6 +2697,10 @@ func testTransportUsesGoAwayDebugError(t *testing.T, failMidBody bool) {
|
||||
ct.fr.WriteGoAway(5, ErrCodeNo, []byte(goAwayDebugData))
|
||||
ct.fr.WriteGoAway(5, goAwayErrCode, nil)
|
||||
ct.sc.(*net.TCPConn).CloseWrite()
|
||||
if runtime.GOOS == "plan9" {
|
||||
// CloseWrite not supported on Plan 9; Issue 17906
|
||||
ct.sc.(*net.TCPConn).Close()
|
||||
}
|
||||
<-clientDone
|
||||
return nil
|
||||
}
|
||||
@@ -2821,6 +2829,10 @@ func TestTransportAdjustsFlowControl(t *testing.T) {
|
||||
|
||||
ct.client = func() error {
|
||||
defer ct.cc.(*net.TCPConn).CloseWrite()
|
||||
if runtime.GOOS == "plan9" {
|
||||
// CloseWrite not supported on Plan 9; Issue 17906
|
||||
defer ct.cc.(*net.TCPConn).Close()
|
||||
}
|
||||
defer close(clientDone)
|
||||
|
||||
req, _ := http.NewRequest("POST", "https://dummy.tld/", struct{ io.Reader }{io.LimitReader(neverEnding('A'), bodySize)})
|
||||
@@ -3449,6 +3461,10 @@ func TestTransportRetryAfterRefusedStream(t *testing.T) {
|
||||
ct := newClientTester(t)
|
||||
ct.client = func() error {
|
||||
defer ct.cc.(*net.TCPConn).CloseWrite()
|
||||
if runtime.GOOS == "plan9" {
|
||||
// CloseWrite not supported on Plan 9; Issue 17906
|
||||
defer ct.cc.(*net.TCPConn).Close()
|
||||
}
|
||||
defer close(clientDone)
|
||||
req, _ := http.NewRequest("GET", "https://dummy.tld/", nil)
|
||||
resp, err := ct.tr.RoundTrip(req)
|
||||
@@ -3515,6 +3531,10 @@ func TestTransportRetryHasLimit(t *testing.T) {
|
||||
ct := newClientTester(t)
|
||||
ct.client = func() error {
|
||||
defer ct.cc.(*net.TCPConn).CloseWrite()
|
||||
if runtime.GOOS == "plan9" {
|
||||
// CloseWrite not supported on Plan 9; Issue 17906
|
||||
defer ct.cc.(*net.TCPConn).Close()
|
||||
}
|
||||
defer close(clientDone)
|
||||
req, _ := http.NewRequest("GET", "https://dummy.tld/", nil)
|
||||
resp, err := ct.tr.RoundTrip(req)
|
||||
@@ -3563,6 +3583,10 @@ func TestTransportResponseDataBeforeHeaders(t *testing.T) {
|
||||
ct := newClientTester(t)
|
||||
ct.client = func() error {
|
||||
defer ct.cc.(*net.TCPConn).CloseWrite()
|
||||
if runtime.GOOS == "plan9" {
|
||||
// CloseWrite not supported on Plan 9; Issue 17906
|
||||
defer ct.cc.(*net.TCPConn).Close()
|
||||
}
|
||||
req := httptest.NewRequest("GET", "https://dummy.tld/", nil)
|
||||
// First request is normal to ensure the check is per stream and not per connection.
|
||||
_, err := ct.tr.RoundTrip(req)
|
||||
@@ -3675,6 +3699,10 @@ func TestTransportRequestsStallAtServerLimit(t *testing.T) {
|
||||
wg.Wait()
|
||||
close(clientDone)
|
||||
ct.cc.(*net.TCPConn).CloseWrite()
|
||||
if runtime.GOOS == "plan9" {
|
||||
// CloseWrite not supported on Plan 9; Issue 17906
|
||||
ct.cc.(*net.TCPConn).Close()
|
||||
}
|
||||
}()
|
||||
for k := 0; k < maxConcurrent+2; k++ {
|
||||
wg.Add(1)
|
||||
@@ -4295,6 +4323,10 @@ func testTransportBodyReadError(t *testing.T, body []byte) {
|
||||
ct := newClientTester(t)
|
||||
ct.client = func() error {
|
||||
defer ct.cc.(*net.TCPConn).CloseWrite()
|
||||
if runtime.GOOS == "plan9" {
|
||||
// CloseWrite not supported on Plan 9; Issue 17906
|
||||
defer ct.cc.(*net.TCPConn).Close()
|
||||
}
|
||||
defer close(clientDone)
|
||||
|
||||
checkNoStreams := func() error {
|
||||
@@ -4383,6 +4415,10 @@ func TestTransportBodyEagerEndStream(t *testing.T) {
|
||||
ct := newClientTester(t)
|
||||
ct.client = func() error {
|
||||
defer ct.cc.(*net.TCPConn).CloseWrite()
|
||||
if runtime.GOOS == "plan9" {
|
||||
// CloseWrite not supported on Plan 9; Issue 17906
|
||||
defer ct.cc.(*net.TCPConn).Close()
|
||||
}
|
||||
body := strings.NewReader(reqBody)
|
||||
req, err := http.NewRequest("PUT", "https://dummy.tld/", body)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user