diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-05-06 19:54:41 +0200 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-05-07 08:53:32 +0200 |
commit | 8d8534d7ab31ef9f7bdc4e00c54bcda9d9bf93d9 (patch) | |
tree | 056de43f43ad53bb447820b86ed92475441d5ec2 /lib/api | |
parent | 1f39fcd1123c1a65798a0a0b3e5f3b2fa43651ac (diff) | |
download | gitlab-ce-8d8534d7ab31ef9f7bdc4e00c54bcda9d9bf93d9.tar.gz |
Enforce proper 416 support for runner trace patch endpoint
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/runner.rb | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/api/runner.rb b/lib/api/runner.rb index 67896ae1fc5..cd7d6603171 100644 --- a/lib/api/runner.rb +++ b/lib/api/runner.rb @@ -153,9 +153,20 @@ module API content_range = request.headers['Content-Range'] content_range = content_range.split('-') - stream_size = job.trace.append(request.body.read, content_range[0].to_i) - if stream_size < 0 - break error!('416 Range Not Satisfiable', 416, { 'Range' => "0-#{-stream_size}" }) + # TODO: + # it seems that `Content-Range` as formatted by runner is wrong, + # the `byte_end` should point to final byte, but it points byte+1 + # that means that we have to calculate end of body, + # as we cannot use `content_length[1]` + # Issue: https://gitlab.com/gitlab-org/gitlab-runner/issues/3275 + + body_data = request.body.read + body_start = content_range[0].to_i + body_end = body_start + body_data.bytesize + + stream_size = job.trace.append(body_data, body_start) + unless stream_size == body_end + break error!('416 Range Not Satisfiable', 416, { 'Range' => "0-#{stream_size}" }) end status 202 |