Skip to content

Commit 80c9209

Browse files
committed
address PR notes
1 parent 4c42509 commit 80c9209

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

private/buf/bufcurl/tls.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ type TLSSettings struct {
3838
// "h2", and exclude "http/1.1". If the server does not pick a
3939
// protocol, "h2" is assumed as the default.
4040
HTTP2PriorKnowledge bool
41-
41+
// If true, the server is known to support HTTP/3. When set, the
42+
// ALPN protocols sent during the TLS handshake will include
43+
// only "h3", and exclude the other versions.
4244
HTTP3 bool
4345
}
4446

private/buf/cmd/buf/command/curl/curl.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -955,10 +955,11 @@ func run(ctx context.Context, container appext.Container, f *flags) (err error)
955955
// This shouldn't be possible since we check in flags.validate, but just in case
956956
return nil, errors.New("URL positional argument is missing")
957957
}
958-
if f.HTTP3 {
959-
return makeHTTP3Client(f, bufcurl.GetAuthority(host, requestHeaders), container.VerbosePrinter())
958+
roundTripper, err := makeHTTPRoundTripper(f, isSecure, bufcurl.GetAuthority(host, requestHeaders), container.VerbosePrinter())
959+
if err != nil {
960+
return nil, err
960961
}
961-
return makeHTTPClient(f, isSecure, bufcurl.GetAuthority(host, requestHeaders), container.VerbosePrinter())
962+
return bufcurl.NewVerboseHTTPClient(roundTripper, container.VerbosePrinter()), nil
962963
})
963964

964965
output := container.Stdout()
@@ -1067,7 +1068,10 @@ func run(ctx context.Context, container appext.Container, f *flags) (err error)
10671068
}
10681069
}
10691070

1070-
func makeHTTPClient(f *flags, isSecure bool, authority string, printer verbose.Printer) (connect.HTTPClient, error) {
1071+
func makeHTTPRoundTripper(f *flags, isSecure bool, authority string, printer verbose.Printer) (http.RoundTripper, error) {
1072+
if f.HTTP3 {
1073+
return makeHTTP3RoundTripper(f, authority, printer)
1074+
}
10711075
var dialer net.Dialer
10721076
if f.ConnectTimeoutSeconds != 0 {
10731077
dialer.Timeout = secondsToDuration(f.ConnectTimeoutSeconds)
@@ -1140,10 +1144,10 @@ func makeHTTPClient(f *flags, isSecure bool, authority string, printer verbose.P
11401144
MaxIdleConns: 1,
11411145
}
11421146
}
1143-
return bufcurl.NewVerboseHTTPClient(transport, printer), nil
1147+
return transport, nil
11441148
}
11451149

1146-
func makeHTTP3Client(f *flags, authority string, printer verbose.Printer) (connect.HTTPClient, error) {
1150+
func makeHTTP3RoundTripper(f *flags, authority string, printer verbose.Printer) (http.RoundTripper, error) {
11471151
quicCfg := &quic.Config{
11481152
KeepAlivePeriod: -1,
11491153
}
@@ -1186,7 +1190,7 @@ func makeHTTP3Client(f *flags, authority string, printer verbose.Printer) (conne
11861190
MaxResponseHeaderBytes: 0,
11871191
DisableCompression: false,
11881192
}
1189-
return bufcurl.NewVerboseHTTPClient(roundTripper, printer), nil
1193+
return roundTripper, nil
11901194
}
11911195

11921196
func secondsToDuration(secs float64) time.Duration {

0 commit comments

Comments
 (0)