[Catalyst] Serving binary content with Catalyst

Kentucky Mandeloid Mo. ky at df.ru
Tue Aug 22 10:01:14 CEST 2006


Hi, all
I have some issue with serving binary content through Cat using FastCGI 
engine.
Sometimes in the server logs appears messages like 
....FastCGI sent in stderr: "UTF-16 surrogate 0xd80f 
at /usr/lib/perl/5.8/IO/Handle.pm line 199"....

I think FCGI output stream is set to :utf8 somewhere.
So I just need to binmode it to :raw.

Sounds easy but I unable to find a way how to do that other then patch 
Engine::FastCGI.

Actually what I found is that binmode doesn't help at all even if it placed in 
FastCGI.pm just before *STDOUT->syswrite().
What helped was change from syswrite() to write().
However there are notes in the .pm:
"# FastCGI does not stream data properly if using 'print $handle',
# but a syswrite appears to work properly."

Placing 'no warnings "utf8"' just before the syswrite() call doesn't make 
sence too.

The only way to I found is using write() instead of syswrite().

Is there a proper way to serve binary content with Catalyst?








More information about the Catalyst mailing list