httpx

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 27 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

HTTP steps every part of icebath takes the same way

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backoff

func Backoff(attempt int, h http.Header) time.Duration

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

func Client(env Env, timeout time.Duration) *http.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

func Dial(ctx context.Context, network, address string) (net.Conn, error)

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 IPv4

func IPv4() bool

Whether connections try the IPv4 addresses of a host first

func Loopback

func Loopback(host string) bool

Whether the host is this machine's loopback: localhost, a name under .localhost or a loopback address, brackets around one dropped

func Message

func Message(body any) string

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

func Pool(env Env) *x509.CertPool

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

func Proxied(env Env) bool

Whether the environment sets a proxy, which then resolves the names of the hosts itself

func Proxy

func Proxy(env Env) func(*http.Request) (*url.URL, error)

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

func Retried(status int, h http.Header) bool

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

func RetryAfter(value string) (time.Duration, bool)

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

func Roots(env Env) *x509.CertPool

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

func Said(err error, used, shown string) error

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

func Transport(env Env) *http.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

func TunnelProxy(env Env, address string) (*url.URL, error)

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

func Unaddressed(err error) error

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

type Env func(name string) string

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

func (*Events) Beat

func (e *Events) Beat() bool

Says the stream still lives, as a line no reader takes as an event

func (*Events) Send

func (e *Events) Send(name string, data any) bool

Sends one event: its name when it has one, and its data, text as it is and any other value as JSON; false once the reader went

Jump to

Keyboard shortcuts

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