You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by ma...@redhat.com on 2012/11/07 09:22:13 UTC

[PATCH 3/3] CIMI - default to a content type for response when cimi request

From: marios <ma...@redhat.com>


Signed-off-by: marios <ma...@redhat.com>
---
 server/lib/sinatra/rack_accept.rb | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/server/lib/sinatra/rack_accept.rb b/server/lib/sinatra/rack_accept.rb
index 3be919c..9b915d0 100644
--- a/server/lib/sinatra/rack_accept.rb
+++ b/server/lib/sinatra/rack_accept.rb
@@ -79,7 +79,11 @@ module Rack
         end
         yield wants
 
-        if Deltacloud.default_frontend.name == :cimi
+        if request.path.include?("cimi") || Deltacloud.default_frontend.name == :cimi
+          #when cimi and neither json or xml defined... default to _something_  -  json?
+          if ([:json, :xml] & accepting_formats.keys).empty?
+            request.env['rack-accept.formats'] = {:json=>0}
+          end
           @media_type = (accepting_formats.has_key?(:xml) ? [:xml, accepting_formats[:xml]] : nil)
         end if Deltacloud.respond_to? :default_frontend
 
-- 
1.7.11.7


Re: [PATCH 3/3] CIMI - default to a content type for response when cimi request

Posted by "marios@redhat.com" <ma...@redhat.com>.
self.NACK (reason inline) :)

On 07/11/12 10:22, marios@redhat.com wrote:
> From: marios <ma...@redhat.com>
> 
> 
> Signed-off-by: marios <ma...@redhat.com>
> ---
>  server/lib/sinatra/rack_accept.rb | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/server/lib/sinatra/rack_accept.rb b/server/lib/sinatra/rack_accept.rb
> index 3be919c..9b915d0 100644
> --- a/server/lib/sinatra/rack_accept.rb
> +++ b/server/lib/sinatra/rack_accept.rb
> @@ -79,7 +79,11 @@ module Rack
>          end
>          yield wants
>  
> -        if Deltacloud.default_frontend.name == :cimi
> +        if request.path.include?("cimi") || Deltacloud.default_frontend.name == :cimi

Dies pointed out on IRC that request.path.inclue is not the best test...

(10:34:13) dkoper: That said. the code... if
request.path.include?("cimi") , does that affect GET
/api/images/random_image_id_with_cimi_in_it?format=xml ?

Looking at [1] I think using request.env["SCRIPT_NAME"] is a safer bet.
going to resend these patches now.

marios


[1] http://rack.rubyforge.org/doc/SPEC.html


> +          #when cimi and neither json or xml defined... default to _something_  -  json?
> +          if ([:json, :xml] & accepting_formats.keys).empty?
> +            request.env['rack-accept.formats'] = {:json=>0}
> +          end
>            @media_type = (accepting_formats.has_key?(:xml) ? [:xml, accepting_formats[:xml]] : nil)
>          end if Deltacloud.respond_to? :default_frontend
>  
>