httputil

package
v2.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

Package httputil provides shared HTTP client construction utilities for the PromptKit project. It centralizes timeout defaults and client creation so that every module uses consistent configuration.

Index

Constants

View Source
const (
	// DefaultProviderTimeout is the HTTP timeout for LLM provider calls
	// (e.g. OpenAI, Claude, Gemini). Provider requests can involve large
	// payloads and long inference times, so they use a longer timeout.
	DefaultProviderTimeout = 60 * time.Second

	// DefaultToolTimeout is the HTTP timeout for tool / webhook calls
	// made by the SDK HTTP executor. These are typically shorter-lived
	// API requests.
	DefaultToolTimeout = 30 * time.Second

	// DefaultStreamingTimeout is the HTTP timeout for streaming provider
	// responses (e.g. SSE streams). Streaming connections stay open much
	// longer than regular request/response cycles.
	DefaultStreamingTimeout = 300 * time.Second
)

Standard timeout defaults used across the project.

Variables

View Source
var ErrNonPublicDestination = errors.New("destination is not a public address")

ErrNonPublicDestination is returned when a guarded client is asked to connect to an address that is not on the public internet.

Functions

func IsPublicAddress added in v2.13.0

func IsPublicAddress(ip netip.Addr) bool

IsPublicAddress reports whether ip is an ordinary public address: not loopback, private, link-local (which is where cloud metadata services live), multicast, unspecified or otherwise reserved.

func NewHTTPClient

func NewHTTPClient(timeout time.Duration) *http.Client

NewHTTPClient returns an *http.Client configured with the given timeout, a TLS 1.2 minimum, and connection pool limits. Pass one of the Default*Timeout constants, or a custom duration.

func NewPublicHTTPClient added in v2.13.0

func NewPublicHTTPClient(timeout time.Duration) *http.Client

NewPublicHTTPClient returns an HTTP client that connects only to public addresses. Use it to fetch a URL that came from a model, a remote client or any other input the host does not control: without it, such a URL can point the host at its own cloud metadata service or internal network.

It never uses a proxy, since a proxy would make the dialed address the proxy's and hide the real destination from the check.

Types

This section is empty.

Jump to

Keyboard shortcuts

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