Documentation ¶
Overview ¶
Package testutil provides utilities for testing the HTTP protocol.
Index ¶
- func CurDir() (string, error)
- func GetCertsPaths() (string, string, error)
- func HTTPPythonServer(t *testing.T, addr string, options Options) *exec.Cmd
- func HTTPServer(t *testing.T, addr string, options Options) func()
- func SetupNetIPV4TCPTimestamp(t *testing.T, enable bool)
- func StatusFromPath(path string) uint16
- type Options
- type TCPServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCertsPaths ¶
GetCertsPaths returns the absolute paths to the certs located in the testdata directory, so they can be used in test throughout the project
func HTTPPythonServer ¶
HTTPPythonServer launches an HTTP python server.
func HTTPServer ¶
HTTPServer spins up a HTTP test server that returns the status code included in the URL Example: * GET /200/foo returns a 200 status code; * PUT /404/bar returns a 404 status code; Optional TLS support using a self-signed certificate can be enabled trough the `enableTLS` argument nolint
func SetupNetIPV4TCPTimestamp ¶
SetupNetIPV4TCPTimestamp sets the net.ipv4.tcp_timestamps to the provided value.
func StatusFromPath ¶
StatusFromPath returns the status code present in the first segment of the request path
Types ¶
type Options ¶
type Options struct { // If TLS is enabled, allows to upgrade the connections to http/2. EnableHTTP2 bool EnableTLS bool EnableKeepAlive bool EnableLimitListener bool EnableTCPTimestamp *bool ReadTimeout time.Duration WriteTimeout time.Duration SlowResponse time.Duration }
Options wraps all configurable params for the HTTPServer
type TCPServer ¶
type TCPServer struct {
// contains filtered or unexported fields
}
TCPServer represents a basic TCP server configuration.
func NewTCPServer ¶
NewTCPServer creates and initializes a new TCPServer instance with the provided address and callback function to handle incoming messages.
func NewTLSServerWithSpecificVersion ¶
func NewTLSServerWithSpecificVersion(addr string, onMessage func(c net.Conn), tlsVersion uint16) *TCPServer
NewTLSServerWithSpecificVersion creates and initializes a new TCPServer instance with the provided address and callback function to handle incoming messages. It also sets the TLS version to the provided value.