Skip to content

Commit

Permalink
repro
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedanese committed Jul 14, 2020
0 parents commit eb81410
Show file tree
Hide file tree
Showing 70 changed files with 56,900 additions and 0 deletions.
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module h2bug

go 1.14

require golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
92 changes: 92 additions & 0 deletions h2bug_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package http

import (
"context"
"crypto/tls"
"errors"
"fmt"
"log"
"net"
"net/http"
"net/http/httptrace"
"sync"
"testing"
"time"

"golang.org/x/net/http2"
)

var bad struct {
sync.Mutex
val bool
}

type connWrapper struct {
net.Conn
}

func (cw *connWrapper) Write(b []byte) (n int, err error) {
bad.Lock()
defer bad.Unlock()
if bad.val {
log.Printf("bad=false")
bad.val = false
return 0, errors.New("broken pipe")
}
return cw.Conn.Write(b)
}

var trace = &httptrace.ClientTrace{
GotConn: func(info httptrace.GotConnInfo) {
log.Printf("conn: %#v", info)
},
TLSHandshakeDone: func(cfg tls.ConnectionState, err error) {
bad.Lock()
defer bad.Unlock()
log.Printf("bad=true")
bad.val = true
},
}

func dial(network, addr string) (net.Conn, error) {
c, err := net.Dial(network, addr)
if err != nil {
return nil, err
}
return &connWrapper{c}, nil
}

func TestBadCaching(t *testing.T) {
ts := &http.Transport{
ForceAttemptHTTP2: true,
Dial: dial,
DialContext: func(_ context.Context, network, addr string) (net.Conn, error) {
return dial(network, addr)
},
}
if err := http2.ConfigureTransport(ts); err != nil {
t.Fatal(err)
}

cli := &http.Client{
Transport: ts,
}
for {
func() {
req, err := http.NewRequest("GET", "https://container.googleapis.com", nil)
if err != nil {
log.Printf("err: %v\n", err)
return
}
req = req.WithContext(httptrace.WithClientTrace(req.Context(), trace))
resp, err := cli.Do(req)
if err != nil {
log.Printf("err: %v\n", err)
return
}
fmt.Printf("status: %v\n", resp.Status)
defer resp.Body.Close()
}()
time.Sleep(1 * time.Second)
}
}
3 changes: 3 additions & 0 deletions vendor/golang.org/x/net/AUTHORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/golang.org/x/net/CONTRIBUTORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions vendor/golang.org/x/net/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions vendor/golang.org/x/net/PATENTS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions vendor/golang.org/x/net/http/httpguts/guts.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit eb81410

Please sign in to comment.