Render text and byte lengths

Just a quick tip for Ruby on Rails; Don’t do render :text => 1 Rather do render :text => '1'

The former causes problems over HTTP when the client is expecting a content length of 4 but only getting 1. You get hanging connections which eventually reset. The latter render will send down the proper content length.

It seems obvious but thanks to the loose typing of Ruby you can, and I did, easily get bitten.

Trackbacks

close Reblog this comment
blog comments powered by Disqus