2018-09-29 18:34:47 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-06-28 02:10:51 -04:00
|
|
|
module API
|
|
|
|
module Helpers
|
|
|
|
module HeadersHelpers
|
2020-01-30 16:08:47 -05:00
|
|
|
include Gitlab::NoCacheHeaders
|
|
|
|
|
2018-06-28 02:10:51 -04:00
|
|
|
def set_http_headers(header_data)
|
|
|
|
header_data.each do |key, value|
|
2018-08-01 12:48:33 -04:00
|
|
|
if value.is_a?(Enumerable)
|
|
|
|
raise ArgumentError.new("Header value should be a string")
|
|
|
|
end
|
|
|
|
|
|
|
|
header "X-Gitlab-#{key.to_s.split('_').collect(&:capitalize).join('-')}", value.to_s
|
2018-06-28 02:10:51 -04:00
|
|
|
end
|
|
|
|
end
|
2020-01-30 16:08:47 -05:00
|
|
|
|
|
|
|
def no_cache_headers
|
|
|
|
DEFAULT_GITLAB_NO_CACHE_HEADERS.each do |k, v|
|
|
|
|
header k, v
|
|
|
|
end
|
|
|
|
end
|
2018-06-28 02:10:51 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|