diff options
Diffstat (limited to 'lib/ci')
-rw-r--r-- | lib/ci/api/api.rb | 2 | ||||
-rw-r--r-- | lib/ci/api/builds.rb | 20 |
2 files changed, 18 insertions, 4 deletions
diff --git a/lib/ci/api/api.rb b/lib/ci/api/api.rb index 4e85d2c3c74..353c4ddebf8 100644 --- a/lib/ci/api/api.rb +++ b/lib/ci/api/api.rb @@ -23,6 +23,8 @@ module Ci rack_response({ 'message' => '500 Internal Server Error' }, 500) end + content_type :txt, 'text/plain' + content_type :json, 'application/json' format :json helpers ::Ci::API::Helpers diff --git a/lib/ci/api/builds.rb b/lib/ci/api/builds.rb index 61e15675535..decee3739c8 100644 --- a/lib/ci/api/builds.rb +++ b/lib/ci/api/builds.rb @@ -51,12 +51,24 @@ module Ci end patch ":id/trace.txt" do - authenticate_runner! - update_runner_last_contact - build = Ci::Build.where(runner_id: current_runner.id).running.find(params[:id]) + build = Ci::Build.find_by_id(params[:id]) + not_found! unless build + authenticate_build_token!(build) forbidden!('Build has been erased!') if build.erased? - build.append_trace(params[:trace_part]) + error!('400 Missing header Content-Range', 400) unless request.headers.has_key?('Content-Range') + content_range = request.headers['Content-Range'] + content_range = content_range.split('-') + + unless build.trace_length == content_range[0].to_i + return error!('416 Range Not Satisfiable', 416, { 'Range' => "0-#{build.trace_length}" }) + end + + build.append_trace(request.body.read) + + status 202 + header 'Build-Status', build.status + header 'Range', "0-#{build.trace_length}" end # Authorize artifacts uploading for build - Runners only |