Skip to content

Commit 199a02b

Browse files
committed
Use Transport.ForceAttemptHTTP2 to enable HTTP/2
This can remove `golang.org/x/net/http2` dependency. Ref: https://golang.org/doc/go1.13#net/http
1 parent 6fb0374 commit 199a02b

2 files changed

Lines changed: 2 additions & 10 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Imitation is the sincerest form of flattery.
99
But seriously, https://github.com/reorx/httpstat is the new hotness, and this is a shameless rip off.
1010

1111
## Installation
12-
`httpstat` requires Go 1.11 or later.
12+
`httpstat` requires Go 1.13 or later.
1313
```
1414
$ go get github.com/davecheney/httpstat
1515
```

main.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import (
2222
"strings"
2323
"time"
2424

25-
"golang.org/x/net/http2"
26-
2725
"github.com/fatih/color"
2826
)
2927

@@ -253,6 +251,7 @@ func visit(url *url.URL) {
253251
IdleConnTimeout: 90 * time.Second,
254252
TLSHandshakeTimeout: 10 * time.Second,
255253
ExpectContinueTimeout: 1 * time.Second,
254+
ForceAttemptHTTP2: true,
256255
}
257256

258257
switch {
@@ -274,13 +273,6 @@ func visit(url *url.URL) {
274273
InsecureSkipVerify: insecure,
275274
Certificates: readClientCert(clientCertFile),
276275
}
277-
278-
// Because we create a custom TLSClientConfig, we have to opt-in to HTTP/2.
279-
// See https://github.com/golang/go/issues/14275
280-
err = http2.ConfigureTransport(tr)
281-
if err != nil {
282-
log.Fatalf("failed to prepare transport for HTTP/2: %v", err)
283-
}
284276
}
285277

286278
client := &http.Client{

0 commit comments

Comments
 (0)