diff options
author | Adam Niedzielski <adamsunday@gmail.com> | 2017-06-07 12:11:26 +0300 |
---|---|---|
committer | Adam Niedzielski <adamsunday@gmail.com> | 2017-06-07 12:15:33 +0300 |
commit | 280529c7f40db6af7bb0bfd3ef30d330bbafc225 (patch) | |
tree | 8eb0da7809d446e363982098d07c4036b513ffc4 /lib | |
parent | dddc54aa0aea4088e5a233d18a62cb2435590fe9 (diff) |
Fix incorrect ETag cache key when relative instance URL is used
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/etag_caching/middleware.rb | 9 | ||||
-rw-r--r-- | lib/gitlab/etag_caching/router.rb | 4 |
2 files changed, 7 insertions, 6 deletions
diff --git a/lib/gitlab/etag_caching/middleware.rb b/lib/gitlab/etag_caching/middleware.rb index 270d67dd50c..7f884183bb1 100644 --- a/lib/gitlab/etag_caching/middleware.rb +++ b/lib/gitlab/etag_caching/middleware.rb @@ -6,12 +6,13 @@ module Gitlab end def call(env) - route = Gitlab::EtagCaching::Router.match(env) + request = Rack::Request.new(env) + route = Gitlab::EtagCaching::Router.match(request) return @app.call(env) unless route track_event(:etag_caching_middleware_used, route) - etag, cached_value_present = get_etag(env) + etag, cached_value_present = get_etag(request) if_none_match = env['HTTP_IF_NONE_MATCH'] if if_none_match == etag @@ -27,8 +28,8 @@ module Gitlab private - def get_etag(env) - cache_key = env['PATH_INFO'] + def get_etag(request) + cache_key = request.path store = Gitlab::EtagCaching::Store.new current_value = store.get(cache_key) cached_value_present = current_value.present? diff --git a/lib/gitlab/etag_caching/router.rb b/lib/gitlab/etag_caching/router.rb index ca49eda51fb..dccc66b3918 100644 --- a/lib/gitlab/etag_caching/router.rb +++ b/lib/gitlab/etag_caching/router.rb @@ -53,8 +53,8 @@ module Gitlab ) ].freeze - def self.match(env) - ROUTES.find { |route| route.regexp.match(env['PATH_INFO']) } + def self.match(request) + ROUTES.find { |route| route.regexp.match(request.path_info) } end end end |