http

package
v0.0.0-...-910450c Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

This is a derived work based on `code.google.com/p/mlab-ns2/gae/ns/digest` (original work of Bipasa Chattopadhyay bipasa@cs.unc.edu Eric Gavaletz gavaletz@gmail.com Seon-Wook Park seon.wook@swook.net, from the fork maintained by Bob Ziuchkovski @bobziuchkovski (https://github.com/rkl-/digest).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(cfg ClientConfig) (*http.Client, error)

NewClient instantiates a new `http.Client` based on the client configuration supplied.

func WithCACert

func WithCACert(fpath string) func(*tls.Config) error

func WithClientCertificate

func WithClientCertificate(cert, key string) func(*tls.Config) error

func WithInsecureSkipVerify

func WithInsecureSkipVerify() func(*tls.Config)

func WithTransport

func WithTransport(rt http.RoundTripper) func(*http.Client)

Types

type ClientConfig

type ClientConfig struct {
	// TLSSkipVerify indicates that the client should not perform any
	// hostname or certificate chain of trust validations.
	//
	TLSSkipVerify bool

	// TLSClientCert is the path to a TLS client certificate to be used
	// when connecting to a TLS server.
	//
	// ps.: must be supplied together with TLSClientKey.
	//
	TLSClientCert string

	// TLSClientKey is the path to a TLS private key certificate to be used
	// when connecting to a TLS server.
	//
	// ps.: must be supplied together with TLSClientCert.
	//
	TLSClientKey string

	// TLSCACert is the path to a certificate authority certificate that
	// should be included in the chain of trust.
	//
	TLSCACert string

	// Verbose dictates whether the transport should dump all request and
	// response information to stderr.
	//
	Verbose bool

	// RequestTimeout places a deadline on every request issued by this
	// client.
	//
	RequestTimeout time.Duration

	// Username is the name of the user to send in the header of every HTTP
	// call - must match the first portion of
	// `--rpc-login=<username>:[password]` provided to `monerod`.
	//
	Username string

	// Password is the user's password to send in the header of every HTTP
	// call - must match the second portion of
	// `--rpc-login=<username>:[password]` provided to `monerod` or the
	// password interactively supplied during the daemon's startup.
	//
	// Note that because the `monerod` performs digest auth, the password
	// won't be sent solely in plain base64 encoding, but the rest of the
	// body of every request and response will still be cleartext.
	//
	Password string
}

ClientConfig provides extra configuration to tweak the behavior of the HTTP client instantiated via `NewClient`.

func (ClientConfig) Validate

func (c ClientConfig) Validate() error

type DigestAuthTransport

type DigestAuthTransport struct {
	Username string
	Password string
	// contains filtered or unexported fields
}

DigestAuthTransport is an implementation of http.RoundTripper that takes care of http digest authentication.

func NewDigestAuthTransport

func NewDigestAuthTransport(
	username, password string, rt http.RoundTripper,
) *DigestAuthTransport

NewDigestAuthTransport creates a new digest transport using the http.DefaultTransport.

func (*DigestAuthTransport) RoundTrip

func (t *DigestAuthTransport) RoundTrip(
	req *http.Request,
) (*http.Response, error)

RoundTrip makes a request expecting a 401 response that will require digest authentication. It creates the credentials it needs and makes a follow-up request.

type DumpTransport

type DumpTransport struct {
	R http.RoundTripper
}

DumpTransport implements the `net/http.RoundTripper` interface wrapping another Roundtripper dumping to stdout both the requests and the responses that it sees passing through.

func NewDumpTransport

func NewDumpTransport(rt http.RoundTripper) *DumpTransport

NewDumpTransport instantiates a new DumpTransport.

func (*DumpTransport) RoundTrip

func (d *DumpTransport) RoundTrip(h *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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