nettesting

package
v0.33.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2025 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

Package nettesting contains utilities for testing networking functionality. Don't use these utilities in production code. They have not been security reviewed.

Package nettesting contains utilities for testing networking functionality. Don't use these utilities in production code. They have not been security reviewed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeSocketNameForTest

func MakeSocketNameForTest(t testing.TB, name string) string

MakeSocketNameForTest returns a socket name to use for the duration of a test. On Operating systems that support abstract sockets, it the name is prefixed with `@` to make it an abstract socket. On Operating systems that do not support abstract sockets, the name is treated as a filename and a cleanup hook is registered to delete the socket at the end of the test.

Types

type HTTPProxyHandler

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

HTTPProxyHandler implements a simple handler for http_proxy and https_proxy requests for use in testing.

func NewHTTPProxyHandler

func NewHTTPProxyHandler(t testing.TB, hook func(req *http.Request) bool) *HTTPProxyHandler

NewHTTPProxyHandler returns a new HTTPProxyHandler. It accepts an optional hook which is called early in the handler to export request state. If the hook returns false, the handler returns immediately with a server error. Ensure that this is only used in tests. This code has not been security reviewed.

func (*HTTPProxyHandler) ServeHTTP

func (h *HTTPProxyHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP handles an HTTP proxy request.

func (*HTTPProxyHandler) Wait

func (h *HTTPProxyHandler) Wait()

Jump to

Keyboard shortcuts

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