]> git.openstreetmap.org Git - rails.git/commitdiff
Rework AMF controller's streaming output for rails 3
authorTom Hughes <tom@compton.nu>
Wed, 22 Sep 2010 21:59:19 +0000 (22:59 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 14 Nov 2011 09:42:46 +0000 (09:42 +0000)
app/controllers/amf_controller.rb
config/initializers/mime_types.rb
test/functional/amf_controller_test.rb

index e776c8d8b30c89b22f2f63e3d88585fcd04d9d2e..96d3602a9219013ca1fc0a2fd29ae1484a7c51fd 100644 (file)
@@ -66,7 +66,10 @@ class AmfController < ApplicationController
       end
 
       bodies=AMF.getint(req)            # Read number of bodies
-      render :content_type => "application/x-amf", :text => proc { |response, output| 
+
+      self.status = :ok
+      self.content_type = Mime::AMF
+      self.response_body = proc { |response, output| 
         a,b=bodies.divmod(256)
         output.write 0.chr+0.chr+0.chr+0.chr+a.chr+b.chr
         bodies.times do                 # Read each body
@@ -114,7 +117,10 @@ class AmfController < ApplicationController
       end
 
       bodies=AMF.getint(req)          # Read number of bodies
-      render :content_type => "application/x-amf", :text => proc { |response, output| 
+
+      self.status = :ok
+      self.content_type = Mime::AMF
+      self.response_body = proc { |response, output| 
         a,b=bodies.divmod(256)
         output.write 0.chr+0.chr+0.chr+0.chr+a.chr+b.chr
         bodies.times do               # Read each body
index 72aca7e441e1855f8c7a7ac1f1cbe5d42cd1235b..c676f6e46c50aa019fcb728a648bd0998d8ec89e 100644 (file)
@@ -3,3 +3,4 @@
 # Add new mime types for use in respond_to blocks:
 # Mime::Type.register "text/richtext", :rtf
 # Mime::Type.register_alias "text/html", :iphone
+Mime::Type.register "application/x-amf", :amf
index 2c76dfc9cc29b5058c9a7d5404f886d73f7ebb04..1ed8ebf485cc365d8c5864028f18400b8d199789 100644 (file)
@@ -577,13 +577,8 @@ class AmfControllerTest < ActionController::TestCase
   # The result is a hash of message_ref => data.
   # The attribute @amf_result is initialised to this hash.
   def amf_parse_response
-    if @response.body.class.to_s == 'Proc'
-      res = StringIO.new()
-      @response.body.call @response, res
-      req = StringIO.new(res.string)
-    else
-      req = StringIO.new(@response.body)
-    end
+    req = StringIO.new(@response.body)
+
     req.read(2)   # version
 
     # parse through any headers