Source file src/vendor/golang.org/x/net/http3/http3.go

     1  // Copyright 2026 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  	"net/http"
     9  	"time"
    10  	_ "unsafe" // for linkname
    11  
    12  	. "golang.org/x/net/internal/http3"
    13  	"golang.org/x/net/quic"
    14  )
    15  
    16  // Be extra generous with the handshake timeout. On some builders, the default
    17  // handshake timeout seems to be insufficient, causing rare test flakes.
    18  const handshakeTimeout = 1 * time.Minute
    19  
    20  //go:linkname registerHTTP3Server net/http_test.registerHTTP3Server
    21  func registerHTTP3Server(s *http.Server) <-chan *quic.Endpoint {
    22  	endpointCh := make(chan *quic.Endpoint)
    23  	RegisterServer(s, ServerOpts{
    24  		ListenQUIC: func(addr string, config *quic.Config) (*quic.Endpoint, error) {
    25  			e, err := quic.Listen("udp", addr, config)
    26  			endpointCh <- e
    27  			return e, err
    28  		},
    29  		QUICConfig: &quic.Config{HandshakeTimeout: handshakeTimeout},
    30  	})
    31  	return endpointCh
    32  }
    33  
    34  //go:linkname registerHTTP3Transport net/http_test.registerHTTP3Transport
    35  func registerHTTP3Transport(tr *http.Transport) <-chan *quic.Endpoint {
    36  	endpointCh := make(chan *quic.Endpoint)
    37  	RegisterTransport(tr, TransportOpts{
    38  		ListenQUIC: func(addr string, config *quic.Config) (*quic.Endpoint, error) {
    39  			e, err := quic.Listen("udp", addr, config)
    40  			endpointCh <- e
    41  			return e, err
    42  		},
    43  		QUICConfig: &quic.Config{HandshakeTimeout: handshakeTimeout},
    44  	})
    45  	return endpointCh
    46  }
    47  

View as plain text