4dc2907472
This diff is part of https://github.com/ooni/probe/issues/1505. You will notice that I have not adapted all the (great) tests we had previously. They should live at another layer, and namely the one that deals with performing measurements. When I'm refactoring such a layer I'll ensure those tests that I have not adapted here are reintroduced into the tree.
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
// Package httptransport contains HTTP transport extensions.
|
|
package httptransport
|
|
|
|
import (
|
|
"context"
|
|
"crypto/tls"
|
|
"net"
|
|
"net/http"
|
|
|
|
"github.com/lucas-clemente/quic-go"
|
|
)
|
|
|
|
// Config contains the configuration required for constructing an HTTP transport
|
|
type Config struct {
|
|
Dialer Dialer
|
|
QUICDialer QUICDialer
|
|
TLSDialer TLSDialer
|
|
TLSConfig *tls.Config
|
|
}
|
|
|
|
// Dialer is the definition of dialer assumed by this package.
|
|
type Dialer interface {
|
|
DialContext(ctx context.Context, network, address string) (net.Conn, error)
|
|
}
|
|
|
|
// TLSDialer is the definition of a TLS dialer assumed by this package.
|
|
type TLSDialer interface {
|
|
DialTLSContext(ctx context.Context, network, address string) (net.Conn, error)
|
|
}
|
|
|
|
// QUICDialer is the definition of dialer for QUIC assumed by this package.
|
|
type QUICDialer interface {
|
|
DialContext(ctx context.Context, network, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlySession, error)
|
|
}
|
|
|
|
// RoundTripper is the definition of http.RoundTripper used by this package.
|
|
type RoundTripper interface {
|
|
RoundTrip(req *http.Request) (*http.Response, error)
|
|
CloseIdleConnections()
|
|
}
|
|
|
|
// Resolver is the interface we expect from a resolver
|
|
type Resolver interface {
|
|
LookupHost(ctx context.Context, hostname string) (addrs []string, err error)
|
|
Network() string
|
|
Address() string
|
|
}
|