http

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebugRequest

func DebugRequest(req *http.Request) string

func DebugResponse

func DebugResponse(r *http.Response) string

func DrainBody

func DrainBody(b io.ReadCloser) (r1, r2 io.ReadCloser, err error)

https://golang.org/src/net/http/httputil/dump.go drainBody reads all of b to memory and then returns two equivalent ReadClosers yielding the same bytes.

It returns an error if the initial slurp of all bytes fails. It does not attempt to make the returned ReadClosers have identical error-matching behavior.

func NewBuilder

func NewBuilder() *mTLSClientBuilder

func NewMATLSClient

func NewMATLSClient(config MATLSConfig) (*http.Client, error)

NewMATLSClient creates a new http client that is configured for Mutually Authenticated TLS. `insecureSkipVerify` can be set to true if host certificates are not to be validated against a local trusted list of CA certificates. `caCerts` is an optional list of root CA certificates that can be used to validate host certificates. Can be set to nil if not required.

func RootCAPoolFromCerts

func RootCAPoolFromCerts(certs []*x509.Certificate) *x509.CertPool

func RootCASCertificate

func RootCASCertificate(pemBytes []byte) (*x509.Certificate, error)

func RootCASFromFile

func RootCASFromFile(path string) (*x509.Certificate, error)

func RootCAs

func RootCAs(cas []string) ([]*x509.Certificate, error)

func TlsCertFromFile

func TlsCertFromFile(keyPath, certPath string) ([]tls.Certificate, error)

func TlsClientCert

func TlsClientCert(certPEMBlock, keyPEMBlock []byte) ([]tls.Certificate, error)

Types

type MATLSClientBuilder

type MATLSClientBuilder interface {
	WithRootCAs(rootCAs []string) MATLSClientBuilder
	WithTransportKeyPair(certPEMBlock, keyPEMBlock string) MATLSClientBuilder
	Build() (*http.Client, error)
}

type MATLSConfig

type MATLSConfig struct {
	ClientCerts        []tls.Certificate
	InsecureSkipVerify bool
	RootCAs            []*x509.Certificate
	TLSMinVersion      uint16
}

Jump to

Keyboard shortcuts

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