httptransport

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2020 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package httptransport contains HTTP transport extensions. Here we define a http.Transport that emits events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSystemTransport

func NewSystemTransport(dialer Dialer, tlsDialer TLSDialer) *http.Transport

NewSystemTransport creates a new "system" HTTP transport. That is a transport using the Go standard library with custom dialer and TLS dialer.

Types

type ByteCountingTransport

type ByteCountingTransport struct {
	RoundTripper
	Counter *bytecounter.Counter
}

ByteCountingTransport is a RoundTripper that counts bytes.

func (ByteCountingTransport) RoundTrip

func (txp ByteCountingTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements RoundTripper.RoundTrip

type Config

type Config struct {
	BogonIsError        bool                 // default: bogon is not error
	ByteCounter         *bytecounter.Counter // default: no explicit byte counting
	CacheResolutions    bool                 // default: no caching
	ContextByteCounting bool                 // default: no implicit byte counting
	Dialer              Dialer               // default: dialer.DNSDialer
	Logger              Logger               // default: no logging
	ProxyURL            *url.URL             // default: no proxy
	Resolver            Resolver             // default: system resolver
	Saver               *trace.Saver         // default: no saver
	TLSConfig           *tls.Config          // default: attempt using h2
	TLSDialer           TLSDialer            // default: dialer.TLSDialer
}

Config contains configuration for creating a new transport. When any field of Config is nil/empty, we will use a suitable default.

type Dialer

type Dialer interface {
	DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

Dialer is the definition of dialer assumed by this package.

type Logger

type Logger interface {
	Debugf(format string, v ...interface{})
	Debug(message string)
}

Logger is the logger assumed by this package

type LoggingTransport

type LoggingTransport struct {
	RoundTripper
	Logger Logger
}

LoggingTransport is a logging transport

func (LoggingTransport) RoundTrip

func (txp LoggingTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements RoundTripper.RoundTrip

type Resolver

type Resolver interface {
	LookupHost(ctx context.Context, hostname string) (addrs []string, err error)
	Network() string
	Address() string
}

Resolver is the interface we expect from a resolver

type RoundTripper

type RoundTripper interface {
	RoundTrip(req *http.Request) (*http.Response, error)
	CloseIdleConnections()
}

RoundTripper is the definition of http.RoundTripper used by this package.

func New

func New(config Config) RoundTripper

New creates a new RoundTripper. You can further extend the returned RoundTripper before wrapping it into an http.Client.

type SaverHTTPTransport added in v0.10.0

type SaverHTTPTransport struct {
	RoundTripper
	Saver *trace.Saver
}

SaverHTTPTransport is a RoundTripper that saves events

func (SaverHTTPTransport) RoundTrip added in v0.10.0

func (txp SaverHTTPTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements RoundTripper.RoundTrip

type TLSDialer

type TLSDialer interface {
	DialTLSContext(ctx context.Context, network, address string) (net.Conn, error)
}

TLSDialer is the definition of a TLS dialer assumed by this package.

type UserAgentTransport

type UserAgentTransport struct {
	RoundTripper
}

UserAgentTransport is a transport that ensures that we always set an OONI specific default User-Agent header.

func (UserAgentTransport) RoundTrip

func (txp UserAgentTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements RoundTripper.RoundTrip

Jump to

Keyboard shortcuts

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