You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2012/05/22 22:19:38 UTC
[46/50] [abbrv] git commit: Core: Fixed the respond_to extension to
return XML when no media-type
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 <mf...@redhat.com>
Authored: Tue Apr 17 15:36:08 2012 +0200
Committer: Michal fojtik <mf...@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