2018-08-18 11:19:57 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-07-03 21:01:13 +00:00
|
|
|
# Helpers to send Git blobs, diffs, patches or archives through Workhorse.
|
2016-06-06 11:16:30 +00:00
|
|
|
# Workhorse will also serve files when using `send_file`.
|
|
|
|
module WorkhorseHelper
|
|
|
|
# Send a Git blob through Workhorse
|
2018-07-13 01:24:11 +00:00
|
|
|
def send_git_blob(repository, blob, inline: true)
|
2016-06-06 11:16:30 +00:00
|
|
|
headers.store(*Gitlab::Workhorse.send_git_blob(repository, blob))
|
2018-12-06 21:22:39 +00:00
|
|
|
|
2018-12-19 11:51:07 +00:00
|
|
|
headers['Content-Disposition'] = inline ? 'inline' : 'attachment'
|
2018-12-06 21:22:39 +00:00
|
|
|
|
|
|
|
# If enabled, this will override the values set above
|
|
|
|
workhorse_set_content_type!
|
|
|
|
|
2018-06-06 02:28:32 +00:00
|
|
|
render plain: ""
|
2016-06-06 11:16:30 +00:00
|
|
|
end
|
|
|
|
|
2016-06-08 12:30:15 +00:00
|
|
|
# Send a Git diff through Workhorse
|
|
|
|
def send_git_diff(repository, diff_refs)
|
|
|
|
headers.store(*Gitlab::Workhorse.send_git_diff(repository, diff_refs))
|
|
|
|
headers['Content-Disposition'] = 'inline'
|
|
|
|
head :ok
|
|
|
|
end
|
|
|
|
|
2016-07-03 21:01:13 +00:00
|
|
|
# Send a Git patch through Workhorse
|
|
|
|
def send_git_patch(repository, diff_refs)
|
|
|
|
headers.store(*Gitlab::Workhorse.send_git_patch(repository, diff_refs))
|
|
|
|
headers['Content-Disposition'] = 'inline'
|
|
|
|
head :ok
|
|
|
|
end
|
|
|
|
|
2016-06-06 11:16:30 +00:00
|
|
|
# Archive a Git repository and send it through Workhorse
|
2018-02-19 20:41:04 +00:00
|
|
|
def send_git_archive(repository, **kwargs)
|
|
|
|
headers.store(*Gitlab::Workhorse.send_git_archive(repository, **kwargs))
|
2016-06-06 11:16:30 +00:00
|
|
|
head :ok
|
|
|
|
end
|
2016-07-05 14:58:38 +00:00
|
|
|
|
|
|
|
# Send an entry from artifacts through Workhorse
|
2020-05-15 18:07:52 +00:00
|
|
|
def send_artifacts_entry(file, entry)
|
|
|
|
headers.store(*Gitlab::Workhorse.send_artifacts_entry(file, entry))
|
2016-07-05 14:58:38 +00:00
|
|
|
head :ok
|
|
|
|
end
|
2016-08-19 17:10:41 +00:00
|
|
|
|
|
|
|
def set_workhorse_internal_api_content_type
|
|
|
|
headers['Content-Type'] = Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE
|
|
|
|
end
|
2018-12-06 21:22:39 +00:00
|
|
|
|
|
|
|
def workhorse_set_content_type!
|
2018-12-19 11:51:07 +00:00
|
|
|
headers[Gitlab::Workhorse::DETECT_HEADER] = "true"
|
2018-12-06 21:22:39 +00:00
|
|
|
end
|
2016-06-06 11:16:30 +00:00
|
|
|
end
|