Commit 4976259a authored by Pavel Shutsin's avatar Pavel Shutsin

Merge branch 'morefice/fix-artifacts-content-type' into 'master'

Fix artifacts content-type

See merge request gitlab-org/gitlab!83515
parents 4e32a9de e2e17fe6
...@@ -38,6 +38,8 @@ module WorkhorseHelper ...@@ -38,6 +38,8 @@ module WorkhorseHelper
# Send an entry from artifacts through Workhorse # Send an entry from artifacts through Workhorse
def send_artifacts_entry(file, entry) def send_artifacts_entry(file, entry)
headers.store(*Gitlab::Workhorse.send_artifacts_entry(file, entry)) headers.store(*Gitlab::Workhorse.send_artifacts_entry(file, entry))
headers.store(*Gitlab::Workhorse.detect_content_type)
head :ok head :ok
end end
......
...@@ -707,6 +707,7 @@ module API ...@@ -707,6 +707,7 @@ module API
def send_artifacts_entry(file, entry) def send_artifacts_entry(file, entry)
header(*Gitlab::Workhorse.send_artifacts_entry(file, entry)) header(*Gitlab::Workhorse.send_artifacts_entry(file, entry))
header(*Gitlab::Workhorse.detect_content_type)
body '' body ''
end end
......
...@@ -226,6 +226,13 @@ module Gitlab ...@@ -226,6 +226,13 @@ module Gitlab
end end
end end
def detect_content_type
[
Gitlab::Workhorse::DETECT_HEADER,
'true'
]
end
protected protected
# This is the outermost encoding of a senddata: header. It is safe for # This is the outermost encoding of a senddata: header. It is safe for
......
...@@ -323,6 +323,7 @@ RSpec.describe Projects::ArtifactsController do ...@@ -323,6 +323,7 @@ RSpec.describe Projects::ArtifactsController do
subject subject
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response.headers['Gitlab-Workhorse-Detect-Content-Type']).to eq('true')
expect(send_data).to start_with('artifacts-entry:') expect(send_data).to start_with('artifacts-entry:')
expect(params.keys).to eq(%w(Archive Entry)) expect(params.keys).to eq(%w(Archive Entry))
......
...@@ -448,6 +448,14 @@ RSpec.describe Gitlab::Workhorse do ...@@ -448,6 +448,14 @@ RSpec.describe Gitlab::Workhorse do
end end
end end
describe '.detect_content_type' do
subject { described_class.detect_content_type }
it 'returns array setting detect content type in workhorse' do
expect(subject).to eq(%w[Gitlab-Workhorse-Detect-Content-Type true])
end
end
describe '.send_git_blob' do describe '.send_git_blob' do
include FakeBlobHelpers include FakeBlobHelpers
......
...@@ -556,7 +556,8 @@ RSpec.describe API::Ci::JobArtifacts do ...@@ -556,7 +556,8 @@ RSpec.describe API::Ci::JobArtifacts do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response.headers.to_h) expect(response.headers.to_h)
.to include('Content-Type' => 'application/json', .to include('Content-Type' => 'application/json',
'Gitlab-Workhorse-Send-Data' => /artifacts-entry/) 'Gitlab-Workhorse-Send-Data' => /artifacts-entry/,
'Gitlab-Workhorse-Detect-Content-Type' => 'true')
end end
end end
...@@ -626,7 +627,8 @@ RSpec.describe API::Ci::JobArtifacts do ...@@ -626,7 +627,8 @@ RSpec.describe API::Ci::JobArtifacts do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response.headers.to_h) expect(response.headers.to_h)
.to include('Content-Type' => 'application/json', .to include('Content-Type' => 'application/json',
'Gitlab-Workhorse-Send-Data' => /artifacts-entry/) 'Gitlab-Workhorse-Send-Data' => /artifacts-entry/,
'Gitlab-Workhorse-Detect-Content-Type' => 'true')
expect(response.parsed_body).to be_empty expect(response.parsed_body).to be_empty
end end
end end
...@@ -644,7 +646,8 @@ RSpec.describe API::Ci::JobArtifacts do ...@@ -644,7 +646,8 @@ RSpec.describe API::Ci::JobArtifacts do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response.headers.to_h) expect(response.headers.to_h)
.to include('Content-Type' => 'application/json', .to include('Content-Type' => 'application/json',
'Gitlab-Workhorse-Send-Data' => /artifacts-entry/) 'Gitlab-Workhorse-Send-Data' => /artifacts-entry/,
'Gitlab-Workhorse-Detect-Content-Type' => 'true')
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment