grab: github.com/cavaliercoder/grab/grabtest Index | Files

package grabtest

import "github.com/cavaliercoder/grab/grabtest"

Index

Package Files

assert.go handler.go handler_option.go util.go

Variables

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

func AssertHTTPResponseBodyLength Uses

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

func AssertHTTPResponseContentLength Uses

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

func AssertHTTPResponseHeader Uses

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

func AssertHTTPResponseStatusCode Uses

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

func AssertSHA256Sum Uses

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

func MustHTTPDo Uses

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

func MustHTTPDoWithClose Uses

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

func MustHTTPNewRequest Uses

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

func MustHexDecodeString Uses

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

func MustHexEncodeString Uses

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

func NewHandler Uses

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

func WithTestServer Uses

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

type HandlerOption Uses

type HandlerOption func(*handler) error

func AcceptRanges Uses

func AcceptRanges(enabled bool) HandlerOption

func AttachmentFilename Uses

func AttachmentFilename(filename string) HandlerOption

func ContentLength Uses

func ContentLength(n int) HandlerOption

func HeaderBlacklist Uses

func HeaderBlacklist(headers ...string) HandlerOption

func LastModified Uses

func LastModified(t time.Time) HandlerOption

func MethodWhitelist Uses

func MethodWhitelist(methods ...string) HandlerOption

func RateLimiter Uses

func RateLimiter(bps int) HandlerOption

func StatusCode Uses

func StatusCode(f StatusCodeFunc) HandlerOption

func StatusCodeStatic Uses

func StatusCodeStatic(code int) HandlerOption

func TimeToFirstByte Uses

func TimeToFirstByte(d time.Duration) HandlerOption

type StatusCodeFunc Uses

type StatusCodeFunc func(req *http.Request) int

Package grabtest imports 12 packages (graph). Updated 2019-07-30. Refresh now. Tools for package owners.