Created
June 7, 2022 15:28
-
-
Save ncw/016e5ccdc69000225b03db43e00f8c3a to your computer and use it in GitHub Desktop.
Reproducer for https://github.com/golang/go/issues/53253
This file contains hidden or 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
module github.com/ncw/go-issue-53253 | |
go 1.18 | |
replace golang.org/x/net => /opt/go/x/net | |
require ( | |
golang.org/x/net v0.0.0-20220607020251-c690dde0001d // indirect | |
golang.org/x/text v0.3.6 // indirect | |
) |
This file contains hidden or 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
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= | |
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | |
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
This file contains hidden or 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
package main | |
import ( | |
"flag" | |
"fmt" | |
"io" | |
"log" | |
"net/http" | |
"os" | |
"time" | |
"golang.org/x/net/http2" | |
) | |
func get(url string) { | |
t0 := time.Now() | |
resp, err := http.Head(url) | |
dt := time.Since(t0) | |
if err != nil { | |
log.Printf("Failed to fetch %q: %v", url, err) | |
return | |
} | |
defer resp.Body.Close() | |
_, err = io.Copy(os.Stdout, resp.Body) | |
if err != nil && err != io.EOF { | |
log.Printf("Failed to read from %q: %v", url, err) | |
return | |
} | |
fmt.Println() | |
log.Printf("%q: read OK", url) | |
log.Printf("%q: request -> response took %v", url, dt) | |
} | |
func main() { | |
flag.Parse() | |
// Use the specific version of x/net/http2 in go.mod rather | |
// than the one bundled with the go compiler | |
t := http.DefaultTransport.(*http.Transport) | |
t.TLSNextProto = nil | |
err := http2.ConfigureTransport(t) | |
if err != nil { | |
log.Fatal(err) | |
} | |
for _, arg := range flag.Args() { | |
get(arg) | |
get(arg) | |
get(arg) | |
get(arg) | |
get(arg) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment