Documentation
¶
Overview ¶
HTTP steps every part of icebath takes the same way
Index ¶
- func Backoff(attempt int, h http.Header) time.Duration
- func Client(env Env, timeout time.Duration) *http.Client
- func Dial(ctx context.Context, network, address string) (net.Conn, error)
- func DialTLS(ctx context.Context, dialer *net.Dialer, network, address string, ...) (net.Conn, error)
- func DialTunnel(ctx context.Context, dialer *net.Dialer, proxy *url.URL, address, agent string) (net.Conn, error)
- func Dialing(dialer *net.Dialer) func(ctx context.Context, network, address string) (net.Conn, error)
- func IPv4() bool
- func Loopback(host string) bool
- func Message(body any) string
- func Pool(env Env) *x509.CertPool
- func PreferIPv4(on bool)
- func Proxied(env Env) bool
- func Proxy(env Env) func(*http.Request) (*url.URL, error)
- func Retried(status int, h http.Header) bool
- func RetryAfter(value string) (time.Duration, bool)
- func Roots(env Env) *x509.CertPool
- func Said(err error, used, shown string) error
- func Transport(env Env) *http.Transport
- func TunnelProxy(env Env, address string) (*url.URL, error)
- func Unaddressed(err error) error
- type Env
- type Events
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Backoff ¶
Wait before the next try of an OpenAI style API: what Retry-After asks within a minute, else half a second doubling with each try up to 8 seconds, a quarter of it random
func Client ¶
HTTP client of requests made in the environment on the Transport they share, a request given up after the timeout, never for none
func Dial ¶
What a connection that sets no wait of its own dials with: 30 seconds to connect, kept alive every 30 seconds
func DialTLS ¶
func DialTLS(ctx context.Context, dialer *net.Dialer, network, address string, config *tls.Config) (net.Conn, error)
A TLS connection dialed as every connection of icebath is, its handshake made with the config before it is handed back; the host of the address is the name the certificate is checked against where the config names none, as tls.Dialer has it
func DialTunnel ¶
func DialTunnel(ctx context.Context, dialer *net.Dialer, proxy *url.URL, address, agent string) (net.Conn, error)
A connection to the address through the proxy, opened as gRPC opens one through a proxy of the environment: the proxy dialed as every connection of icebath is, on 443 where its address names no port, then an HTTP CONNECT to the address with the user agent given and the proxy's credentials as Basic authorization, an answer other than 200 refused; what the proxy sent past its answer is read first. TLS to the address, where the caller asks for it, is made through the tunnel by the caller
func Dialing ¶
func Dialing(dialer *net.Dialer) func(ctx context.Context, network, address string) (net.Conn, error)
The dial of every connection of icebath, made of the dialer and its settings: while IPv4 is preferred, a tcp or udp connection to a host name takes its IPv4 addresses alone, each tried in the order the resolver gives them, and the host's addresses of every family when it has no IPv4 one; an address, a unix socket and every other network dial as they are. The preference is read at each dial
func Loopback ¶
Whether the host is this machine's loopback: localhost, a name under .localhost or a loopback address, brackets around one dropped
func Message ¶
Message a JSON error body of an API carries for a person, in the shapes services give it: error.message, error as text, message, detail or error_description; empty when the body holds none
func Pool ¶
Pool of the authorities the environment trusts that a caller adds its own to, such as the certificate a provider's settings name: a copy of Roots, else of the system's
func PreferIPv4 ¶
func PreferIPv4(on bool)
Has every connection the process opens from now on try the IPv4 addresses of a host first, or its addresses in the order the system gives them, clients made before included: for networks whose IPv6 route only times out. The first call has http.DefaultTransport dial as Dial does, so it is made before anything else of the process dials
func Proxied ¶
Whether the environment sets a proxy, which then resolves the names of the hosts itself
func Proxy ¶
Proxy of each request as the environment says, the hosts NO_PROXY names and this machine reached directly: what a transport of the environment's requests is given in place of http.ProxyFromEnvironment, which reads this process's variables
func Retried ¶
Whether a failed status of an OpenAI style API is worth another try: as its x-should-retry header says, else a timeout, conflict, rate limit or failure of the service
func RetryAfter ¶
Wait a Retry-After value asks for: seconds, or an HTTP or mail date to wait until, never less than nothing; false when it asks none
func Roots ¶
Authorities a TLS client trusts in the environment: the system's with those of the files and folders its variables name, nil when they name none, which leaves the system's. A file that can't be read is said in the log and left out. The pool is shared by every request of the same files: a caller that adds its own takes Pool
func Said ¶
Error with an address said as a person is told it: where a setting writes the start of an address with a reference, as shown, every place the text of the error holds the start it comes to, used, holds it as written instead, and a request that failed says what went wrong without the address the network repeats, so no error shows the value of a variable a setting names; any host of the address left in the text is said as the address written. The error itself when the two are the same or either is empty; what it wraps is kept
func Transport ¶
Transport of requests made in the environment: Go's default one with the environment's proxy and authorities, shared by every environment that sets the same, so connections are reused. A caller that changes it takes a Clone
func TunnelProxy ¶
Proxy a connection that is no HTTP request goes through to the address, read from the environment as gRPC reads it for its own connections (http.ProxyFromEnvironment for an https request to the address): HTTPS_PROXY or https_proxy, the hosts NO_PROXY or no_proxy names and this machine's own reached directly, none under CGI; ALL_PROXY not read, as gRPC reads it not. Nil for none
func Unaddressed ¶
What went wrong reaching or listening at an address, without the address or the URL the error repeats: what is said beside the address as a person wrote it, which may name a variable as ${NAME} whose value no message shows
Types ¶
type Env ¶
Variable of the environment a request is made in, empty when it is not set: a profile's, such as the settings of the profile read it, so the proxy and the authorities of its requests are its own and never those of another profile this process serves
type Events ¶
type Events struct {
// contains filtered or unexported fields
}
An answer of server-sent events written as it is made, which stops writing once the reader went
func NewEvents ¶
func NewEvents(w http.ResponseWriter) *Events
Begins an answer of events: the headers of a stream no proxy holds back, status 200, sent at once