grabtest

package
v3.0.0-...-791b159 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultHandlerContentLength       = 1 << 20
	DefaultHandlerMD5Checksum         = "c35cc7d8d91728a0cb052831bc4ef372"
	DefaultHandlerMD5ChecksumBytes    = MustHexDecodeString(DefaultHandlerMD5Checksum)
	DefaultHandlerSHA256Checksum      = "fbbab289f7f94b25736c58be46a994c441fd02552cc6022352e3d86d2fab7c83"
	DefaultHandlerSHA256ChecksumBytes = MustHexDecodeString(DefaultHandlerSHA256Checksum)
)

Functions

func AssertHTTPResponseBodyLength

func AssertHTTPResponseBodyLength(t *testing.T, resp *http.Response, n int64) (ok bool)

func AssertHTTPResponseContentLength

func AssertHTTPResponseContentLength(t *testing.T, resp *http.Response, n int64) (ok bool)

func AssertHTTPResponseHeader

func AssertHTTPResponseHeader(t *testing.T, resp *http.Response, key, format string, a ...interface{}) (ok bool)

func AssertHTTPResponseStatusCode

func AssertHTTPResponseStatusCode(t *testing.T, resp *http.Response, expect int) (ok bool)

func AssertSHA256Sum

func AssertSHA256Sum(t *testing.T, sum []byte, r io.Reader) (ok bool)

func MustHTTPDo

func MustHTTPDo(req *http.Request) *http.Response

func MustHTTPDoWithClose

func MustHTTPDoWithClose(req *http.Request) *http.Response

func MustHTTPNewRequest

func MustHTTPNewRequest(method, url string, body io.Reader) *http.Request

func MustHexDecodeString

func MustHexDecodeString(s string) (b []byte)

func MustHexEncodeString

func MustHexEncodeString(b []byte) (s string)

func NewHandler

func NewHandler(options ...HandlerOption) (http.Handler, error)

func WithTestServer

func WithTestServer(t *testing.T, f func(url string), options ...HandlerOption)

Types

type HandlerOption

type HandlerOption func(*handler) error

func AcceptRanges

func AcceptRanges(enabled bool) HandlerOption

func AttachmentFilename

func AttachmentFilename(filename string) HandlerOption

func ContentLength

func ContentLength(n int) HandlerOption

func HeaderBlacklist

func HeaderBlacklist(headers ...string) HandlerOption

func LastModified

func LastModified(t time.Time) HandlerOption

func MethodWhitelist

func MethodWhitelist(methods ...string) HandlerOption

func RateLimiter

func RateLimiter(bps int) HandlerOption

func StatusCode

func StatusCode(f StatusCodeFunc) HandlerOption

func StatusCodeStatic

func StatusCodeStatic(code int) HandlerOption

func TimeToFirstByte

func TimeToFirstByte(d time.Duration) HandlerOption

type StatusCodeFunc

type StatusCodeFunc func(req *http.Request) int

Jump to

Keyboard shortcuts

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