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

Function TestDecompress_UnlimitedExplicit

middleware/decompress_test.go:353–373  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

351}
352
353func TestDecompress_UnlimitedExplicit(t *testing.T) {
354 e := echo.New()
355 largeBody := strings.Repeat("X", 10*1024) // 10KB
356 gz, _ := gzipString(largeBody)
357
358 req := httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(gz))
359 req.Header.Set(echo.HeaderContentEncoding, GZIPEncoding)
360 rec := httptest.NewRecorder()
361 c := e.NewContext(req, rec)
362
363 h, err := DecompressConfig{MaxDecompressedSize: -1}.ToMiddleware() // Unlimited
364 assert.NoError(t, err)
365
366 err = h(func(c *echo.Context) error {
367 b, _ := io.ReadAll(c.Request().Body)
368 return c.String(http.StatusOK, string(b))
369 })(c)
370
371 assert.NoError(t, err)
372 assert.Equal(t, largeBody, rec.Body.String())
373}
374
375func TestDecompress_DefaultLimit(t *testing.T) {
376 e := echo.New()

Callers

nothing calls this directly

Calls 6

RequestMethod · 0.95
StringMethod · 0.95
gzipStringFunction · 0.85
SetMethod · 0.80
NewContextMethod · 0.80
ToMiddlewareMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…