You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2012/05/21 12:06:57 UTC
[PATCH core 16/51] Core: Fixed the respond_to extension to return XML when no media-type
From: Michal Fojtik <mf...@redhat.com>
Signed-off-by: Michal fojtik <mf...@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