summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-09-04 07:49:01 -0700
committerStan Hu <stanhu@gmail.com>2015-09-04 07:49:01 -0700
commite8bbc83771a249170812edd33d5554042c051908 (patch)
tree4eb69425f40a00e4b2925c3279b574b75e83e427
parent69beca5ae962cc0364b8918253307861e9535255 (diff)
parent4144c59941e8e91bbaff2c68e757af0f01f7997d (diff)
downloadgitlab-ce-e8bbc83771a249170812edd33d5554042c051908.tar.gz
Merge pull request #9598 from darkrasid/master
Add image content-type header in raw download
-rw-r--r--CHANGELOG1
-rw-r--r--app/controllers/projects/raw_controller.rb2
-rw-r--r--spec/controllers/projects/raw_controller_spec.rb14
3 files changed, 17 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 7a773a7ed1d..8154d4333d9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -36,6 +36,7 @@ v 8.0.0 (unreleased)
- Refactored service API and added automatically service docs generator (Kirill Zaitsev)
- Added web_url key project hook_attrs (Kirill Zaitsev)
- Add ability to get user information by ID of an SSH key via the API
+ - Fix bug which IE cannot show image at markdown when the image is raw file of gitlab
v 7.14.1
- Improve abuse reports management from admin area
diff --git a/app/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb
index 1a3df40dc75..5f6fbce795e 100644
--- a/app/controllers/projects/raw_controller.rb
+++ b/app/controllers/projects/raw_controller.rb
@@ -29,6 +29,8 @@ class Projects::RawController < Projects::ApplicationController
def get_blob_type
if @blob.text?
'text/plain; charset=utf-8'
+ elsif @blob.image?
+ @blob.content_type
else
'application/octet-stream'
end
diff --git a/spec/controllers/projects/raw_controller_spec.rb b/spec/controllers/projects/raw_controller_spec.rb
index 1f921d5f05d..c114f342021 100644
--- a/spec/controllers/projects/raw_controller_spec.rb
+++ b/spec/controllers/projects/raw_controller_spec.rb
@@ -19,5 +19,19 @@ describe Projects::RawController do
to eq("inline")
end
end
+
+ context 'image header' do
+ let(:id) { 'master/files/images/6049019_460s.jpg' }
+
+ it 'set image content type header' do
+ get(:show,
+ namespace_id: public_project.namespace.to_param,
+ project_id: public_project.to_param,
+ id: id)
+
+ expect(response.status).to eq(200)
+ expect(response.header['Content-Type']).to eq('image/jpeg')
+ end
+ end
end
end