public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Added application/jsonrequest as a synonym for application/json

[#536 state:resolved]
subelsky (author)
Wed Jul 02 11:15:43 -0700 2008
technoweenie (committer)
Wed Jul 02 11:39:42 -0700 2008
commit  8f640c381d9d1b74f6a0fc3648c21da373661914
tree    d179b1200ce573847076301646fac854e66b11ab
parent  a4138d46321d63012adbf1942f5ea7c5e4951fc9
...
17
18
19
20
21
 
 
22
...
17
18
19
 
20
21
22
23
0
@@ -17,4 +17,5 @@ Mime::Type.register "multipart/form-data", :multipart_form
0
 Mime::Type.register "application/x-www-form-urlencoded", :url_encoded_form
0
 
0
 # http://www.ietf.org/rfc/rfc4627.txt
0
-Mime::Type.register "application/json", :json, %w( text/x-json )
0
\ No newline at end of file
0
+# http://www.json.org/JSONRequest.html
0
+Mime::Type.register "application/json", :json, %w( text/x-json application/jsonrequest )
0
\ No newline at end of file
...
909
910
911
912
913
 
 
 
 
 
 
 
 
914
915
916
917
918
919
920
 
 
921
922
923
...
909
910
911
 
 
912
913
914
915
916
917
918
919
920
921
922
923
924
 
 
925
926
927
928
929
0
@@ -909,15 +909,21 @@ class LegacyXmlParamsParsingTest < XmlParamsParsingTest
0
 end
0
 
0
 class JsonParamsParsingTest < Test::Unit::TestCase
0
-  def test_hash_params
0
-    person = parse_body({:person => {:name => "David"}}.to_json)[:person]
0
+  def test_hash_params_for_application_json
0
+    person = parse_body({:person => {:name => "David"}}.to_json,'application/json')[:person]
0
+    assert_kind_of Hash, person
0
+    assert_equal 'David', person['name']
0
+  end
0
+
0
+  def test_hash_params_for_application_jsonrequest
0
+    person = parse_body({:person => {:name => "David"}}.to_json,'application/jsonrequest')[:person]
0
     assert_kind_of Hash, person
0
     assert_equal 'David', person['name']
0
   end
0
 
0
   private
0
-    def parse_body(body)
0
-      env = { 'CONTENT_TYPE'   => 'application/json',
0
+    def parse_body(body,content_type)
0
+      env = { 'CONTENT_TYPE'   => content_type,
0
               'CONTENT_LENGTH' => body.size.to_s }
0
       cgi = ActionController::Integration::Session::StubCGI.new(env, body)
0
       ActionController::CgiRequest.new(cgi).request_parameters

Comments