Source file src/net/http/internal/http3/quic.go

     1  // Copyright 2025 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package http3
     6  
     7  import (
     8  	"crypto/tls"
     9  	"slices"
    10  
    11  	"golang.org/x/net/quic"
    12  )
    13  
    14  func newQUICConfig(config *quic.Config, tlsConfig *tls.Config) *quic.Config {
    15  	config = config.Clone()
    16  	if config == nil {
    17  		config = &quic.Config{}
    18  	}
    19  	// tlsConfig may be nil: net/http.Transport.TLSClientConfig is nil
    20  	// by default, and initEndpoint passes it to us unchanged.
    21  	if tlsConfig == nil {
    22  		tlsConfig = &tls.Config{NextProtos: []string{"h3"}}
    23  	} else if !slices.Equal(tlsConfig.NextProtos, []string{"h3"}) {
    24  		tlsConfig = tlsConfig.Clone()
    25  		tlsConfig.NextProtos = []string{"h3"}
    26  	}
    27  	config.TLSConfig = tlsConfig
    28  	return config
    29  }
    30  

View as plain text