(t *testing.T)
| 396 | } |
| 397 | |
| 398 | func TestDecompress_SmallCustomLimit(t *testing.T) { |
| 399 | e := echo.New() |
| 400 | body := strings.Repeat("D", 512) // 512 bytes |
| 401 | gz, _ := gzipString(body) |
| 402 | |
| 403 | req := httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(gz)) |
| 404 | req.Header.Set(echo.HeaderContentEncoding, GZIPEncoding) |
| 405 | rec := httptest.NewRecorder() |
| 406 | c := e.NewContext(req, rec) |
| 407 | |
| 408 | h, err := DecompressConfig{MaxDecompressedSize: 1024}.ToMiddleware() // 1KB limit |
| 409 | assert.NoError(t, err) |
| 410 | |
| 411 | err = h(func(c *echo.Context) error { |
| 412 | b, _ := io.ReadAll(c.Request().Body) |
| 413 | return c.String(http.StatusOK, string(b)) |
| 414 | })(c) |
| 415 | |
| 416 | assert.NoError(t, err) |
| 417 | assert.Equal(t, body, rec.Body.String()) |
| 418 | } |
| 419 | |
| 420 | func TestDecompress_MultipleReads(t *testing.T) { |
| 421 | e := echo.New() |
nothing calls this directly
no test coverage detected
searching dependent graphs…