Documentation ¶
Index ¶
- Variables
- func ListenAndServe(addr, certFile, keyFile string, handler http.Handler) error
- func ListenAndServeQUIC(addr, certFile, keyFile string, handler http.Handler) error
- type RoundTripOpt
- type RoundTripper
- type Server
- func (s *Server) Close() error
- func (s *Server) CloseGracefully(timeout time.Duration) error
- func (s *Server) ListenAndServe() error
- func (s *Server) ListenAndServeTLS(certFile, keyFile string) error
- func (s *Server) Serve(conn net.PacketConn) error
- func (s *Server) SetQuicHeaders(hdr http.Header) error
Constants ¶
This section is empty.
Variables ¶
var ErrNoCachedConn = errors.New("h2quic: no cached connection was available")
ErrNoCachedConn is returned when RoundTripper.OnlyCachedConn is set
Functions ¶
func ListenAndServe ¶
ListenAndServe listens on the given network address for both, TLS and QUIC connetions in parallel. It returns if one of the two returns an error. http.DefaultServeMux is used when handler is nil. The correct Alt-Svc headers for QUIC are set.
Types ¶
type RoundTripOpt ¶ added in v0.6.0
type RoundTripOpt struct { // OnlyCachedConn controls whether the RoundTripper may // create a new QUIC connection. If set true and // no cached connection is available, RoundTrip // will return ErrNoCachedConn. OnlyCachedConn bool }
RoundTripOpt are options for the Transport.RoundTripOpt method.
type RoundTripper ¶ added in v0.6.0
type RoundTripper struct { // DisableCompression, if true, prevents the Transport from // requesting compression with an "Accept-Encoding: gzip" // request header when the Request contains no existing // Accept-Encoding value. If the Transport requests gzip on // its own and gets a gzipped response, it's transparently // decoded in the Response.Body. However, if the user // explicitly requested gzip it is not automatically // uncompressed. DisableCompression bool // TLSClientConfig specifies the TLS configuration to use with // tls.Client. If nil, the default configuration is used. TLSClientConfig *tls.Config // QuicConfig is the quic.Config used for dialing new connections. // If nil, reasonable default values will be used. QuicConfig *quic.Config // contains filtered or unexported fields }
RoundTripper implements the http.RoundTripper interface
func (*RoundTripper) Close ¶ added in v0.6.0
func (r *RoundTripper) Close() error
Close closes the QUIC connections that this RoundTripper has used
func (*RoundTripper) RoundTripOpt ¶ added in v0.6.0
func (r *RoundTripper) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Response, error)
RoundTripOpt is like RoundTrip, but takes options.
type Server ¶
type Server struct { *http.Server // By providing a quic.Config, it is possible to set parameters of the QUIC connection. // If nil, it uses reasonable default values. QuicConfig *quic.Config // Private flag for demo, do not use CloseAfterFirstRequest bool // contains filtered or unexported fields }
Server is a HTTP2 server listening for QUIC connections.
func (*Server) Close ¶
Close the server immediately, aborting requests and sending CONNECTION_CLOSE frames to connected clients. Close in combination with ListenAndServe() (instead of Serve()) may race if it is called before a UDP socket is established.
func (*Server) CloseGracefully ¶
CloseGracefully shuts down the server gracefully. The server sends a GOAWAY frame first, then waits for either timeout to trigger, or for all running requests to complete. CloseGracefully in combination with ListenAndServe() (instead of Serve()) may race if it is called before a UDP socket is established.
func (*Server) ListenAndServe ¶
ListenAndServe listens on the UDP address s.Addr and calls s.Handler to handle HTTP/2 requests on incoming connections.
func (*Server) ListenAndServeTLS ¶
ListenAndServeTLS listens on the UDP address s.Addr and calls s.Handler to handle HTTP/2 requests on incoming connections.
func (*Server) Serve ¶
func (s *Server) Serve(conn net.PacketConn) error
Serve an existing UDP connection.
func (*Server) SetQuicHeaders ¶
SetQuicHeaders can be used to set the proper headers that announce that this server supports QUIC. The values that are set depend on the port information from s.Server.Addr, and currently look like this (if Addr has port 443):
Alt-Svc: quic=":443"; ma=2592000; v="33,32,31,30"