# ActionPack raw\_post\_data\_fix.rb#read\_body bug with AMF data

**URL:** <https://www.ruby-forum.com/t/actionpack-raw-post-data-fix-rb-read-body-bug-with-amf-data/112655>\
**Category:** Rails\
**Created:** [August 21, 2007, 9:36pm UTC](https://www.ruby-forum.com/t/actionpack-raw-post-data-fix-rb-read-body-bug-with-amf-data/112655 "2007-08-21T21:36:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ktheory](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e480ec/32.png) [@ktheory](https://www.ruby-forum.com/u/ktheory)\
**Post date:** [August 21, 2007, 9:36pm UTC](https://www.ruby-forum.com/t/actionpack-raw-post-data-fix-rb-read-body-bug-with-amf-data/112655/1 "2007-08-21T21:36:06Z")

</div>

Hey Everyone,

I just found a slight problem with the “read\_body” method in  
raw\_post\_data\_fix.rb.

This line:

# Fix for Safari Ajax postings that always append \000

content.chop! if content[-1] == 0

This causes problems with Flash AMF binary format. As AMF always appends  
a \000 to the stream as well. I’m the developer over at RubyAMF and have  
been running into problems with AMF data being truncated in the Rails  
plugin. This is the cause of it.

So can a condition be put in the method so that if the content-type is  
“application/x-amf” that it doesn’t “chop” the data.

I’ve changed the method to this and it fixes the problem:

–snip  
content\_type = env\_table[‘CONTENT\_TYPE’]  
if content[-1] == 0 && content\_type != ‘application/x-amf’  
content.chop! if content[-1] == 0  
end  
–snip

I can talk with whomever is developing actionpack to give you a  
supporting test cast and how to see what happens with AMF. I would  
really appreciate this, as it’s a knee breaker for RubyAMF.

Thanks much  
Aaron S.

---

<div class="post-metadata">

**Author:** ![ktheory](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e480ec/32.png) [@ktheory](https://www.ruby-forum.com/u/ktheory)\
**Post date:** [August 21, 2007, 9:44pm UTC](https://www.ruby-forum.com/t/actionpack-raw-post-data-fix-rb-read-body-bug-with-amf-data/112655/2 "2007-08-21T21:44:19Z")

</div>

whoops, that method should be:

if content[-1] == 0 && content\_type != ‘application/x-amf’  
content.chop! ####  
end

---

<div class="post-metadata">

**Author:** ![ktheory](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e480ec/32.png) [@ktheory](https://www.ruby-forum.com/u/ktheory)\
**Post date:** [August 22, 2007, 3:11pm UTC](https://www.ruby-forum.com/t/actionpack-raw-post-data-fix-rb-read-body-bug-with-amf-data/112655/3 "2007-08-22T15:11:53Z")

</div>

Just an update. I can handle this issue with Rails truncating the last  
byte, but just for future AMF support in Rails it would be good to have  
that in there.
