Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-11-13 21:09:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-13 21:09:11 +0300
commitfeb61d56e7ce9ab2cd994486bbad9887c3c023f5 (patch)
tree716c5af8f027f560e66123a90f848e7a9c8f80c4 /lib/gitlab/etag_caching
parent37699393e9d68181a04f54ded5ae1b08b6272291 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/etag_caching')
-rw-r--r--lib/gitlab/etag_caching/middleware.rb19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/gitlab/etag_caching/middleware.rb b/lib/gitlab/etag_caching/middleware.rb
index 81cfce6a3db..fc3c05c57b2 100644
--- a/lib/gitlab/etag_caching/middleware.rb
+++ b/lib/gitlab/etag_caching/middleware.rb
@@ -3,6 +3,14 @@
module Gitlab
module EtagCaching
class Middleware
+ SKIP_HEADER_KEY = 'X-Gitlab-Skip-Etag'
+
+ class << self
+ def skip!(response)
+ response.set_header(SKIP_HEADER_KEY, '1')
+ end
+ end
+
def initialize(app)
@app = app
end
@@ -22,9 +30,7 @@ module Gitlab
else
track_cache_miss(if_none_match, cached_value_present, route)
- status, headers, body = @app.call(env)
- headers['ETag'] = etag
- [status, headers, body]
+ maybe_apply_etag(etag, *@app.call(env))
end
end
@@ -43,6 +49,13 @@ module Gitlab
[weak_etag_format(current_value), cached_value_present]
end
+ def maybe_apply_etag(etag, status, headers, body)
+ headers['ETag'] = etag unless
+ Gitlab::Utils.to_boolean(headers.delete(SKIP_HEADER_KEY))
+
+ [status, headers, body]
+ end
+
def weak_etag_format(value)
%Q{W/"#{value}"}
end