Rails 3, Glassfish Gem, and request.raw_post

I encountered an issue where request.raw_post consistently returned
nil within a Rails 3 controller. I initially developed the Rails
application using WEBrick, which always provided the raw POST data.
Examining the params hash on each request showed that the raw data was
making it to Rails. The first key/value pair in the params hash
looked like:

{"{\"foo\": \"bar\"}", nil}

This behavior was consistent with WEBrick. Also, changing the request
Content-Type to application/json generated this params hash:

{"foo": "bar"}

Again, consistent with WEBrick.

In summary, request.raw_post did not seem to be giving me access to
the raw POST data. My additional explanation is basically the
workaround I used to capture the POST data. In hindsight, posting
with the correct Content-Type seems more correct, but the raw data
should also be available.


Hector

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs