h2quic

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2017 License: MIT Imports: 25 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

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

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.

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/2 requests on incoming connections. http.DefaultServeMux is used when handler is nil.

Types

type Client

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

Client is a HTTP2 client doing QUIC requests

func NewClient

func NewClient(t *QuicRoundTripper, tlsConfig *tls.Config, hostname string) *Client

NewClient creates a new client

func (*Client) Close

func (c *Client) Close(e error)

Close closes the client

func (*Client) Dial

func (c *Client) Dial() error

Dial dials the connection

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do executes a request and returns a response

type QuicRoundTripper

type QuicRoundTripper 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
	// contains filtered or unexported fields
}

QuicRoundTripper implements the http.RoundTripper interface

func (*QuicRoundTripper) RoundTrip

func (r *QuicRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip does a round trip

type Server

type Server struct {
	*http.Server

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

func (s *Server) Close() error

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

func (s *Server) CloseGracefully(timeout time.Duration) error

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

func (s *Server) ListenAndServe() error

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

func (*Server) ListenAndServeTLS

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

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.UDPConn) error

Serve an existing UDP 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 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):

Alternate-Protocol: 443:quic
Alt-Svc: quic=":443"; ma=2592000; v="33,32,31,30"

Jump to

Keyboard shortcuts

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