http3

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 32 Imported by: 6

README

HTTP/3

Documentation PkgGoDev

This package implements HTTP/3 (RFC 9114), including QPACK (RFC 9204) and HTTP Datagrams (RFC 9297). It aims to provide feature parity with the standard library's HTTP/1.1 and HTTP/2 implementation.

Detailed documentation can be found on quic-go.net.

Documentation

Index

Constants

View Source
const (
	// MethodGet0RTT allows a GET request to be sent using 0-RTT.
	// Note that 0-RTT doesn't provide replay protection and should only be used for idempotent requests.
	MethodGet0RTT = "GET_0RTT"
	// MethodHead0RTT allows a HEAD request to be sent using 0-RTT.
	// Note that 0-RTT doesn't provide replay protection and should only be used for idempotent requests.
	MethodHead0RTT = "HEAD_0RTT"
)
View Source
const (
	// QPACK maximum table capacity, RFC 9204
	SettingQpackMaxTableCapacity = 0x1
	// Maximum field section size, RFC 9114
	SettingMaxFieldSectionSize = 0x6
	// QPACK blocked streams, RFC 9204
	SettingQpackBlockedStreams = 0x7
	// Extended CONNECT, RFC 9220
	SettingExtendedConnect = 0x8
	// HTTP Datagrams, RFC 9297
	SettingH3Datagram = 0x33
	// Enable Metadata, draft-beky-httpbis-metadata-02
	SettingEnableMetadata = 0x4d44
	// GREASE identifier, draft-edm-protocol-greasing-05
	SettingGrease = 0x1f*1 + 0x21
)

Exported setting identifiers, used by callers that want full control over the SETTINGS frame (contents and order) for fingerprinting purposes.

View Source
const CapsuleProtocolHeader = "Capsule-Protocol"

CapsuleProtocolHeader is the header value used to advertise support for the capsule protocol

View Source
const NextProtoH3 = "h3"

NextProtoH3 is the ALPN protocol negotiated during the TLS handshake, for QUIC v1 and v2.

Variables

View Source
var (
	// ErrNoCachedConn is returned by [Transport.RoundTripOpt] when [RoundTripOpt.OnlyCachedConn]
	// is true and no cached connection is available.
	ErrNoCachedConn = errors.New("http3: no cached connection was available")
	// ErrTransportClosed is returned by [Transport.RoundTrip] and [Transport.RoundTripOpt]
	// after the transport is closed.
	ErrTransportClosed = errors.New("http3: transport is closed")
)
View Source
var ErrNoAltSvcPort = errors.New("no port can be announced, specify it explicitly using Server.Port or Server.Addr")

ErrNoAltSvcPort is returned by Server.SetQUICHeaders when no port was found for Alt-Svc to announce. This can happen if listening on a net.PacketConn without a port (UNIX socket, for example) and no port is specified in Server.Port or Server.Addr.

View Source
var RemoteAddrContextKey = &contextKey{"remote-addr"}

RemoteAddrContextKey is a context key. It can be used in HTTP handlers with context.Context.Value to access the remote address of the connection. The associated value will be of type net.Addr.

Use this value instead of http.Request.RemoteAddr if you require access to the remote address of the connection rather than its string representation.

View Source
var ServerContextKey = &contextKey{"http3-server"}

ServerContextKey is a context key. It can be used in HTTP handlers with context.Context.Value to access the server that started the handler. The associated value will be of type *Server.

Functions

func ConfigureTLSConfig

func ConfigureTLSConfig(tlsConf *tls.Config) *tls.Config

ConfigureTLSConfig creates a new tls.Config which can be used to create a quic.Listener meant for serving HTTP/3.

func ListenAndServeQUIC

func ListenAndServeQUIC(addr, certFile, keyFile string, handler http.Handler) error

ListenAndServeQUIC listens on the UDP network address addr and calls the handler for HTTP/3 requests on incoming connections. http.DefaultServeMux is used when handler is nil.

func ListenAndServeTLS

func ListenAndServeTLS(addr, certFile, keyFile string, handler http.Handler) error

ListenAndServeTLS listens on the given network address for both TLS/TCP and QUIC connections 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.

func WriteCapsule

func WriteCapsule(w quicvarint.Writer, ct CapsuleType, value []byte) error

WriteCapsule writes a capsule

Types

type CapsuleParser added in v1.2.0

type CapsuleParser struct {
	// contains filtered or unexported fields
}

CapsuleParser parses a sequence of capsules. A capsule's contents must be fully consumed or discarded before calling CapsuleParser.Next again.

func NewCapsuleParser added in v1.2.0

func NewCapsuleParser(r io.Reader) *CapsuleParser

NewCapsuleParser creates a parser that reads capsules from r.

func (*CapsuleParser) Next added in v1.2.0

Next returns the type and contents of the next capsule. The previous capsule's contents must be fully consumed or discarded before calling this method again.

type CapsuleReader added in v1.2.0

type CapsuleReader struct {
	// contains filtered or unexported fields
}

CapsuleReader reads the contents of a capsule. It becomes invalid after CapsuleParser.Next successfully advances to the next capsule.

func (CapsuleReader) Discard added in v1.2.0

func (r CapsuleReader) Discard() error

Discard consumes the remaining capsule contents.

func (CapsuleReader) Read added in v1.2.0

func (r CapsuleReader) Read(b []byte) (int, error)

Read reads from the capsule contents.

func (CapsuleReader) ReadByte added in v1.2.0

func (r CapsuleReader) ReadByte() (byte, error)

ReadByte reads one byte from the capsule contents.

func (CapsuleReader) Remaining added in v1.2.0

func (r CapsuleReader) Remaining() int64

Remaining returns the number of bytes remaining in the capsule.

type CapsuleType

type CapsuleType uint64

CapsuleType is the type of the capsule

type ClientConn

type ClientConn struct {
	// contains filtered or unexported fields
}

ClientConn is an HTTP/3 client doing requests to a single remote server.

func (*ClientConn) CloseWithError

func (c *ClientConn) CloseWithError(code quic.ApplicationErrorCode, msg string) error

CloseWithError closes the connection with the given error code and message. It is invalid to call this function after the connection was closed.

func (*ClientConn) Context

func (c *ClientConn) Context() context.Context

Context returns a context that is cancelled when the connection is closed.

func (*ClientConn) HandleBidirectionalStream added in v1.1.0

func (c *ClientConn) HandleBidirectionalStream(str *quic.Stream)

HandleBidirectionalStream handles an incoming bidirectional stream.

func (*ClientConn) OpenRequestStream

func (c *ClientConn) OpenRequestStream(ctx context.Context) (*RequestStream, error)

OpenRequestStream opens a new request stream on the HTTP/3 connection.

func (*ClientConn) ReceivedSettings

func (c *ClientConn) ReceivedSettings() <-chan struct{}

ReceivedSettings returns a channel that is closed once the server's HTTP/3 settings were received. The settings can be obtained from ClientConn.Settings after the channel is closed.

func (*ClientConn) RoundTrip

func (c *ClientConn) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a request and returns a response

func (*ClientConn) Settings

func (c *ClientConn) Settings() *Settings

Settings returns the HTTP/3 settings for this connection. It is only valid to call this method after the channel returned by ClientConn.ReceivedSettings is closed.

type ErrCode

type ErrCode quic.ApplicationErrorCode
const (
	ErrCodeNoError                  ErrCode = 0x100
	ErrCodeGeneralProtocolError     ErrCode = 0x101
	ErrCodeInternalError            ErrCode = 0x102
	ErrCodeStreamCreationError      ErrCode = 0x103
	ErrCodeClosedCriticalStream     ErrCode = 0x104
	ErrCodeFrameUnexpected          ErrCode = 0x105
	ErrCodeFrameError               ErrCode = 0x106
	ErrCodeExcessiveLoad            ErrCode = 0x107
	ErrCodeIDError                  ErrCode = 0x108
	ErrCodeSettingsError            ErrCode = 0x109
	ErrCodeMissingSettings          ErrCode = 0x10a
	ErrCodeRequestRejected          ErrCode = 0x10b
	ErrCodeRequestCanceled          ErrCode = 0x10c
	ErrCodeRequestIncomplete        ErrCode = 0x10d
	ErrCodeMessageError             ErrCode = 0x10e
	ErrCodeConnectError             ErrCode = 0x10f
	ErrCodeVersionFallback          ErrCode = 0x110
	ErrCodeDatagramError            ErrCode = 0x33
	ErrCodeQPACKDecompressionFailed ErrCode = 0x200
)

func (ErrCode) String

func (e ErrCode) String() string

type Error

type Error struct {
	Remote       bool
	ErrorCode    ErrCode
	ErrorMessage string
}

Error is returned by Transport.RoundTrip, Transport.RoundTripOpt, and ClientConn.RoundTrip for HTTP clients, and from request-body reads and response writes inside HTTP handlers for HTTP servers, when an HTTP/3 error occurs. See section 8 of RFC 9114.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

type FrameType

type FrameType uint64

FrameType is the frame type of a HTTP/3 frame

type HTTPStreamer

type HTTPStreamer interface {
	HTTPStream() *Stream
}

HTTPStreamer allows an HTTP handler to take over an HTTP/3 stream. It is implemented by the http.ResponseWriter passed to HTTP/3 handlers. When a stream is taken over, it's the caller's responsibility to close the stream.

type QUICListener

type QUICListener interface {
	Accept(context.Context) (*quic.Conn, error)
	Addr() net.Addr
	io.Closer
}

A QUICListener listens for incoming QUIC connections.

type RawClientConn added in v1.1.0

type RawClientConn struct {
	*ClientConn
}

RawClientConn is a low-level HTTP/3 client connection. It allows the application to take control of the stream accept loops, giving the application the ability to handle streams originating from the server.

func (*RawClientConn) HandleUnidirectionalStream added in v1.1.0

func (c *RawClientConn) HandleUnidirectionalStream(str *quic.ReceiveStream)

HandleUnidirectionalStream handles an incoming unidirectional stream.

type RawServerConn added in v1.1.0

type RawServerConn struct {
	// contains filtered or unexported fields
}

RawServerConn is an HTTP/3 server connection. It can be used for advanced use cases where the application wants to manage the QUIC connection lifecycle.

func (*RawServerConn) CloseWithError added in v1.1.0

func (c *RawServerConn) CloseWithError(code quic.ApplicationErrorCode, msg string) error

CloseWithError closes the connection with the given error code and message.

func (*RawServerConn) HandleRequestStream added in v1.1.0

func (c *RawServerConn) HandleRequestStream(str *quic.Stream)

HandleRequestStream handles an HTTP/3 request on a bidirectional request stream. The stream can either be obtained by calling quic.Conn.AcceptStream on the underlying QUIC connection, or (internally) by using the server's stream accept loop.

func (*RawServerConn) HandleUnidirectionalStream added in v1.1.0

func (c *RawServerConn) HandleUnidirectionalStream(str *quic.ReceiveStream)

HandleUnidirectionalStream handles an incoming unidirectional stream.

type RequestStream

type RequestStream struct {
	// contains filtered or unexported fields
}

A RequestStream is a low-level abstraction representing an HTTP/3 request stream. It decouples sending of the HTTP request from reading the HTTP response, allowing the application to optimistically use the stream (and, for example, send datagrams) before receiving the response.

This is only needed for advanced use case, e.g. WebTransport and the various MASQUE proxying protocols.

func (*RequestStream) CancelRead

func (s *RequestStream) CancelRead(errorCode quic.StreamErrorCode)

CancelRead aborts receiving on this stream. See quic.Stream.CancelRead for more details.

func (*RequestStream) CancelWrite

func (s *RequestStream) CancelWrite(errorCode quic.StreamErrorCode)

CancelWrite aborts sending on this stream. See quic.Stream.CancelWrite for more details.

func (*RequestStream) Close

func (s *RequestStream) Close() error

Close closes the send-direction of the stream. It does not close the receive-direction of the stream.

func (*RequestStream) Context

func (s *RequestStream) Context() context.Context

Context returns a context derived from the underlying QUIC stream's context. See quic.Stream.Context for more details.

func (*RequestStream) Read

func (s *RequestStream) Read(b []byte) (int, error)

Read reads data from the underlying stream.

It can only be used after the request has been sent using RequestStream.SendRequestHeader and RequestStream.ReadResponse has returned the response.

func (*RequestStream) ReadResponse

func (s *RequestStream) ReadResponse() (*http.Response, error)

ReadResponse reads the HTTP response from the stream.

It must be called after sending the request using RequestStream.SendRequestHeader. It is invalid to call it more than once. It doesn't set http.Response.Request or http.Response.TLS.

func (*RequestStream) ReceiveDatagram

func (s *RequestStream) ReceiveDatagram(ctx context.Context) ([]byte, error)

ReceiveDatagram receives HTTP Datagrams (RFC 9297).

It is only possible if HTTP Datagram support was enabled using Transport.EnableDatagrams.

func (*RequestStream) SendDatagram

func (s *RequestStream) SendDatagram(b []byte) error

SendDatagram sends a new HTTP Datagram (RFC 9297).

It is only possible to send datagrams if the server enabled support for this extension. It is recommended (though not required) to send the request before calling this method, as the server might drop datagrams which it can't associate with an existing request.

func (*RequestStream) SendRequestHeader

func (s *RequestStream) SendRequestHeader(req *http.Request) error

SendRequestHeader sends the HTTP request.

It can only be used for requests that don't have a request body. It is invalid to call it more than once.

func (*RequestStream) SetDeadline

func (s *RequestStream) SetDeadline(t time.Time) error

SetDeadline sets the read and write deadlines associated with the stream. It is equivalent to calling both RequestStream.SetReadDeadline and RequestStream.SetWriteDeadline.

func (*RequestStream) SetReadDeadline

func (s *RequestStream) SetReadDeadline(t time.Time) error

SetReadDeadline sets the deadline for RequestStream.Read calls.

func (*RequestStream) SetWriteDeadline

func (s *RequestStream) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the deadline for RequestStream.Write calls.

func (*RequestStream) StreamID

func (s *RequestStream) StreamID() quic.StreamID

StreamID returns the QUIC stream ID of the underlying QUIC stream.

func (*RequestStream) TryWriteAll added in v1.2.0

func (s *RequestStream) TryWriteAll(b []byte) error

TryWriteAll writes b if the entire DATA frame can be queued immediately. It can only be used after the request has been sent using RequestStream.SendRequestHeader.

func (*RequestStream) Write

func (s *RequestStream) Write(b []byte) (int, error)

Write writes data to the stream.

It can only be used after the request has been sent using RequestStream.SendRequestHeader.

type RoundTripOpt

type RoundTripOpt struct {
	// OnlyCachedConn controls whether the Transport may create a new QUIC connection.
	// If true and no cached connection is available, [Transport.RoundTripOpt] returns [ErrNoCachedConn].
	OnlyCachedConn bool
}

RoundTripOpt contains options for Transport.RoundTripOpt.

type Server

type Server struct {
	// Addr optionally specifies the UDP address for the server to listen on,
	// in the form "host:port".
	//
	// When used by [Server.ListenAndServe] and [Server.ListenAndServeTLS], if empty,
	// ":https" (port 443) is used. See [net.Dial] for details of the address
	// format.
	//
	// Otherwise, if Port is not set and underlying QUIC listeners do not
	// have valid port numbers, the port part is used in Alt-Svc headers set
	// with [Server.SetQUICHeaders].
	Addr string

	// Port is used in Alt-Svc response headers set with [Server.SetQUICHeaders]. If
	// needed Port can be manually set when the Server is created.
	//
	// This is useful when a Layer 4 firewall is redirecting UDP traffic and
	// clients must use a port different from the port the Server is
	// listening on.
	Port int

	// TLSConfig provides a TLS configuration for use by server. It must be
	// set for [Server.ListenAndServe] and [Server.Serve].
	TLSConfig *tls.Config

	// QUICConfig provides the parameters for QUIC connections created with [Server.Serve].
	// If nil, it uses reasonable default values.
	QUICConfig *quic.Config

	// Handler is the HTTP request handler. If nil, [http.DefaultServeMux] is used.
	Handler http.Handler

	// EnableDatagrams enables support for HTTP/3 datagrams (RFC 9297).
	// For connections created by the server, this also enables [quic.Config.EnableDatagrams].
	EnableDatagrams bool

	// MaxHeaderBytes controls the maximum number of bytes the server will
	// read parsing the request HEADERS frame. It does not limit the size of
	// the request body. If zero or negative, [http.DefaultMaxHeaderBytes] is
	// used.
	MaxHeaderBytes int

	// AdditionalSettings specifies additional HTTP/3 settings.
	// It is invalid to specify any settings defined by RFC 9114 (HTTP/3) and RFC 9297 (HTTP Datagrams).
	AdditionalSettings map[uint64]uint64

	// IdleTimeout specifies how long until idle clients connection should be
	// closed. Idle refers only to the HTTP/3 layer, activity at the QUIC layer
	// like PING frames are not considered.
	// If zero or negative, there is no timeout.
	IdleTimeout time.Duration

	// ConnContext optionally specifies a function that modifies the context used for a new connection c.
	// The provided ctx has a ServerContextKey value.
	ConnContext func(ctx context.Context, c *quic.Conn) context.Context

	Logger *slog.Logger
	// contains filtered or unexported fields
}

Server is a HTTP/3 server.

func (*Server) Close

func (s *Server) Close() error

Close closes the server immediately, aborting requests and sending CONNECTION_CLOSE frames to connected clients. Calling Close concurrently with Server.ListenAndServe may race with UDP socket creation; use Server.Serve to avoid this. It is the caller's responsibility to close any connection passed to Server.ServeQUICConn.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe listens on the UDP address Server.Addr and calls Server.Handler to handle HTTP/3 requests on incoming connections.

If Server.Addr is blank, ":https" is used.

func (*Server) ListenAndServeTLS

func (s *Server) ListenAndServeTLS(certFile, keyFile string) error

ListenAndServeTLS listens on the UDP address Server.Addr and calls Server.Handler to handle HTTP/3 requests on incoming connections.

If Server.Addr is blank, ":https" is used.

func (*Server) NewRawServerConn added in v1.1.0

func (s *Server) NewRawServerConn(conn *quic.Conn) (*RawServerConn, error)

func (*Server) Serve

func (s *Server) Serve(conn net.PacketConn) error

Serve an existing UDP connection. It is possible to reuse the same connection for outgoing connections. Closing the server does not close the connection.

func (*Server) ServeListener

func (s *Server) ServeListener(ln QUICListener) error

ServeListener serves an existing QUIC listener. Use ConfigureTLSConfig to configure a tls.Config for the QUIC listener. Closing the server does not close the listener; closing the listener is the application's responsibility. ServeListener always returns a non-nil error. After Server.Shutdown or Server.Close, it returns http.ErrServerClosed.

func (*Server) ServeQUICConn

func (s *Server) ServeQUICConn(conn *quic.Conn) error

ServeQUICConn serves a single QUIC connection.

func (*Server) SetQUICHeaders

func (s *Server) SetQUICHeaders(hdr http.Header) error

SetQUICHeaders can be used to set the proper headers that announce that this server supports HTTP/3. The values set by default advertise all the ports the server is listening on, but can be changed to a specific port by setting Server.Port before launching the server. If none of the server's listeners report a valid port through QUICListener.Addr, Server.Addr is used to extract the port, if specified. For example, a server launched using Server.ListenAndServe on an address with port 443 would set:

Alt-Svc: h3=":443"; ma=2592000

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the server without interrupting any active connections. The server sends a GOAWAY frame first, then waits for all running requests to complete. Calling Shutdown concurrently with Server.ListenAndServe may race with UDP socket creation; use Server.Serve to avoid this.

type Setting added in v1.0.1

type Setting struct {
	ID  uint64
	Val uint64
}

type Settings

type Settings struct {
	// Support for HTTP/3 datagrams (RFC 9297)
	EnableDatagrams bool
	// Extended CONNECT, RFC 9220
	EnableExtendedConnect bool
	// Other settings, defined by the application
	Other map[uint64]uint64
}

Settings are HTTP/3 settings that apply to the underlying connection.

type Settingser added in v1.1.0

type Settingser interface {
	// ReceivedSettings returns a channel that is closed once the peer's SETTINGS frame was received.
	// The settings can be obtained from [Settingser.Settings] after the channel is closed.
	ReceivedSettings() <-chan struct{}
	// Settings returns the settings received on this connection.
	// It is only valid to call this method after the channel returned by [Settingser.ReceivedSettings] is closed.
	Settings() *Settings
}

Settingser allows waiting for and retrieving the peer's HTTP/3 settings.

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

A Stream is an HTTP/3 stream.

When writing to and reading from the stream, data is framed in HTTP/3 DATA frames.

func (*Stream) Read

func (s *Stream) Read(b []byte) (int, error)

func (*Stream) ReceiveDatagram

func (s *Stream) ReceiveDatagram(ctx context.Context) ([]byte, error)

func (*Stream) SendDatagram

func (s *Stream) SendDatagram(b []byte) error

func (*Stream) StreamID

func (s *Stream) StreamID() quic.StreamID

func (*Stream) TryWriteAll added in v1.2.0

func (s *Stream) TryWriteAll(b []byte) error

TryWriteAll writes b in a DATA frame if the entire frame can be queued immediately. It returns quic.ErrWouldBlock without queueing anything otherwise.

func (*Stream) Write

func (s *Stream) Write(b []byte) (int, error)

type StreamType

type StreamType uint64

StreamType is the stream type of a unidirectional stream.

type Transport

type Transport struct {
	// 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

	// Dial specifies an optional dial function for creating QUIC
	// connections for requests.
	// If [Transport.Dial] is nil, a [net.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.Conn, error)

	// Enable support for HTTP/3 datagrams (RFC 9297).
	// If [Transport.QUICConfig] is set, [quic.Config.EnableDatagrams] must also be enabled.
	EnableDatagrams bool

	// Additional HTTP/3 settings.
	// It is invalid to specify any settings defined by RFC 9114 (HTTP/3) and RFC 9297 (HTTP Datagrams).
	AdditionalSettings map[uint64]uint64

	// AdditionalSettingsOrder specifies the order in which the settings in
	// AdditionalSettings are sent in the SETTINGS frame. Settings not listed here
	// are not sent. If nil, the settings are sent in map iteration order.
	AdditionalSettingsOrder []uint64

	// PseudoHeaderOrder specifies the order in which the request pseudo-header
	// fields (:authority, :method, :path, :scheme, :protocol) are sent.
	// If nil, the default order is used.
	PseudoHeaderOrder []string

	// MaxResponseHeaderBytes specifies a limit on how many response bytes are
	// allowed in the server's response header.
	// Zero means to use a default limit.
	MaxResponseHeaderBytes int

	// 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

	Logger *slog.Logger
	// contains filtered or unexported fields
}

Transport implements the http.RoundTripper interface.

func (*Transport) Close

func (t *Transport) Close() error

Close closes the QUIC connections that this Transport has used. A Transport cannot be used after it has been closed.

func (*Transport) CloseIdleConnections

func (t *Transport) CloseIdleConnections()

CloseIdleConnections closes any QUIC connections in the transport's pool that are currently idle. An idle connection is one that was previously used for requests but is now sitting unused. This method does not interrupt any connections currently in use. It also does not affect connections obtained via Transport.NewClientConn.

func (*Transport) NewClientConn

func (t *Transport) NewClientConn(conn *quic.Conn) *ClientConn

NewClientConn creates a new HTTP/3 client connection on top of a QUIC connection. Most users should use Transport.RoundTrip instead of creating a connection directly. Specifically, it is not needed to perform GET, POST, HEAD and CONNECT requests.

Obtaining a ClientConn is only needed for more advanced use cases, such as using Extended CONNECT for WebTransport or the various MASQUE protocols.

func (*Transport) NewRawClientConn added in v1.1.0

func (t *Transport) NewRawClientConn(conn *quic.Conn) *RawClientConn

NewRawClientConn creates a new low-level HTTP/3 client connection on top of a QUIC connection. Unlike Transport.NewClientConn, the returned RawClientConn allows the application to take control of the stream accept loops by calling RawClientConn.HandleUnidirectionalStream for incoming unidirectional streams and ClientConn.HandleBidirectionalStream for incoming bidirectional streams.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip does a round trip.

func (*Transport) RoundTripOpt

func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Response, error)

RoundTripOpt is like Transport.RoundTrip, but takes options.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址