websocket

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Negotiate

func Negotiate(rt http.RoundTripper, connectionInfo ConnectionHolder, req *http.Request, protocols ...string) (*gwebsocket.Conn, error)

Negotiate opens a connection to a remote server and attempts to negotiate a WebSocket connection. Upon success, it returns the negotiated connection. The round tripper rt must use the WebSocket round tripper wsRt - see RoundTripperFor.

Types

type ConnectionHolder

type ConnectionHolder interface {
	DataBufferSize() int
	Connection() *gwebsocket.Conn
}

ConnectionHolder defines functions for structure providing access to the websocket connection.

func RoundTripperFor

func RoundTripperFor(config *restclient.Config) (http.RoundTripper, ConnectionHolder, error)

RoundTripperFor transforms the passed rest config into a wrapped roundtripper, as well as a pointer to the websocket RoundTripper. The websocket RoundTripper contains the websocket connection after RoundTrip() on the wrapper. Returns an error if there is a problem creating the round trippers.

type RoundTripper

type RoundTripper struct {
	// TLSConfig holds the TLS configuration settings to use when connecting
	// to the remote server.
	TLSConfig *tls.Config

	// Proxier specifies a function to return a proxy for a given
	// Request. If the function returns a non-nil error, the
	// request is aborted with the provided error.
	// If Proxy is nil or returns a nil *URL, no proxy is used.
	Proxier func(req *http.Request) (*url.URL, error)

	// Conn holds the WebSocket connection after a round trip.
	Conn *gwebsocket.Conn
}

RoundTripper knows how to establish a connection to a remote WebSocket endpoint and make it available for use. RoundTripper must not be reused.

func (*RoundTripper) Connection

func (rt *RoundTripper) Connection() *gwebsocket.Conn

Connection returns the stored websocket connection.

func (*RoundTripper) DataBufferSize

func (rt *RoundTripper) DataBufferSize() int

DataBufferSize returns the size of buffers for the websocket connection.

func (*RoundTripper) RoundTrip

func (rt *RoundTripper) RoundTrip(request *http.Request) (retResp *http.Response, retErr error)

RoundTrip connects to the remote websocket using the headers in the request and the TLS configuration from the config

func (*RoundTripper) TLSClientConfig

func (rt *RoundTripper) TLSClientConfig() *tls.Config

TLSClientConfig implements pkg/util/net.TLSClientConfigHolder.

Jump to

Keyboard shortcuts

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