ACK

Applies cleanly, works like a charm on my Chrome. Way to go!

Thomas

----- Original Message -----
From: [email protected]
To: [email protected]
Sent: Wednesday, June 9, 2010 11:04:59 AM GMT +01:00 Amsterdam / Berlin / Bern 
/ Rome / Stockholm / Vienna
Subject: [deltacloud-devel] [PATCH core] Fixed Chrome accept headers (rev 4)

---
 server/lib/sinatra/respond_to.rb |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/server/lib/sinatra/respond_to.rb b/server/lib/sinatra/respond_to.rb
index 64b3cd7..b87f784 100644
--- a/server/lib/sinatra/respond_to.rb
+++ b/server/lib/sinatra/respond_to.rb
@@ -48,10 +48,7 @@ module Sinatra
           rpi = request.path_info.sub(%r{\.([^\./]+)$}, '')
 
           if (not $1) or ($1 and TEXT_MIME_TYPES.include?($1.to_sym))
-
-            request.path_info=rpi
-            ext = nil
-
+            request.path_info, ext = rpi, nil
             if ! $1.nil?
               ext = $1
             elsif env['HTTP_ACCEPT'].nil? || env['HTTP_ACCEPT'].empty?
@@ -240,6 +237,13 @@ module Sinatra
       def match_accept_type(mime_types, format)
         selected = []
         accepted_types = mime_types.map {|type| 
Regexp.escape(type).gsub(/\\\*/,'.*') }
+        # Fix for Chrome based browsers which returns XML when 'xhtml' is 
requested.
+        if env['HTTP_USER_AGENT'] =~ /Chrome/ and accepted_types.size>1
+          accepted_types[0], accepted_types[1] = accepted_types[1], 
accepted_types[0]
+          if accepted_types[0].eql?('application/xhtml\\+xml')
+            accepted_types[0] = 'text/html'
+          end
+        end
         accepted_types.each do |at|
           format.each do |fmt, ht, handler|
             (selected = [fmt, ht, handler]) and break if ht.match(at)
-- 
1.7.1

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to