perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: [mp2] api/sendfile.t on Win32
Date Thu, 01 Jul 2004 07:17:57 GMT
Randy Kobes wrote:
> 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. 

May be there weren't any \n lines in it?

> Another way to get the test as written
> to pass is is to open the file in binary mode:

I'm now not sure what's going on win32, <fh> removes \r but sendfile not?

> ===========================================================
> 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.

Adding a short comment why we use binmode should be good enough I believe. Go 
ahead and commit that patch (+comment). Thanks Randy.




-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message