+ o Make the PRINT method return the number of bytes written rather than
+ undef to be consistent with the IO:: interface. Fixes RT#24347
+ <David Dick>
o Fix UTF-8 double encoding when FCGI is passed octets by downgrading
them into bytes correctly. Fixes RT#52400 <chansen@cpan.org>
sub PRINT {
my ($stream) = shift;
+ my $bytes = 0;
for (@_) {
- $stream->{src}->write($stream->{type}, $_, length($_));
+ my $len = length($_);
+ $stream->{src}->write($stream->{type}, $_, $len);
+ $bytes += $len;
}
+ return $bytes;
}
sub CLOSE {
#ifndef USE_SFIO
-void
+int
PRINT(stream, ...)
FCGI::Stream stream;
PREINIT:
int n;
+ int retval;
+ int bytes_written;
CODE:
- for (n = 1; n < items; ++n) {
+ retval = 0;
+ bytes_written = 0;
+ for (n = 1; n < items && bytes_written >= 0; ++n) {
STRLEN len;
register char *tmps;
#ifdef DO_UTF8
croak("Wide character in FCGI::Stream::PRINT");
#endif
tmps = (char *)SvPV(ST(n),len);
- FCGX_PutStr(tmps, len, stream);
- }
+ bytes_written = FCGX_PutStr(tmps, len, stream);
+ if (bytes_written > 0) {
+ retval += bytes_written;
+ }
+ }
if (SvTRUEx(perl_get_sv("|", FALSE)))
FCGX_FFlush(stream);
+ RETVAL = retval;
+
+ OUTPUT:
+ RETVAL
int
WRITE(stream, bufsv, len, ...)