On Wed, 30 Jun 2004, Stas Bekman wrote:
> Randy Kobes wrote:
> > On Wed, 30 Jun 2004, Stas Bekman wrote:
> >
> >
> >>Randy Kobes wrote:
> >>
> >>>On Win32, the first subtest of api/sendfile.t fails
> >>>due to different line endings. This diff:
> [...]
> >>> my $received = GET_BODY($url);
> >>>+ $received =~ s{\r}{}g if Apache::TestConfig::WIN32;
> [...]
> >>>==================================================================
> >>>fixes it.
> >>
> >>How about a fix without win32 branching -- just drop "\n"
> >>on both sides? Or is it the one coming from a file that is
> >>sendfile'd?
> >
> > It's that coming from the file being sendfile'd. And I guess
> > we shouldn't alter with what sendfile produces?
>
> Hmm, is that correct at all? why would it stuff \r into a
> file that didn't have it? Or does it do that only for text
> files (assuming it somehow figures out it's not a binary
> file). What if you send an image file, does it stuff \r
> there too if it finds \n?
Maybe I didn't understand the original comment ... But I
tried sending a png file, and they compared as equal without
the \r substitution. Another way to get the test as written
to pass is is to open the file in binary mode:
===========================================================
Index: t/api/sendfile.t
===================================================================
RCS file: /home/cvs/modperl-2.0/t/api/sendfile.t,v
retrieving revision 1.7
diff -u -r1.7 sendfile.t
--- t/api/sendfile.t 29 Jun 2004 22:56:16 -0000 1.7
+++ t/api/sendfile.t 1 Jul 2004 06:16:46 -0000
@@ -20,6 +20,7 @@
open my $fh, $file or die "can't open $file: $!";
local $/;
+ binmode $fh;
my $expected = join '', $header, <$fh>, $footer;
close $fh;
=============================================================
This should be OK on unix too, but is a little unintuitive
to a casual reader - unix people wouldn't open a simple text
file like this in binary mode, as there's no reason, and
Win32 people don't want to open a text file in binary mode,
unless they want the \r line endings.
It sounds like then that sendfile sends either a text or
binary file in binary mode, without doing a \r translation.
--
best regards,
randy
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]