-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit eb81410
Showing
70 changed files
with
56,900 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.