Skip to content

Commit

Permalink
Merge pull request #309 from forta-network/disable-http-2
Browse files Browse the repository at this point in the history
Disable HTTP/2 in default client
  • Loading branch information
dkeysil authored Apr 10, 2024
2 parents b5d04a0 + 453da8f commit 80ab9a8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion utils/httpclient/client.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package httpclient

import (
"crypto/tls"
"net/http"
"time"
)

// Default is the default HTTP client to use.
// Default is the default HTTP client to use. HTTP/2 is disabled.
var Default = &http.Client{
Timeout: time.Second * 30,
// Disable HTTP/2
// Reason: https://www.bentasker.co.uk/posts/blog/software-development/golang-net-http-net-http-2-does-not-reliably-close-failed-connections-allowing-attempted-reuse.html
Transport: &http.Transport{
TLSNextProto: map[string]func(string, *tls.Conn) http.RoundTripper{},
},
}

0 comments on commit 80ab9a8

Please sign in to comment.