mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Bug #1472: Set content-type header correctly for OCCI/Self-Service responses
(cherry picked from commit 1f9748aabc7aa2e00ac9df5601ebc89454f7b909)
This commit is contained in:
parent
d8e3c2011e
commit
f44f143386
@ -150,6 +150,7 @@ end
|
||||
|
||||
before do
|
||||
cache_control :no_store
|
||||
content_type 'application/xml', :charset => 'utf-8'
|
||||
unless request.path=='/ui/login' || request.path=='/ui'
|
||||
if !authorized?
|
||||
begin
|
||||
@ -245,6 +246,7 @@ helpers do
|
||||
def treat_response(result,rc)
|
||||
if OpenNebula::is_error?(result)
|
||||
logger.error {result.message}
|
||||
content_type 'text/plain', :charset => 'utf-8'
|
||||
halt rc, result.message
|
||||
end
|
||||
|
||||
@ -325,6 +327,7 @@ post '/compute/:id/action' do
|
||||
when 'detachdisk' then
|
||||
@occi_server.detach_disk(request, params, xml)
|
||||
else
|
||||
content_type 'text/plain', :charset => 'utf-8'
|
||||
halt 403, "Action #{xml['PERFORM']} not supported"
|
||||
end
|
||||
|
||||
@ -421,6 +424,7 @@ post '/ui/config' do
|
||||
begin
|
||||
body = JSON.parse(request.body.read)
|
||||
rescue
|
||||
content_type 'text/plain', :charset => 'utf-8'
|
||||
[500, "POST Config: Error parsing configuration JSON"]
|
||||
end
|
||||
|
||||
@ -446,6 +450,7 @@ post '/ui/logout' do
|
||||
end
|
||||
|
||||
get '/ui' do
|
||||
content_type 'text/html', :charset => 'utf-8'
|
||||
if !authorized?
|
||||
return File.read(File.dirname(__FILE__)+'/ui/templates/login.html')
|
||||
end
|
||||
@ -462,6 +467,7 @@ get '/ui' do
|
||||
end
|
||||
|
||||
post '/ui/upload' do
|
||||
content_type 'application/json', :charset => 'utf-8'
|
||||
#so we can re-use occi post_storage()
|
||||
request.params['file'] = {:tempfile => request.env['rack.input']}
|
||||
result,rc = @occi_server.post_storage(request)
|
||||
@ -469,11 +475,13 @@ post '/ui/upload' do
|
||||
end
|
||||
|
||||
post '/ui/startvnc/:id' do
|
||||
content_type 'application/json', :charset => 'utf-8'
|
||||
vm_id = params[:id]
|
||||
@occi_server.startvnc(vm_id, settings.vnc)
|
||||
end
|
||||
|
||||
get '/ui/accounting' do
|
||||
content_type 'application/json', :charset => 'utf-8'
|
||||
@occi_server.get_user_accounting(params)
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user