Skip to content

Commit

Permalink
Disable http2, take 2
Browse files Browse the repository at this point in the history
  • Loading branch information
germanoeich committed Apr 12, 2022
1 parent e41c309 commit c6bdce5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,20 @@ type BotUserResponse struct {

func createTransport(ip string) http.RoundTripper {
if ip == "" {
return http.DefaultTransport
// http.DefaultTransport options, with http2 disabled
return &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).DialContext,
ForceAttemptHTTP2: false,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
TLSNextProto: map[string]func(string, *tls.Conn) http.RoundTripper{},
}
}
addr, err := net.ResolveTCPAddr("tcp", ip+":0")

Expand All @@ -55,7 +68,7 @@ func createTransport(ip string) http.RoundTripper {
}

transport := http.Transport{
ForceAttemptHTTP2: true,
ForceAttemptHTTP2: false,
MaxIdleConns: 1000,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
Expand Down

0 comments on commit c6bdce5

Please sign in to comment.