Documentation
¶
Overview ¶
Package h3 is mimicry's HTTP/3 client (RFC 9114) on internal/quic, with field sections encoded by internal/qpack. It reproduces the profile's HTTP/3 (profile.HTTP3): SETTINGS and GREASE, when each stream opens, QPACK table use, PRIORITY_UPDATE, header lists and DATA framing.
Each request's frames leave in one flight, in the browser's order (quic.Conn.Cork). A request the server did not process fails with ErrConnUnusable or ErrRejected so it can go on another connection.
Index ¶
- Variables
- func Head(p *profile.Spec, altHost, altPort string, req *http.Request) ([]qpack.Field, error)
- func Measured(p *profile.Spec, plan *headerorder.Plan) bool
- func QPACKConfig(h *profile.HTTP3) qpack.Config
- type Conn
- func (c *Conn) CanTakeNewRequest() bool
- func (c *Conn) Close() error
- func (c *Conn) Discard()
- func (c *Conn) Done() <-chan struct{}
- func (c *Conn) EarlyMethod(method string) bool
- func (c *Conn) GoneAway() bool
- func (c *Conn) IdleSince() (time.Time, bool)
- func (c *Conn) OnClose(f func())
- func (c *Conn) RoundTrip(req *http.Request) (*http.Response, error)
- type Options
Constants ¶
This section is empty.
Variables ¶
var ErrConnLost = errors.New("h3: connection ended before the response")
ErrConnLost is a request whose connection ended (the server closed it, it timed out, or reset) before the response's headers arrived: the server may or may not have processed it.
var ErrConnUnusable = errors.New("h3: connection cannot take the request")
ErrConnUnusable is a request the connection did not send: it is going away (the server's GOAWAY), or ended. Nothing of the request was sent, so it may go on another connection.
var ErrRejected = errors.New("h3: request rejected by the server")
ErrRejected is a request with a body the server did not process (its GOAWAY, or H3_REQUEST_REJECTED): it may go on another connection with a fresh copy of its body.
Functions ¶
func Head ¶
Head returns the field list a connection for p, to the alternative service at altHost and altPort (Options), sends for req (RoundTrip), pseudo-headers first, built as RoundTrip builds it. An error is one RoundTrip returns before sending anything.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a client HTTP/3 connection on a QUIC connection, speaking as the profile's browser does down to the order of its frames on the wire. It is safe for concurrent use.
func New ¶
New starts HTTP/3 on qc, which quic.Dial returned corked, for profile p, which has HTTP3 and QUIC sections. It opens the profile's handshake streams (after the request, for opts.Pending in 0-RTT where the profile sends it first) and serves the server's streams until qc ends.
func (*Conn) CanTakeNewRequest ¶
CanTakeNewRequest reports whether a new request may start on the connection: it has not ended, failed or received GOAWAY.
func (*Conn) Discard ¶
func (c *Conn) Discard()
Discard ends the connection without a word to the server, as a QUIC idle timeout ends it.
func (*Conn) Done ¶
func (c *Conn) Done() <-chan struct{}
Done is closed once the QUIC connection has ended.
func (*Conn) EarlyMethod ¶
EarlyMethod reports whether the profile sends a request with method in 0-RTT (HTTP3.EarlyData.Methods); others made during the handshake wait for it.
func (*Conn) IdleSince ¶
IdleSince reports when the connection's last request ended (or it started), and false while a request is in flight.
func (*Conn) OnClose ¶
func (c *Conn) OnClose(f func())
OnClose runs f once the QUIC connection has ended (Done is closed): at once, on the caller's goroutine, if it has; otherwise on the goroutine that sees it end. f runs with none of c's locks held.
func (*Conn) RoundTrip ¶
RoundTrip sends req on a new request stream and returns the response once its headers arrive; req's context bounds the whole exchange, body reads included. req.Body is closed, except with ErrConnUnusable, which leaves it for the retry. A 0-RTT request answered 425 Too Early goes again in 1-RTT where the profile retries it (HTTP3.EarlyData) and its body can be re-read.
type Options ¶
type Options struct {
// AltHost and AltPort are the alternative service the connection
// reaches (alt-used).
AltHost, AltPort string
// Pending: the connection was dialled for a request about to be sent,
// which goes before the control and QPACK streams in 0-RTT where the
// profile says so (Firefox).
Pending bool
// Clock times how long the connection has been idle (IdleSince); nil
// is the real clock.
Clock clockwork.Clock
}
Options are what a connection needs besides the QUIC connection and the profile.