transport

package
v0.0.0-...-212369e Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTransportWrapper = identityTransportWrapper

DefaultTransportWrapper allows a user to wrap every generated transport

View Source
var (

	// ErrWrongCodeForByteRange is returned if the client sends a request
	// with a Range header but the server returns a 2xx or 3xx code other
	// than 206 Partial Content.
	ErrWrongCodeForByteRange = errors.New("expected HTTP 206 from byte range request")
)

Functions

func NewTransport

func NewTransport(base http.RoundTripper, modifiers ...RequestModifier) http.RoundTripper

NewTransport creates a new transport which will apply modifiers to the request on a RoundTrip call.

Types

type HTTPReadSeeker

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

HTTPReadSeeker implements an io.ReadSeekCloser.

func NewHTTPReadSeeker

func NewHTTPReadSeeker(ctx context.Context, client *http.Client, url string, errorHandler func(*http.Response) error) *HTTPReadSeeker

NewHTTPReadSeeker handles reading from an HTTP endpoint using a GET request. When seeking and starting a read from a non-zero offset the a "Range" header will be added which sets the offset.

TODO(dmcgowan): Move this into a separate utility package

func (*HTTPReadSeeker) Close

func (hrs *HTTPReadSeeker) Close() error

func (*HTTPReadSeeker) Read

func (hrs *HTTPReadSeeker) Read(p []byte) (n int, err error)

func (*HTTPReadSeeker) Seek

func (hrs *HTTPReadSeeker) Seek(offset int64, whence int) (int64, error)

type RequestModifier

type RequestModifier interface {
	ModifyRequest(*http.Request) error
}

RequestModifier represents an object which will do an inplace modification of an HTTP request.

func NewHeaderRequestModifier

func NewHeaderRequestModifier(header http.Header) RequestModifier

NewHeaderRequestModifier returns a new RequestModifier which will add the given headers to a request.

Jump to

Keyboard shortcuts

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