(t *testing.T)
| 69 | } |
| 70 | |
| 71 | func TestBodyLimitAfterDecompressUsesDecodedSize(t *testing.T) { |
| 72 | e := echo.New() |
| 73 | body := "ok" |
| 74 | gz, err := gzipString(body) |
| 75 | assert.NoError(t, err) |
| 76 | assert.Greater(t, len(gz), len(body)) |
| 77 | |
| 78 | req := httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(gz)) |
| 79 | req.Header.Set(echo.HeaderContentEncoding, GZIPEncoding) |
| 80 | rec := httptest.NewRecorder() |
| 81 | c := e.NewContext(req, rec) |
| 82 | |
| 83 | err = Decompress()(BodyLimit(int64(len(body)))(func(c *echo.Context) error { |
| 84 | body, readErr := io.ReadAll(c.Request().Body) |
| 85 | if readErr != nil { |
| 86 | return readErr |
| 87 | } |
| 88 | return c.String(http.StatusOK, string(body)) |
| 89 | }))(c) |
| 90 | |
| 91 | assert.NoError(t, err) |
| 92 | assert.Equal(t, http.StatusOK, rec.Code) |
| 93 | assert.Equal(t, body, rec.Body.String()) |
| 94 | } |
| 95 | |
| 96 | func TestBodyLimitReader(t *testing.T) { |
| 97 | hw := []byte("Hello, World!") |
nothing calls this directly
no test coverage detected
searching dependent graphs…