transport

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: MIT Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateInvalid state = iota
	StateOk
	StateFailing
	StateDown
)

Variables

View Source
var HopHeaders = []string{
	"Connection",
	"Proxy-Connection",
	"Keep-Alive",
	"Proxy-Authenticate",
	"Proxy-Authorization",
	"Te",
	"Trailer",
	"Transfer-Encoding",
	"Upgrade",
}

HopHeaders Hop-by-hop headers. These are removed when sent to the backend. As of RFC 7230, hop-by-hop headers are required to appear in the Connection header field. These are the headers defined by the obsoleted RFC 2616 (section 13.5.1) and are used for backward compatibility.

Functions

func NewBackend

func NewBackend(ctx *hclsyntax.Body, tc *Config, opts *BackendOptions, log *logrus.Entry) http.RoundTripper

NewBackend creates a new <*Backend> object by the given <*Config>.

func NewProbe

func NewProbe(log *logrus.Entry, tc *Config, opts *config.HealthCheck, listener ProbeStateChange)

func NewTransport

func NewTransport(conf *Config, log *logrus.Entry) *http.Transport

NewTransport creates a new <*http.Transport> object by the given <*Config>.

func ReadCertificates

func ReadCertificates(conf *config.BackendTLS) (tls.Certificate, tls.Certificate, error)

ReadCertificates parses an optional CA certificate or a client certificate / key pair. It is valid to have just the client pair without the CA certificate since the system Root CAs or the related Couper cli option MAY configure the related transport too.

func RemoveConnectionHeaders

func RemoveConnectionHeaders(h http.Header)

RemoveConnectionHeaders removes hop-by-hop headers listed in the "Connection" header of h. See RFC 7230, section 6.1

func RemoveHopHeaders

func RemoveHopHeaders(header http.Header)

Types

type Backend

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

func (*Backend) OnProbeChange

func (b *Backend) OnProbeChange(info *HealthInfo)

func (*Backend) RoundTrip

func (b *Backend) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the <http.RoundTripper> interface.

func (*Backend) Value

func (b *Backend) Value() cty.Value

type BackendOptions

type BackendOptions struct {
	RequestAuthz []RequestAuthorizer
	HealthCheck  *config.HealthCheck
	OpenAPI      *validation.OpenAPIOptions
}

BackendOptions represents the transport <BackendOptions> object.

type Config

type Config struct {
	BackendName            string
	DisableCertValidation  bool
	DisableConnectionReuse bool
	HTTP2                  bool
	MaxConnections         int
	NoProxyFromEnv         bool
	Proxy                  string
	RateLimits             ratelimit.RateLimits

	ConnectTimeout time.Duration
	TTFBTimeout    time.Duration
	Timeout        time.Duration

	// TLS settings
	// Certificate is passed to all backends from the related cli option.
	Certificate []byte
	// CACertificate contains a per backend configured one.
	CACertificate tls.Certificate
	// ClientCertificate holds the one the backend will send during tls handshake if required.
	ClientCertificate tls.Certificate

	// Dynamic values
	Context  context.Context
	Hostname string
	Origin   string
	Scheme   string
}

Config represents the transport <Config> object.

func (*Config) WithTarget

func (c *Config) WithTarget(scheme, origin, hostname, proxyURL string) *Config

func (*Config) WithTimings

func (c *Config) WithTimings(connect, ttfb, timeout string, logger *logrus.Entry) *Config

type HealthInfo

type HealthInfo struct {
	Error   string
	Healthy bool
	Origin  string
	State   string
}

type OAuth2ReqAuth

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

OAuth2ReqAuth represents the transport <OAuth2ReqAuth> object.

func (*OAuth2ReqAuth) GetToken

func (oa *OAuth2ReqAuth) GetToken(req *http.Request) error

func (*OAuth2ReqAuth) RetryWithToken

func (oa *OAuth2ReqAuth) RetryWithToken(req *http.Request, res *http.Response) (bool, error)

type OriginConn

type OriginConn struct {
	net.Conn
	// contains filtered or unexported fields
}

OriginConn wraps the original net.Conn created by net.DialContext or transport.DialTLS for debug purposes.

func NewOriginConn

func NewOriginConn(ctx context.Context, conn net.Conn, conf *Config, entry *logrus.Entry) *OriginConn

NewOriginConn creates a new wrapper with logging context.

func (*OriginConn) Close

func (o *OriginConn) Close() error

type Probe

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

func (Probe) String

func (p Probe) String() string

type ProbeStateChange

type ProbeStateChange interface {
	OnProbeChange(info *HealthInfo)
}

type RequestAuthorizer

type RequestAuthorizer interface {
	GetToken(req *http.Request) error
	RetryWithToken(req *http.Request, res *http.Response) (bool, error)
	// contains filtered or unexported methods
}

func NewOAuth2ReqAuth

func NewOAuth2ReqAuth(evalCtx *hcl.EvalContext, conf *config.OAuth2ReqAuth, memStore *cache.MemoryStore,
	asBackend http.RoundTripper) (RequestAuthorizer, error)

NewOAuth2ReqAuth implements the http.RoundTripper interface to wrap an existing Backend / http.RoundTripper to retrieve a valid token before passing the initial out request.

func NewTokenRequest

func NewTokenRequest(conf *config.TokenRequest, memStore *cache.MemoryStore, reqProducer producer.Roundtrip) (RequestAuthorizer, error)

type TokenRequest

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

func (*TokenRequest) GetToken

func (t *TokenRequest) GetToken(req *http.Request) error

func (*TokenRequest) RetryWithToken

func (t *TokenRequest) RetryWithToken(_ *http.Request, _ *http.Response) (bool, error)

Jump to

Keyboard shortcuts

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