2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
module API
|
|
|
|
module Helpers
|
|
|
|
module HeadersHelpers
|
2020-02-01 01:16:34 +05:30
|
|
|
include Gitlab::NoCacheHeaders
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
def set_http_headers(header_data)
|
|
|
|
header_data.each do |key, value|
|
2018-11-18 11:00:15 +05:30
|
|
|
if value.is_a?(Enumerable)
|
2021-06-08 01:23:25 +05:30
|
|
|
raise ArgumentError, "Header value should be a string"
|
2018-11-18 11:00:15 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
header "X-Gitlab-#{key.to_s.split('_').collect(&:capitalize).join('-')}", value.to_s
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
end
|
2020-02-01 01:16:34 +05:30
|
|
|
|
|
|
|
def no_cache_headers
|
|
|
|
DEFAULT_GITLAB_NO_CACHE_HEADERS.each do |k, v|
|
|
|
|
header k, v
|
|
|
|
end
|
|
|
|
end
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|