fshttp

package
v1.66.5 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package fshttp contains the common http parts of the config, Transport and Client

Index

Constants

This section is empty.

Variables

View Source
var DefaultMetrics = (*Metrics)(nil)

DefaultMetrics specifies metrics used for new Transports.

Functions

func NewClient

func NewClient(ctx context.Context) *http.Client

NewClient returns an http.Client with the correct timeouts

func NewTransport

func NewTransport(ctx context.Context) http.RoundTripper

NewTransport returns an http.RoundTripper with the correct timeouts

func NewTransportCustom added in v1.6.1

func NewTransportCustom(ctx context.Context, customize func(*http.Transport)) http.RoundTripper

NewTransportCustom returns an http.RoundTripper with the correct timeouts. The customize function is called if set to give the caller an opportunity to customize any defaults in the Transport.

func ResetTransport added in v1.6.1

func ResetTransport()

ResetTransport resets the existing transport, allowing it to take new settings. Should only be used for testing.

Types

type Dialer added in v1.55.0

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

Dialer structure contains default dialer and timeout, tclass support

func NewDialer

func NewDialer(ctx context.Context) *Dialer

NewDialer creates a Dialer structure with Timeout, Keepalive, LocalAddr and DSCP set from rclone flags.

func (*Dialer) Dial added in v1.55.0

func (d *Dialer) Dial(network, address string) (net.Conn, error)

Dial connects to the network address.

func (*Dialer) DialContext added in v1.55.0

func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

DialContext connects to the network address using the provided context.

type Metrics added in v1.57.1

type Metrics struct {
	StatusCode *prometheus.CounterVec
}

Metrics provide Transport HTTP level metrics.

func NewMetrics added in v1.57.1

func NewMetrics(namespace string) *Metrics

NewMetrics creates a new metrics instance, the instance shall be assigned to DefaultMetrics before any processing takes place.

func (*Metrics) Collectors added in v1.57.1

func (m *Metrics) Collectors() []prometheus.Collector

Collectors returns all prometheus metrics as collectors for registration.

type Transport

type Transport struct {
	*http.Transport
	// contains filtered or unexported fields
}

Transport is our http Transport which wraps an http.Transport * Sets the User Agent * Does logging * Updates metrics

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (resp *http.Response, err error)

RoundTrip implements the RoundTripper interface.

func (*Transport) SetRequestFilter

func (t *Transport) SetRequestFilter(f func(req *http.Request))

SetRequestFilter sets a filter to be used on each request

Jump to

Keyboard shortcuts

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