In case of Etag cache hit, the body should be empty

This commit is contained in:
Toon Claes 2017-04-05 14:27:49 +02:00 committed by Kamil Trzcinski
parent 847b9c8232
commit 751dae58e6
No known key found for this signature in database
GPG key ID: 4505F5C7E12C6A5A
2 changed files with 7 additions and 1 deletions

View file

@ -69,7 +69,7 @@ module Gitlab
status_code = Gitlab::PollingInterval.polling_enabled? ? 304 : 429
[status_code, { 'ETag' => etag }, ['']]
[status_code, { 'ETag' => etag }, []]
end
def track_cache_miss(if_none_match, cached_value_present, route)

View file

@ -91,6 +91,12 @@ describe Gitlab::EtagCaching::Middleware do
expect(status).to eq 304
end
it 'returns empty body' do
_, _, body = middleware.call(build_env(path, if_none_match))
expect(body).to be_empty
end
it 'tracks "etag_caching_cache_hit" event' do
expect(Gitlab::Metrics).to receive(:add_event)
.with(:etag_caching_middleware_used, endpoint: 'issue_notes')