transport

package
v1.12.2 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 51 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 added in v1.9.0

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

func NewTransport added in v1.9.0

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

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

func ReadCertificates added in v1.11.0

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 added in v1.9.0

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 added in v1.9.0

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 added in v1.9.0

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

func (*Config) WithTimings added in v1.9.0

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

type HealthInfo added in v1.9.0

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 added in v1.10.0

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

func (*OAuth2ReqAuth) RetryWithToken added in v1.9.0

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 added in v1.9.0

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

func (Probe) String added in v1.9.0

func (p Probe) String() string

type ProbeStateChange added in v1.9.0

type ProbeStateChange interface {
	OnProbeChange(info *HealthInfo)
}

type RequestAuthorizer added in v1.10.0

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 added in v1.10.0

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

type TokenRequest added in v1.9.0

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

func (*TokenRequest) GetToken added in v1.10.0

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

func (*TokenRequest) RetryWithToken added in v1.9.0

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