Documentation
¶
Index ¶
Constants ¶
View Source
const ( // TunnelWebSocketProtocol is a subprotocol that allows client and server recognize each other. // See https://datatracker.ietf.org/doc/html/rfc6455#section-11.3.4 TunnelWebSocketProtocol = "ws-tunnel" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HttpHandler ¶
type HttpHandler struct { Ctx context.Context ServerName string AcceptOptions websocket.AcceptOptions Sink chan<- net.Conn // ReadLimit. Optional. See websocket.Conn.SetReadLimit(). ReadLimit int64 }
func (*HttpHandler) ServeHTTP ¶
func (h *HttpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ListenerWrapper ¶
type ListenerWrapper struct { AcceptOptions websocket.AcceptOptions // ReadLimit. Optional. See websocket.Conn.SetReadLimit(). ReadLimit int64 ServerName string ReadTimeout time.Duration ReadHeaderTimeout time.Duration WriteTimeout time.Duration IdleTimeout time.Duration MaxHeaderBytes int ConnState func(net.Conn, http.ConnState) ErrorLog *log.Logger BaseContext func(net.Listener) context.Context ConnContext func(ctx context.Context, c net.Conn) context.Context }
ListenerWrapper does two things:
- HTTP/1.1 connections are expected to contain WebSocket upgrade request. Such connections are turned into TCP streams and returned from Accept(). This mode can be used for tunneling an HTTP/2 protocol via a WebSocket connection.
- HTTP/2 connections are returned from Accept() as is.
There are two modes of operation - with and without TLS. Whether connection is HTTP/1.1 or HTTP/2 is determined by looking at: - TLS: what protocol was negotiated via ALPN. h2 means HTTP/2, everything else is considered HTTP/1.1. - Cleartext: if byte stream contains the standard h2 client preface then it's an HTTP/2 connection, HTTP/1.1 otherwise. See https://httpwg.org/specs/rfc9113.html#preface. See https://www.rfc-editor.org/rfc/rfc7301.html.
Click to show internal directories.
Click to hide internal directories.