views:

55

answers:

1

I'm trying to return a 200 status with an empty body but rails returns a body with a single space. i.e. content-length 1

For instance, this code generates a body with the single space

respond_to do |f|
  f.html {head :ok}
end

and so does this

respond_to do |f|
  f.html {render :nothing => true}
end

Yes, even render :nothing generates something.

All of this seems to be flowing from a 2005 patch in rails that was designed to fix a bug in Safari where it would ignore the headers if the body was empty. (http://dev.rubyonrails.org/changeset/1818)

Does anyone have any thoughts on how to get a 200 status but with a truly empty body? Background: I'm using an API that makes calls to my controllers. I need to send a 200 but the single space body causes the API to malfunction (parse error...). Also, I'll be deploying to Heroku so I can't patch ActionPack to undo the 2005 hack.

Thanks for any thoughts.

+2  A: 

This appears to work

render :text => ""
ngoozeff
This works for me too! You're awesome! Thanks for the very quick response. I love how your response is super simple too.
rhh