rails truncating raw_post_data?

0 views
Skip to first unread message

Aaron Smith

unread,
Aug 20, 2007, 11:45:13 PM8/20/07
to rubyonra...@googlegroups.com
Has anyone ever run into any problems with rails truncating
raw_post_data. My situation is this: I'm the developer for RubyAMF
(wiki.rubyamf.org). Which is a flash remoting application server. With
the rails plugin, it allows flash to talk to a controller and return AMF
data..

So long story short, the flash player makes a request to a rails
controller sending AMF binary format in the raw_post, but I'm having
inconsistent behavior with AMF data being incomplete.

I've narrowed it rails now and am looking for a foot in the right
direction. Either in debugging this myself, or if someone has run into
this...

Right now I grab the raw request like so: request.env["RAW_POST_DATA"].
This is what is being inconsistent in rails.

I've verified this because I can run RubyAMF as a standalone application
server, (takes rails out of the process), and this one bug (incomplete
AMF) that I'm running into NEVER happens. meaning the flash player is
always sending correct AMF, RubyAMF is handling it perfect. But now with
the rails plugin AMF data is being truncated at some point, for some
random reason.

So, does anyone have any ideas? run into this? where to debug??

-Thanks
Aaron
--
Posted via http://www.ruby-forum.com/.

tonypm

unread,
Aug 21, 2007, 2:27:10 PM8/21/07
to Ruby on Rails: Talk
Hi,

I may be way off beam, but if you are using lighttpd:-

I recall having a problem with my raw post data being truncated after
an update to lighttpd, this occurred because I didnt have the mimetype
listed.

just a thought
Tonypm

Aaron Smith

unread,
Aug 21, 2007, 2:55:43 PM8/21/07
to rubyonra...@googlegroups.com

not off base, good though. At least I know someone else has seen this.

So far it happens with webrick, mongrel, and i"m guessing it will with
lighttpd. I'll lighttpd tonight.

What kind of route did you go to debug this? It seems like more of an
issue with Rails, as it's happening with two of the servers.

I'm going to dig into rails and see where the "request" variable is
being setup. I'm thinking I can put some debugging there.. Double
checking that the raw post is correctly coming through the request from
all servers.. if it is, then somewhere in rails it's being truncated.

thanks
-Aaron

Aaron Smith

unread,
Aug 21, 2007, 3:25:06 PM8/21/07
to rubyonra...@googlegroups.com
I actually just found my problem. It's a "bug fix" in actionpack
raw_post_data_fix.rb#read_body. There is this line:

# Fix for Safari Ajax postings that always append \000
content.chop! if content[-1] == 0

But AMF data always appends a \000 as well. So this was causing it to be
truncated.

Now to talk to whomever develops actionpack.

Dave

unread,
Sep 9, 2007, 12:57:47 AM9/9/07
to Ruby on Rails: Talk
I'm seeing the same problem with attachment_fu when saving the image
to the database. When I try to display the image, only 40k appears in
the browser and with some images even that much is not visible (just
garbage when I view source).

Have you heard anything further regarding the bug fix to ActionPack?

-Dave

On Aug 21, 12:25 pm, Aaron Smith <rails-mailing-l...@andreas-s.net>
wrote:

Aaron Smith

unread,
Sep 9, 2007, 3:26:08 AM9/9/07
to rubyonra...@googlegroups.com
Dave Dumaresq wrote:
> I'm seeing the same problem with attachment_fu when saving the image
> to the database. When I try to display the image, only 40k appears in
> the browser and with some images even that much is not visible (just
> garbage when I view source).
>
> Have you heard anything further regarding the bug fix to ActionPack?
>
> -Dave
>
> On Aug 21, 12:25 pm, Aaron Smith <rails-mailing-l...@andreas-s.net>

I know it was a registered bug in the Rails trac system. That's about as
far as I went. In the plugin that I wrote for rails I just handled the
one case where this was causing an issue.

Dave

unread,
Sep 9, 2007, 1:33:53 PM9/9/07
to Ruby on Rails: Talk
Thanks for the reply. I'll bring it up as a new topic and see if
anyone else has run into this.

Cheers,
Dave

On Sep 9, 12:26 am, Aaron Smith <rails-mailing-l...@andreas-s.net>
wrote:

Aaron Smith

unread,
Sep 9, 2007, 2:25:09 PM9/9/07
to rubyonra...@googlegroups.com
Dave Dumaresq wrote:
> Thanks for the reply. I'll bring it up as a new topic and see if
> anyone else has run into this.
>
> Cheers,
> Dave
>
> On Sep 9, 12:26 am, Aaron Smith <rails-mailing-l...@andreas-s.net>

Cool, let me know if you find anything. I'm wondering if this is fixed
in edge rails. I'll take a peek at some point this week.

Richard Fairhurst

unread,
Oct 7, 2007, 11:51:49 AM10/7/07
to rubyonra...@googlegroups.com
Aaron Smith wrote:
> But AMF data always appends a \000 as well. So this was causing it to be
> truncated.
>
> Now to talk to whomever develops actionpack.

Thanks a million for identifying this. I've just spent n hours trying to
fix the same problem - funnily enough, also with a Ruby AMF parser I've
written - and had just decided on the solution of appending a null byte
to the end of the data. I'm reassured to find that this won't just be a
quick-and-dirty fix and that there's actually a real bug that causes me
to do that. :)

Reply all
Reply to author
Forward
0 new messages