request

package
v0.0.0-...-851e5e8 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package request provides convenient way for sending HTTP requests.

Index

Constants

View Source
const (
	DefaultTimeout   = 15 * time.Second
	TransportTimeout = 5 * time.Second
)

Variables

View Source
var (
	ErrBearerTokenNotProvided         = errors.New("bearer token not provided")
	ErrNothingMoreToRotate            = errors.New("nothing more to rotate")
	ErrUsernameAndPasswordNotProvided = errors.New("username and password not provided")
)

Functions

func NewRequest

func NewRequest(
	method, agent, baseURL, pathURL, contentType, contentLength, encoding string,
	body io.Reader,
) (*http.Request, error)

NewRequest builds an unauthenticated request.

func NewRequestWithBearerToken

func NewRequestWithBearerToken(
	method, agent, baseURL, pathURL, contentType, contentLength, encoding string,
	body io.Reader,
	token string,
) (*http.Request, error)

NewRequestWithBearerToken builds a Bearer Token authenticated request.

func NewStdHTTP

func NewStdHTTP(opts ...StdOpt) *http.Client

NewStdHTTP returns standard library's http client with opts.

Types

type BasicAuth

type BasicAuth struct {
	Username string
	Password string
}

type HTTPReTransport

type HTTPReTransport struct {
	// contains filtered or unexported fields
}

HTTPReTransport is std RoundTripper enhanced to reconnect after vpn connect is done Thread safe.

func NewHTTPReTransport

func NewHTTPReTransport(fn func() http.RoundTripper) *HTTPReTransport

func (*HTTPReTransport) NotifyConnect

func (m *HTTPReTransport) NotifyConnect(events.DataConnect) error

func (*HTTPReTransport) RoundTrip

func (m *HTTPReTransport) RoundTrip(req *http.Request) (*http.Response, error)

type PublishingRoundTripper

type PublishingRoundTripper struct {
	// contains filtered or unexported fields
}

func NewPublishingRoundTripper

func NewPublishingRoundTripper(
	roundTripper http.RoundTripper,
	publisher events.Publisher[events.DataRequestAPI],
) *PublishingRoundTripper

func (*PublishingRoundTripper) RoundTrip

func (rt *PublishingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

type QuicTransport

type QuicTransport struct {
	// contains filtered or unexported fields
}

QuicTransport is modified/enhanced RoundTripper. Thread safe.

func NewQuicTransport

func NewQuicTransport(fn func() *http3.RoundTripper) *QuicTransport

func (*QuicTransport) NotifyConnect

func (m *QuicTransport) NotifyConnect(events.DataConnect) error

func (*QuicTransport) RoundTrip

func (m *QuicTransport) RoundTrip(req *http.Request) (*http.Response, error)

type RotatingRoundTripper

type RotatingRoundTripper struct {
	// contains filtered or unexported fields
}

func NewRotatingRoundTripper

func NewRotatingRoundTripper(
	roundTripperH1 http.RoundTripper,
	roundTripperH3 http.RoundTripper,
	h3ReviveTime time.Duration,
) *RotatingRoundTripper

func (*RotatingRoundTripper) RoundTrip

func (rt *RotatingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

type StdOpt

type StdOpt func(*http.Client)

StdOpt allows configuring standard library's http client.

Jump to

Keyboard shortcuts

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