diff options
author | feistel <6742251-feistel@users.noreply.gitlab.com> | 2020-10-13 13:52:50 +0300 |
---|---|---|
committer | Vladimir Shushlin <vshushlin@gitlab.com> | 2020-10-13 13:52:50 +0300 |
commit | 77b42fad727a8d8166d8d9a3aa6951f530a664ea (patch) | |
tree | f6b7ca7cea056fabc00fa163decd685dbca3e172 /acceptance_test.go | |
parent | 5f461b42e39419795b2669278398a9a7c6ed2cd9 (diff) |
Ensure the content encoding is correct before reading the body
Avoid strange EOF error when the encoding is wrong
Diffstat (limited to 'acceptance_test.go')
-rw-r--r-- | acceptance_test.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/acceptance_test.go b/acceptance_test.go index 83f09cdf..0b1442f0 100644 --- a/acceptance_test.go +++ b/acceptance_test.go @@ -659,6 +659,44 @@ func TestObscureMIMEType(t *testing.T) { require.Equal(t, "application/manifest+json", mt) } +func TestCompressedEncoding(t *testing.T) { + skipUnlessEnabled(t) + + tests := []struct { + name string + host string + path string + encoding string + }{ + { + "gzip encoding", + "group.gitlab-example.com", + "index.html", + "gzip", + }, + { + "brotli encoding", + "group.gitlab-example.com", + "index.html", + "br", + }, + } + + teardown := RunPagesProcess(t, *pagesBinary, listeners, "") + defer teardown() + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + rsp, err := GetCompressedPageFromListener(t, httpListener, "group.gitlab-example.com", "index.html", tt.encoding) + require.NoError(t, err) + defer rsp.Body.Close() + + require.Equal(t, http.StatusOK, rsp.StatusCode) + require.Equal(t, tt.encoding, rsp.Header.Get("Content-Encoding")) + }) + } +} + func TestArtifactProxyRequest(t *testing.T) { skipUnlessEnabled(t, "not-inplace-chroot") |