Rework AMF controller's streaming output for rails 3

This commit is contained in:
Tom Hughes 2010-09-22 22:59:19 +01:00
parent 35e60d4d7b
commit b89486eab0
3 changed files with 11 additions and 9 deletions

View 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

View 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

View 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