(t *testing.T)
| 351 | } |
| 352 | |
| 353 | func 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 | |
| 375 | func TestDecompress_DefaultLimit(t *testing.T) { |
| 376 | e := echo.New() |
nothing calls this directly
no test coverage detected
searching dependent graphs…