deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [46/50] [abbrv] git commit: Core: Fixed the respond_to extension to return XML when no media-type
Date Tue, 22 May 2012 20:19:38 GMT
Core: Fixed the respond_to extension to return XML when no media-type


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/f866431d
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/f866431d
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/f866431d

Branch: refs/heads/master
Commit: f866431d2c4789518eec595438cab3c9f879337e
Parents: 09cb888
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Tue Apr 17 15:36:08 2012 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Tue May 22 22:17:35 2012 +0200

----------------------------------------------------------------------
 server/lib/sinatra/rack_accept.rb |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/f866431d/server/lib/sinatra/rack_accept.rb
----------------------------------------------------------------------
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


Mime
View raw message