Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

special cased */* accept header

  • Loading branch information...
commit 02a67bc547c0d90565cb0a8a2b0ead95a7e6238b 1 parent 95274b0
Dane Harrigan authored April 15, 2012

Showing 1 changed file with 9 additions and 2 deletions. Show diff stats Hide diff stats

  1. 11  lib/respond_with/response.rb
11  lib/respond_with/response.rb
@@ -27,7 +27,7 @@ def request_types
27 27
       format = params.delete "format"
28 28
       content_type = MIME::Types.type_for(format).first.to_s if format
29 29
 
30  
-      unless content_type.nil? && request.accept.first == content_type
  30
+      if content_type && request.accept.first != content_type
31 31
         request.accept.delete content_type
32 32
         request.accept.unshift content_type
33 33
       end
@@ -39,11 +39,18 @@ def request_types
39 39
 
40 40
     def available_responses
41 41
       responses = request_types.map do |request_type|
42  
-        if @object.responses.include? request_type
  42
+        if @object.responses.include?(request_type)
43 43
           [request_type, 1.0]
44 44
         end
45 45
       end.compact
46 46
 
  47
+      if request_types.include? "*/*"
  48
+        @object.responses.each do |response_type|
  49
+          response_rating = [response_type, 1.0]
  50
+          responses << response_rating unless responses.include? response_rating
  51
+        end
  52
+      end
  53
+
47 54
       Hash[responses]
48 55
     end
49 56
 

0 notes on commit 02a67bc

Please sign in to comment.
Something went wrong with that request. Please try again.