MCPcopy Index your code
hub / github.com/labstack/echo / TestGzip_AcceptEncodingHeader

Function TestGzip_AcceptEncodingHeader

middleware/compress_test.go:44–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestGzip_AcceptEncodingHeader(t *testing.T) {
45 h := Gzip()(func(c *echo.Context) error {
46 c.Response().Write([]byte("test")) // For Content-Type sniffing
47 return nil
48 })
49
50 e := echo.New()
51 req := httptest.NewRequest(http.MethodGet, "/", nil)
52 req.Header.Set(echo.HeaderAcceptEncoding, gzipScheme)
53
54 rec := httptest.NewRecorder()
55 c := e.NewContext(req, rec)
56
57 err := h(c)
58 assert.NoError(t, err)
59
60 assert.Equal(t, gzipScheme, rec.Header().Get(echo.HeaderContentEncoding))
61 assert.Contains(t, rec.Header().Get(echo.HeaderContentType), echo.MIMETextPlain)
62
63 r, err := gzip.NewReader(rec.Body)
64 assert.NoError(t, err)
65 buf := new(bytes.Buffer)
66 defer r.Close()
67 buf.ReadFrom(r)
68 assert.Equal(t, "test", buf.String())
69}
70
71func TestGzip_chunked(t *testing.T) {
72 e := echo.New()

Callers

nothing calls this directly

Calls 9

ResponseMethod · 0.95
GzipFunction · 0.85
SetMethod · 0.80
NewContextMethod · 0.80
WriteMethod · 0.45
GetMethod · 0.45
HeaderMethod · 0.45
CloseMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…