remote_http

package
v0.0.0-...-791c77c Latest Latest
Warning

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

Go to latest
Published: May 11, 2025 License: MIT Imports: 51 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRoundTripper http.RoundTripper

Functions

func MakeClient

func MakeClient(
	envUI env_ui.Env,
	transport http.RoundTripper,
	localRepo repo.LocalRepo,
	typedBlobStore typed_blob_store.InventoryList,
) *client

func ReadErrorFromBody

func ReadErrorFromBody(response *http.Response) (err error)

func ReadErrorFromBodyOnGreaterOrEqual

func ReadErrorFromBodyOnGreaterOrEqual(
	response *http.Response,
	status int,
) (err error)

func ReadErrorFromBodyOnNot

func ReadErrorFromBodyOnNot(
	response *http.Response,
	statuses ...int,
) (err error)

Types

type BufferedResponseWriter

type BufferedResponseWriter struct {
	Dirty    bool
	Response http.Response
	Buffer   bytes.Buffer
}

func (*BufferedResponseWriter) GetResponseWriter

func (responseWriter *BufferedResponseWriter) GetResponseWriter() http.ResponseWriter

func (*BufferedResponseWriter) Header

func (responseWriter *BufferedResponseWriter) Header() http.Header

func (*BufferedResponseWriter) Reset

func (responseWriter *BufferedResponseWriter) Reset()

func (*BufferedResponseWriter) Write

func (responseWriter *BufferedResponseWriter) Write(p []byte) (int, error)

func (*BufferedResponseWriter) WriteHeader

func (responseWriter *BufferedResponseWriter) WriteHeader(statusCode int)

func (*BufferedResponseWriter) WriteResponse

func (responseWriter *BufferedResponseWriter) WriteResponse(
	writer io.Writer,
) error

type HTTPPort

type HTTPPort struct {
	net.Listener
	Port int
}

type MethodPath

type MethodPath struct {
	Method string
	Path   string
}

type Request

type Request struct {
	MethodPath
	Headers http.Header
	Body    io.ReadCloser
	// contains filtered or unexported fields
}

func (Request) Vars

func (r Request) Vars() map[string]string

type Response

type Response struct {
	StatusCode int
	Body       io.ReadCloser
}

func (*Response) Error

func (response *Response) Error(err error)

func (*Response) ErrorWithStatus

func (response *Response) ErrorWithStatus(status int, err error)

type RoundTripperBufioWrappedSigner

type RoundTripperBufioWrappedSigner struct {
	repo_signing.PublicKey
	// contains filtered or unexported fields
}

func (*RoundTripperBufioWrappedSigner) RoundTrip

func (roundTripper *RoundTripperBufioWrappedSigner) RoundTrip(
	request *http.Request,
) (response *http.Response, err error)

TODO extract signing into an agnostic middleware

type RoundTripperHost

type RoundTripperHost struct {
	UrlData
	http.RoundTripper
}

A round tripper that decorates another round tripper and always populates the http requests with given UrlData template.

func (*RoundTripperHost) RoundTrip

func (roundTripper *RoundTripperHost) RoundTrip(
	request *http.Request,
) (response *http.Response, err error)

type RoundTripperRetry

type RoundTripperRetry struct {
	RetryFunc  func(error) bool
	RetryCount int
	http.RoundTripper
}

func MakeRoundTripperRetry

func MakeRoundTripperRetry(
	inner http.RoundTripper,
	count int,
	retryFunc func(error) bool,
) RoundTripperRetry

func MakeRoundTripperRetryTimeouts

func MakeRoundTripperRetryTimeouts(
	inner http.RoundTripper,
	count int,
) RoundTripperRetry

func (RoundTripperRetry) RoundTrip

func (roundTripper RoundTripperRetry) RoundTrip(
	request *http.Request,
) (response *http.Response, err error)

type RoundTripperStdio

type RoundTripperStdio struct {
	exec.Cmd
	io.WriteCloser
	io.ReadCloser
	RoundTripperBufioWrappedSigner
}

func (*RoundTripperStdio) InitializeWithLocal

func (roundTripper *RoundTripperStdio) InitializeWithLocal(
	envRepo env_repo.Env,
	pubkey repo_signing.PublicKey,
) (err error)

func (*RoundTripperStdio) InitializeWithSSH

func (roundTripper *RoundTripperStdio) InitializeWithSSH(
	envUI env_ui.Env,
	arg string,
) (err error)

type RoundTripperUnixSocket

type RoundTripperUnixSocket struct {
	repo.UnixSocket
	net.Conn
	RoundTripperBufioWrappedSigner
}

func (*RoundTripperUnixSocket) Initialize

func (roundTripper *RoundTripperUnixSocket) Initialize(
	remote *Server,
	pubkey repo_signing.PublicKey,
) (err error)

TODO add public key

type Server

type Server struct {
	EnvLocal env_local.Env
	Repo     repo.LocalRepo

	GetCertificate func(*tls.ClientHelloInfo) (*tls.Certificate, error)
	// contains filtered or unexported fields
}

func (*Server) InitializeHTTP

func (server *Server) InitializeHTTP(
	config net.ListenConfig,
	port int,
) (httpPort HTTPPort, err error)

func (*Server) InitializeListener

func (server *Server) InitializeListener(
	network, address string,
) (listener net.Listener, err error)

TODO switch to not return error

func (*Server) InitializeUnixSocket

func (server *Server) InitializeUnixSocket(
	config net.ListenConfig,
	path string,
) (sock repo.UnixSocket, err error)

func (*Server) Serve

func (server *Server) Serve(listener net.Listener) (err error)

TODO remove error return and use context

func (*Server) ServeStdio

func (server *Server) ServeStdio()

type UrlData

type UrlData struct {
	Scheme string
	Opaque string        // encoded opaque data
	User   *url.Userinfo // username and password information
	Host   string        // host or host:port (see Hostname and Port methods)
}

func MakeUrlDataFromUri

func MakeUrlDataFromUri(uri values.Uri) UrlData

func (UrlData) Apply

func (urlData UrlData) Apply(ur *url.URL)

Jump to

Keyboard shortcuts

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