Documentation ¶
Index ¶
- Constants
- Variables
- type FrameType
- type GzipReader
- type HTTPStreamer
- type Header
- type Hijacker
- type RoundTripOpt
- type RoundTripper
- func (r *RoundTripper) AddConn(addr string) error
- func (r *RoundTripper) Close() error
- func (r *RoundTripper) CloseIdleConnections()
- func (r *RoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
- func (r *RoundTripper) RoundTripOnlyCachedConn(req *http.Request) (*http.Response, error)
- func (r *RoundTripper) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Response, error)
- type Stream
- type StreamCreator
- type StreamType
Constants ¶
const ( VersionDraft29 quic.VersionNumber = 0xff00001d Version1 quic.VersionNumber = 0x1 Version2 quic.VersionNumber = 0x6b3343cf )
const MethodGet0RTT = "GET_0RTT"
MethodGet0RTT allows a GET request to be sent using 0-RTT. Note that 0-RTT data doesn't provide replay protection.
Variables ¶
var ErrNoCachedConn = errors.New("http3: no cached connection was available")
ErrNoCachedConn is returned when RoundTripper.OnlyCachedConn is set
Functions ¶
This section is empty.
Types ¶
type GzipReader ¶
type GzipReader struct { Body io.ReadCloser // underlying Response.Body // contains filtered or unexported fields }
call gzip.NewReader on the first call to Read
func (*GzipReader) Close ¶
func (gz *GzipReader) Close() error
type HTTPStreamer ¶
type HTTPStreamer interface {
HTTPStream() Stream
}
The HTTPStreamer allows taking over a HTTP/3 stream. The interface is implemented by: * for the server: the http.Request.Body * for the client: the http.Response.Body On the client side, the stream will be closed for writing, unless the DontCloseRequestStream RoundTripOpt was set. When a stream is taken over, it's the caller's responsibility to close the stream.
type Hijacker ¶
type Hijacker interface {
StreamCreator() StreamCreator
}
A Hijacker allows hijacking of the stream creating part of a quic.Session from a http.Response.Body. It is used by WebTransport to create WebTransport streams after a session has been established.
type RoundTripOpt ¶
type RoundTripOpt struct { // OnlyCachedConn controls whether the RoundTripper may create a new QUIC connection. // If set true and no cached connection is available, RoundTripOpt will return ErrNoCachedConn. OnlyCachedConn bool // DontCloseRequestStream controls whether the request stream is closed after sending the request. // If set, context cancellations have no effect after the response headers are received. DontCloseRequestStream bool }
RoundTripOpt are options for the Transport.RoundTripOpt method.
type RoundTripper ¶
type RoundTripper struct { *transport.Options // QuicConfig is the quic.Config used for dialing new connections. // If nil, reasonable default values will be used. QuicConfig *quic.Config // Enable support for HTTP/3 datagrams. // If set to true, QuicConfig.EnableDatagram will be set. // // See https://datatracker.ietf.org/doc/html/rfc9297. EnableDatagrams bool // Additional HTTP/3 settings. // It is invalid to specify any settings defined by the HTTP/3 draft and the datagram draft. AdditionalSettings map[uint64]uint64 // When set, this callback is called for the first unknown frame parsed on a bidirectional stream. // It is called right after parsing the frame type. // If parsing the frame type fails, the error is passed to the callback. // In that case, the frame type will not be set. // Callers can either ignore the frame and return control of the stream back to HTTP/3 // (by returning hijacked false). // Alternatively, callers can take over the QUIC stream (by returning hijacked true). StreamHijacker func(FrameType, quic.Connection, quic.Stream, error) (hijacked bool, err error) // When set, this callback is called for unknown unidirectional stream of unknown stream type. // If parsing the stream type fails, the error is passed to the callback. // In that case, the stream type will not be set. UniStreamHijacker func(StreamType, quic.Connection, quic.ReceiveStream, error) (hijacked bool) // Dial specifies an optional dial function for creating QUIC // connections for requests. // If Dial is nil, a UDPConn will be created at the first request // and will be reused for subsequent connections to other servers. Dial func(ctx context.Context, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error) // contains filtered or unexported fields }
RoundTripper implements the http.RoundTripper interface
func (*RoundTripper) AddConn ¶
func (r *RoundTripper) AddConn(addr string) error
AddConn add a http3 connection, dial new conn if not exists.
func (*RoundTripper) Close ¶
func (r *RoundTripper) Close() error
Close closes the QUIC connections that this RoundTripper has used. It also closes the underlying UDPConn if it is not nil.
func (*RoundTripper) CloseIdleConnections ¶
func (r *RoundTripper) CloseIdleConnections()
func (*RoundTripper) RoundTripOnlyCachedConn ¶
RoundTripOnlyCachedConn round trip only cached conn.
func (*RoundTripper) RoundTripOpt ¶
func (r *RoundTripper) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Response, error)
RoundTripOpt is like RoundTrip, but takes options.
type Stream ¶
type Stream quic.Stream
A Stream is a HTTP/3 stream. When writing to and reading from the stream, data is framed in HTTP/3 DATA frames.
type StreamCreator ¶
type StreamCreator interface { // Context returns a context that is cancelled when the underlying connection is closed. Context() context.Context OpenStream() (quic.Stream, error) OpenStreamSync(context.Context) (quic.Stream, error) OpenUniStream() (quic.SendStream, error) OpenUniStreamSync(context.Context) (quic.SendStream, error) LocalAddr() net.Addr RemoteAddr() net.Addr ConnectionState() quic.ConnectionState }