outboundhttp

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: AGPL-3.0, AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package outboundhttp owns production net/http network transport construction. All Swobu HTTP(S) transports use Go's request-level environment proxy selection. Callers may supply a guarded dialer for direct destinations, but callers do not parse proxy configuration or classify dial addresses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DirectDialContext enables restricted-direct mode. When nil, the transport
	// is unrestricted and delegates route selection entirely to the cloned
	// standard transport.
	DirectDialContext DialContext

	// ResponseHeaderTimeout overrides the cloned standard value when non-zero.
	ResponseHeaderTimeout time.Duration

	// TLSClientConfig, when non-nil, is cloned before use. Callers must not be
	// able to mutate live transport configuration after construction.
	TLSClientConfig *tls.Config
}

Config configures a Transport. The zero value is not meaningful in production because NewTransport type-asserts http.DefaultTransport; construct a Transport only through NewTransport.

type DialContext

type DialContext func(
	context.Context,
	string,
	string,
) (net.Conn, error)

DialContext dials a direct destination. It is the signature of the guarded dialer a restricted caller (media, remote MCP) supplies so its existing destination checks run only on a directly-selected route — never on the first-hop address of an already-selected proxy.

type Transport

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

Transport is the sole production net/http network transport owner. A Transport is either unrestricted (provider) or restricted (media, remote MCP); exactly one of the two layouts is present.

func NewTransport

func NewTransport(cfg Config) *Transport

NewTransport constructs the production Transport. The proxy law is always Go's request-level http.ProxyFromEnvironment; production callers may not select a different proxy law.

func (*Transport) CloseIdleConnections

func (t *Transport) CloseIdleConnections()

CloseIdleConnections closes idle connections on every internal transport. It is safe before any request and safe to call more than once.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(
	req *http.Request,
) (*http.Response, error)

RoundTrip executes a request using the single request-level proxy decision. In unrestricted mode the cloned standard transport owns its ordinary direct/proxy behavior. In restricted mode it evaluates the selector exactly once: a nil result routes to the caller's guarded direct dialer; a non-nil result routes to the shared proxied transport, carrying the decision through a private context value so the selector is not evaluated again.

Jump to

Keyboard shortcuts

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