Help us shape the future of Go! Take the 2026 Go Developer Survey

httpproxytest

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package httpproxytest provides a stub HTTP CONNECT proxy for tests.

It is a package rather than a helper in a _test.go file because three packages need the same stub — internal/httpproxy, host/internal and ws — and test files cannot be imported.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Proxy

type Proxy struct {
	// URL addresses the proxy and carries no credentials. A test that wants
	// Proxy-Authorization copies it and sets User.
	URL *url.URL
	// contains filtered or unexported fields
}

Proxy is a minimal HTTP CONNECT proxy.

func Start

func Start(t TB, status int) *Proxy

Start runs a proxy answering CONNECT with status. A 200 splices the tunnel through to the requested target; any other status refuses it.

func StartRaw

func StartRaw(t TB, reply string) *Proxy

StartRaw runs a proxy answering every CONNECT with reply, written verbatim, dialing no target. Whatever follows the header in reply becomes the tunnel's first bytes, which is how a non-conformant proxy is simulated.

func (*Proxy) LastAuth

func (p *Proxy) LastAuth() string

LastAuth reports the Proxy-Authorization header of the most recent CONNECT, which is "" both when none was sent and when there was no CONNECT at all.

func (*Proxy) LastTarget

func (p *Proxy) LastTarget() string

LastTarget reports the authority of the most recent CONNECT, or "" if the proxy was never asked for a tunnel.

func (*Proxy) Tunnels

func (p *Proxy) Tunnels() int32

Tunnels reports how many CONNECTs were accepted.

type TB

type TB interface {
	Helper()
	Cleanup(func())
	Fatalf(format string, args ...any)
}

TB is the part of *testing.T this package uses. Depending on an interface keeps the testing package, and the flags it registers, out of a non-test import graph.

Jump to

Keyboard shortcuts

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