Skip Menu |

This queue is for tickets about the FCGI CPAN distribution.

Report information
The Basics
Id: 52400
Status: resolved
Priority: 0/
Queue: FCGI

Owner: Nobody in particular
Requestors: GRAF [...]

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)

Subject: Unintentional utf8 encoding
Download (untitled) / with headers
text/plain 118b
FCGI automatically utf-8 encodes a buffer when the utf-8 flag is set. Try this, please:
Show quoted text
...expired - therefore uploaded here.
text/x-perl 2k
#!/usr/bin/env perl use strict; use warnings; use utf8; use FCGI; use File::Temp (); use FCGI::Client::Connection; use Getopt::Std; use IO::Socket; use POSIX (); use Time::HiRes 'sleep'; my %opts; getopts('u', \%opts); my %env; my $socketfile = File::Temp::tmpnam; # $t gets a string perl's internal representation my $t = "Bäh\n"; print qq{\n*** Call me with option "-u" to show FCGI's brokeness ***\n\n} unless $opts{u}; print "original un-encoded content (might look broken on unicode terminal):\n"; print $t, "\n"; print "content ", (utf8::is_utf8($t) ? 'is' : 'is not'), " utf8\n"; print "\n"; print "content is encoded into a utf-8 octet stream\n"; # encode into utf-8 encoded octet stream utf8::encode($t); print "done\n"; print "content ", (utf8::is_utf8($t) ? 'is' : 'is not'), " utf8\n"; print "\n"; if ($opts{u}) { print "content's utf-8 flag is set again\n"; # set utf-8 flag (again) utf8::upgrade($t); print "done\n"; print "\$t ", (utf8::is_utf8($t) ? 'is' : 'is not'), " utf8\n"; print "\n"; } print "Content to be queried through FCGI:\n"; print $t, "\n"; my $pid = fork(); if ($pid) { # parent my $con = FCGI::Client::Connection->new(sock => create_socket()); my ($stdout, $stderr) = $con->request( {REQUEST_METHOD => 'GET', QUERY_STRING => ''}, '' ); print "Content received through FCGI:\n"; print $stdout; kill TERM => $pid; wait; } elsif (defined $pid) { # child print "FastCGI daemon started (pid $$)\n"; open STDIN, "+</dev/null" or die $!; open STDOUT, ">&STDIN" or die $!; open STDERR, ">&STDIN" or die $!; POSIX::setsid(); my $sock = FCGI::OpenSocket($socketfile, 100 ) or die "failed to open FastCGI socket; $!"; my $request = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%env, $sock ); while($request->Accept() >= 0) { print $t; } } else { die "cannot fork\n"; } sub create_socket { my $retry = 20; while ($retry-- >= 0) { my $sock = IO::Socket::UNIX->new(Peer => $socketfile); return $sock if $sock; sleep 0.3; } die "cannot open socket $socketfile: $!"; }
Download (untitled) / with headers
text/plain 315b
Hey, is there any chance you can try and turn this into a t/ file so we've at least got a proper test for it? git repo is - git:// and discussion is currently taking place on #catalyst-dev (and no, it's not on failhub yet - give me a pubkey and I'll give you a branch though)
This issue has been fixed in the latest release.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to