Last active
July 30, 2024 22:12
Revisions
-
wolfeidau revised this gist
Jul 30, 2024 . 1 changed file with 0 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,9 +17,6 @@ func main() { tr := http.DefaultTransport.(*http.Transport).Clone() if *disableHTTP2 { tr.ForceAttemptHTTP2 = false tr.TLSNextProto = make(map[string]func(authority string, c *tls.Conn) http.RoundTripper) -
wolfeidau revised this gist
Jul 30, 2024 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,6 @@ func main() { tr.MaxIdleConnsPerHost = 100 if *disableHTTP2 { tr.ForceAttemptHTTP2 = false tr.TLSNextProto = make(map[string]func(authority string, c *tls.Conn) http.RoundTripper) // The default TLSClientConfig has h2 in NextProtos, so the negotiated TLS connection will assume h2 support. -
wolfeidau revised this gist
Jul 30, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -33,7 +33,7 @@ func main() { Transport: tr, } resp, err := client.Get("https://google.com") if err != nil { panic(err) } -
wolfeidau created this gist
Jul 30, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ package main import ( "crypto/tls" "flag" "log/slog" "net/http" "os" ) var disableHTTP2 = flag.Bool("disable-http2", false, "Disable HTTP/2.0") func main() { flag.Parse() slog.SetDefault(slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{}))) tr := http.DefaultTransport.(*http.Transport).Clone() tr.Proxy = http.ProxyFromEnvironment tr.MaxIdleConnsPerHost = 100 if *disableHTTP2 { // need to disable HTTP/2.0 and just updating the default transport won't work https://github.com/golang/go/issues/50571 tr.ForceAttemptHTTP2 = false tr.TLSNextProto = make(map[string]func(authority string, c *tls.Conn) http.RoundTripper) // The default TLSClientConfig has h2 in NextProtos, so the negotiated TLS connection will assume h2 support. // see https://github.com/golang/go/issues/50571 tr.TLSClientConfig = &tls.Config{} } client := http.Client{ Transport: tr, } resp, err := client.Get("http://agent.buildkite.com/v3/ping") if err != nil { panic(err) } defer resp.Body.Close() // Print the HTTP Status Code slog.With("resp.Status", resp.Status, "resp.StatusCode", resp.StatusCode, "resp.Proto", resp.Proto).Info("HTTP Status Code") }