(t *testing.T)
| 81 | } |
| 82 | |
| 83 | func TestDecompressWithConfig_DefaultConfig(t *testing.T) { |
| 84 | e := echo.New() |
| 85 | |
| 86 | h := Decompress()(func(c *echo.Context) error { |
| 87 | c.Response().Write([]byte("test")) // For Content-Type sniffing |
| 88 | return nil |
| 89 | }) |
| 90 | |
| 91 | // Decompress |
| 92 | body := `{"name": "echo"}` |
| 93 | gz, _ := gzipString(body) |
| 94 | req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(string(gz))) |
| 95 | req.Header.Set(echo.HeaderContentEncoding, GZIPEncoding) |
| 96 | rec := httptest.NewRecorder() |
| 97 | c := e.NewContext(req, rec) |
| 98 | |
| 99 | err := h(c) |
| 100 | assert.NoError(t, err) |
| 101 | |
| 102 | assert.Equal(t, GZIPEncoding, req.Header.Get(echo.HeaderContentEncoding)) |
| 103 | b, err := io.ReadAll(req.Body) |
| 104 | assert.NoError(t, err) |
| 105 | assert.Equal(t, body, string(b)) |
| 106 | } |
| 107 | |
| 108 | func TestCompressRequestWithoutDecompressMiddleware(t *testing.T) { |
| 109 | e := echo.New() |
nothing calls this directly
no test coverage detected
searching dependent graphs…