Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrHTTP3NotSupported = fmt.Errorf("HTTP3 not supported")
ErrHTTP3NotSupported is returned by Accept if the client connection does not support HTTP3 connection. The server than can response to the client with an HTTP1.1 as he wishes.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // Method sets the HTTP method for the dial // The default method, if not set, is HTTP POST. Method string // Header enables sending custom headers to the server Header http.Header // Client is a custom HTTP client to be used for the connection. // The client must have an http3.Transport as it's transport. Client *http.Client }
Client provides HTTP3 client side connection with special arguments
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is client/server symmetric connection. It implements the io.Reader/io.Writer/io.Closer to read/write or close the connection to the other side. It also has a Send/Recv function to use channels to communicate with the other side.
func Accept ¶
Accept is used on a server http.Handler to extract a full-duplex communication object with the client. The server connection will be closed when the http handler function will return. If the client does not support HTTP3, an ErrHTTP3NotSupported is returned.
Usage:
func (w http.ResponseWriter, r *http.Request) { conn, err := h2conn.Accept(w, r) if err != nil { log.Printf("Failed creating http3 connection: %s", err) http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) return } // use conn }
func Connect ¶
Connect establishes a full duplex communication with an HTTP3 server.
Usage:
conn, resp, err := h2conn.Connect(ctx, url) if err != nil { log.Fatalf("Initiate client: %s", err) } if resp.StatusCode != http.StatusOK { log.Fatalf("Bad status code: %d", resp.StatusCode) } defer conn.Close() // use conn