Merge pull request #1177 from ahorek/content_type

[webdav] add content type for html reponses
This commit is contained in:
Karel Picman 2020-09-19 06:46:53 +02:00 committed by GitHub
commit ca1cbb9738
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 0 deletions

View File

@ -200,6 +200,7 @@ module RedmineDmsf
if collection?
html_display
response['Content-Length'] = response.body.bytesize.to_s
response['Content-Type'] = 'text/html'
else
raise Forbidden unless User.current.admin? || User.current.allowed_to?(:view_dmsf_files, project)
response.body = download # Rack based provider

View File

@ -68,6 +68,7 @@ module RedmineDmsf
def get(request, response)
html_display
response['Content-Length'] = response.body.bytesize.to_s
response['Content-Type'] = 'text/html'
OK
end

View File

@ -97,6 +97,7 @@ module RedmineDmsf
def get(request, response)
html_display
response['Content-Length'] = response.body.bytesize.to_s
response['Content-Type'] = 'text/html'
OK
end

View File

@ -41,6 +41,13 @@ class DmsfWebdavGetTest < RedmineDmsf::Test::IntegrationTest
assert_response :success
end
def test_should_include_response_headers
get '/dmsf/webdav', params: nil, headers: @admin
assert_response :success
assert_equal 'text/html', response.headers['Content-Type']
assert response.headers['Content-Length'].to_i > 0, "Content-Length should be > 0, but was #{response.headers['Content-Length']}"
end
def test_should_list_dmsf_enabled_project
get '/dmsf/webdav', params: nil, headers: @admin
assert_response :success