tee_input: safer record separator ($/) handling
commit4fa17dfb4adef0945d73e692147a3302b8dd9b74
authorEric Wong <normalperson@yhbt.net>
Thu, 8 Jul 2010 05:14:55 +0000 (8 05:14 +0000)
committerEric Wong <normalperson@yhbt.net>
Thu, 8 Jul 2010 05:40:45 +0000 (8 05:40 +0000)
treebe853ea38b0870b8eb3efa4d8f03dcb19e3df204
parenta77c60a372273b24866346482255c4cf21240d60
tee_input: safer record separator ($/) handling

Different threads may change $/ during execution, so cache it at
function entry to a local variable for safety.  $/ may also be
of a non-binary encoding, so rely on Rack::Utils.bytesize to
portably capture the correct size.

Our string slicing is always safe from 1.9 encoding: both our
socket and backing temporary file are opened in binary mode,
so we'll always be dealing with binary strings in this class
(in accordance to the Rack spec).
(cherry picked from commit 1cd698f8c7938b1f19e9ba091708cb4515187939)
lib/unicorn/tee_input.rb