]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/amf_controller.rb
Split the rest action into sparate read, update and delete actions thus
[rails.git] / app / controllers / amf_controller.rb
index 8e23a18ccc66611cf6ef9f9ba375c6c899bc0f8b..1049b51b61d0735cb28d31986815df51c1d1005c 100644 (file)
@@ -34,11 +34,11 @@ class AmfController < ApplicationController
       args=getvalue(req)                               #  | get response (probably an array)
 
       case message
-      when 'getpresets';       results[index]=putdata(index,getpresets)
-      when 'whichways';                results[index]=putdata(index,whichways(args))
-      when 'getway';           results[index]=putdata(index,getway(args))
-      when 'putway';           results[index]=putdata(index,putway(args))
-      when 'deleteway';                results[index]=putdata(index,deleteway(args))
+                 when 'getpresets';    results[index]=putdata(index,getpresets)
+                 when 'whichways';             results[index]=putdata(index,whichways(args))
+                 when 'getway';                results[index]=putdata(index,getway(args))
+                 when 'putway';                results[index]=putdata(index,putway(args))
+                 when 'deleteway';             results[index]=putdata(index,deleteway(args))
       end
     end
 
@@ -46,15 +46,14 @@ class AmfController < ApplicationController
     # Write out response
 
     RAILS_DEFAULT_LOGGER.info("  Response: start")
-    response.headers["Content-Type"]="application/x-amf"
     a,b=results.length.divmod(256)
-    ans=0.chr+0.chr+0.chr+0.chr+a.chr+b.chr
-    results.each do |k,v|
-      RAILS_DEFAULT_LOGGER.info("  Response: encode #{k}")
-      ans+=v
-    end
+       render :content_type => "application/x-amf", :text => proc { |response, output| 
+        output.write 0.chr+0.chr+0.chr+0.chr+a.chr+b.chr
+               results.each do |k,v|
+                 output.write(v)
+               end
+       }
     RAILS_DEFAULT_LOGGER.info("  Response: end")
-    render :text => ans
 
   end
 
@@ -254,7 +253,7 @@ EOF
     ActiveRecord::Base.connection.execute("SET #{db_now}=NOW()")
     originalway=originalway.to_i
 
-    RAILS_DEFAULT_LOGGER.info("  Message: putway, id=#{way}")
+    RAILS_DEFAULT_LOGGER.info("  Message: putway, id=#{originalway}")
 
     # -- 3.    read original way into memory