summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-02-03 14:50:28 +0100
committerKamil Trzciński <ayufan@ayufan.eu>2018-02-03 14:51:09 +0100
commita7aa7416f42c2093f197f836b34f2df0021c82d5 (patch)
treedf7ee64b13bcefc8c266b4edd7aefe109b4f83b7
parent23ecc841c6f2a1a9f095c500aae38a340632e1f4 (diff)
downloadgitlab-ce-use-send-url-for-incompatible-runners.tar.gz
Support SendURL for performing indirect download of artifacts if clients does not specify that it supports thatuse-send-url-for-incompatible-runners
-rw-r--r--changelogs/unreleased/use-send-url-for-incompatible-runners.yml6
-rw-r--r--lib/api/helpers.rb7
-rw-r--r--lib/api/runner.rb3
-rw-r--r--lib/gitlab/workhorse.rb11
4 files changed, 24 insertions, 3 deletions
diff --git a/changelogs/unreleased/use-send-url-for-incompatible-runners.yml b/changelogs/unreleased/use-send-url-for-incompatible-runners.yml
new file mode 100644
index 00000000000..6e924a9ee0b
--- /dev/null
+++ b/changelogs/unreleased/use-send-url-for-incompatible-runners.yml
@@ -0,0 +1,6 @@
+---
+title: Support SendURL for performing indirect download of artifacts if clients does
+ not specify that it supports that
+merge_request:
+author:
+type: fixed
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 6134ad2bfc7..39547dabf15 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -426,13 +426,16 @@ module API
end
end
- def present_artifacts!(artifacts_file)
+ def present_artifacts!(artifacts_file, direct_download: true)
return not_found! unless artifacts_file.exists?
if artifacts_file.file_storage?
present_file!(artifacts_file.path, artifacts_file.filename)
- else
+ elsif direct_download
redirect_to(artifacts_file.url)
+ else
+ headers.store(*Gitlab::Workhorse.send_url(artifacts_file.url))
+ head :ok
end
end
diff --git a/lib/api/runner.rb b/lib/api/runner.rb
index 80feb629d54..d3857b4a503 100644
--- a/lib/api/runner.rb
+++ b/lib/api/runner.rb
@@ -244,11 +244,12 @@ module API
params do
requires :id, type: Integer, desc: %q(Job's ID)
optional :token, type: String, desc: %q(Job's authentication token)
+ optional :direct_download, type: Boolean, desc: %q(Perform direct download of artifacts)
end
get '/:id/artifacts' do
job = authenticate_job!
- present_artifacts!(job.artifacts_file)
+ present_artifacts!(job.artifacts_file, params[:direct_download])
end
end
end
diff --git a/lib/gitlab/workhorse.rb b/lib/gitlab/workhorse.rb
index 633da44b22d..b0d21f4917b 100644
--- a/lib/gitlab/workhorse.rb
+++ b/lib/gitlab/workhorse.rb
@@ -158,6 +158,17 @@ module Gitlab
]
end
+ def send_url(url)
+ params = {
+ 'URL' => url
+ }
+
+ [
+ SEND_DATA_HEADER,
+ "send-url:#{encode(params)}"
+ ]
+ end
+
def terminal_websocket(terminal)
details = {
'Terminal' => {