proxychaintest

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 8 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 proxychaintest provides an in-process HTTP CONNECT forward proxy for tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClosedAddr added in v1.6.0

func ClosedAddr(t *testing.T) string

ClosedAddr returns a local address nothing listens on.

func FirstBytes added in v1.6.0

func FirstBytes(t *testing.T, n int) (string, <-chan []byte)

FirstBytes starts a TCP server that reports the first n bytes the client sends on the first connection that sends them (a protocol header, a TLS ClientHello), then hangs up. Closed on test cleanup.

func HostOf

func HostOf(rawURL string) string

HostOf returns the host:port of a URL.

func WithCreds

func WithCreds(rawURL, user, pass string) string

WithCreds rewrites a server URL to carry userinfo.

Types

type Proxy

type Proxy struct {
	*httptest.Server

	// Reject, if set, is consulted for each CONNECT; a non-zero status short
	// circuits with that status and headers.
	Reject func(target string) (int, http.Header)
	// Hold, if set, is closed by the test to release a CONNECT that is
	// deliberately left unanswered.
	Hold chan struct{}
	// contains filtered or unexported fields
}

Proxy is an httptest forward proxy: CONNECT is hijacked and piped to the requested authority, plain requests are forwarded absolute-URI style. It records every CONNECT authority and Proxy-Authorization it saw.

func New

func New(t *testing.T, useTLS bool) *Proxy

New starts a Proxy, closed on test cleanup.

func (*Proxy) Auths

func (p *Proxy) Auths() []string

Auths returns the Proxy-Authorization header of every CONNECT seen so far.

func (*Proxy) Connects

func (p *Proxy) Connects() []string

Connects returns every CONNECT authority seen so far.

Jump to

Keyboard shortcuts

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