deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 16/51] Core: Fixed the respond_to extension to return XML when no media-type
Date Mon, 21 May 2012 10:06:57 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/lib/sinatra/rack_accept.rb |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/server/lib/sinatra/rack_accept.rb b/server/lib/sinatra/rack_accept.rb
index e4a0f1f..4286e93 100644
--- a/server/lib/sinatra/rack_accept.rb
+++ b/server/lib/sinatra/rack_accept.rb
@@ -79,9 +79,16 @@ module Rack
           @media_type ||= accepting_formats.to_a.sort { |a,b| a[1]<=>b[1] }.reverse.select
do |format, priority|
             wants.keys.include?(format) == true
           end.first
+          if @media_type and @media_type.kind_of? Symbol
+            @media_type = [ @media_type ]
+          end
           if @media_type and @media_type[0]
             @media_type = @media_type[0]
-            headers 'Content-Type' => Rack::MediaType::ACCEPTED_MEDIA_TYPES[@media_type][:return]
+            if  Rack::MediaType::ACCEPTED_MEDIA_TYPES[@media_type]
+              headers 'Content-Type' => Rack::MediaType::ACCEPTED_MEDIA_TYPES[@media_type][:return]
+            else
+              headers 'Content-Type' => 'application/xml'
+            end
             wants[@media_type.to_sym].call if wants[@media_type.to_sym]
           else
             headers 'Content-Type' => nil
-- 
1.7.10.1


Mime
View raw message