networkhttp

package
v2026.1105.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 12 Imported by: 0 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

Package networkhttp keeps HTTP connection pools aligned with system routing.

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = &http.Client{Transport: NewDefaultTransport()}
View Source
var ErrRouteChanged = errors.New("system network route changed")

ErrRouteChanged tells the owning retry loop to restart on the current route.

Functions

func NewDefaultTransport

func NewDefaultTransport() http.RoundTripper

NewDefaultTransport follows the standard client's current default transport, including custom RoundTrippers used by integrations and offline test fixtures.

Types

type Transport

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

Transport replaces its connection pool when the system's routes change. New preserves active responses; NewRetrying interrupts them so the owning retry loop can restart. This transport never replays requests itself.

func New

func New(base *http.Transport) *Transport

New clones base, which must not be modified afterward.

func NewForTest

func NewForTest(base *http.Transport, routeKey func() string, interrupt ...bool) *Transport

NewForTest supplies a deterministic routing snapshot for offline tests.

func NewRetrying

func NewRetrying(base *http.Transport) *Transport

NewRetrying also interrupts active requests on route changes. Use only when the caller owns a retry loop and permits replaying the request.

func (*Transport) CloseIdleConnections

func (t *Transport) CloseIdleConnections()

func (*Transport) PrepareRetry

func (t *Transport) PrepareRetry()

PrepareRetry discards the pool used by the failed attempt, even when a transient network change left the route tables unchanged. The next request opens a connection using the OS's current routing decision.

func (*Transport) RoundTrip

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

Jump to

Keyboard shortcuts

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