Skip to content

Commit

Permalink
Use Transport.ForceAttemptHTTP2 to enable HTTP/2
Browse files Browse the repository at this point in the history
This can remove `golang.org/x/net/http2` dependency.
Ref: https://golang.org/doc/go1.13#net/http
  • Loading branch information
y-yagi committed Jul 18, 2021
1 parent 6fb0374 commit 199a02b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Imitation is the sincerest form of flattery.
But seriously, https://github.com/reorx/httpstat is the new hotness, and this is a shameless rip off.

## Installation
`httpstat` requires Go 1.11 or later.
`httpstat` requires Go 1.13 or later.
```
$ go get github.com/davecheney/httpstat
```
Expand Down
10 changes: 1 addition & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
"strings"
"time"

"golang.org/x/net/http2"

"github.com/fatih/color"
)

Expand Down Expand Up @@ -253,6 +251,7 @@ func visit(url *url.URL) {
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
ForceAttemptHTTP2: true,
}

switch {
Expand All @@ -274,13 +273,6 @@ func visit(url *url.URL) {
InsecureSkipVerify: insecure,
Certificates: readClientCert(clientCertFile),
}

// Because we create a custom TLSClientConfig, we have to opt-in to HTTP/2.
// See https://github.com/golang/go/issues/14275
err = http2.ConfigureTransport(tr)
if err != nil {
log.Fatalf("failed to prepare transport for HTTP/2: %v", err)
}
}

client := &http.Client{
Expand Down

0 comments on commit 199a02b

Please sign in to comment.