I have ActivePerl v5.8.8 build 822 and Windblows Vista Home Premium
with its builtin IIS (but I see the same behaviour under MS Windows
Server 2003) and was using the following to print the CGI headers:
print "HTTP/1.0 200 OK\n" if($ENV{'PerlXS'} eq 'PerlIS');
print "Content-type: text/html\n\n";
Which works with all browsers I know of under both perl.exe and
PerlIS.dll, but the current version of .Net complains with "The
server committed a protocol violation. Section=ResponseStatusLine" if
the script runs under PerlIS. I used a HTTP sniffer and found out
that if I use perl.exe the \n is turned to CRLF, if I do not, it
produces just LF. I tried to add
binmode( STDOUT, ':crlf');
but that did not make any difference. I had to create a custom
PerlIO::via filter.
Why? And has this changed in a later version of ActivePerl? Hopefully
within the 5.8 series. As I'd like the content to end up having CRLF,
but do not want to have to place \x0D into all the heredocs and other
places, I'd rather if I could have \n turned to CRLF under PerlIS.dll
## CGI/ISAPI script
use strict;
use warnings;
no warnings qw(uninitialized);
if ($ENV{'PerlXS'} eq 'PerlIS') {
print "HTTP/1.0 200 OK\x0D\x0A";
print "Content-type: text/plain\x0D\x0A\x0D\x0A";
#=rem
eval <<'*END*';
package PerlIO::via::MyCRLF;
sub PUSHED {
return bless \*PUSHED,$_[0]
}
sub POPPED {return 1}
sub WRITE {
my ($self, $buffer, $fh) = @_; $buffer =~
s/(?:\x0D\x0A?|\x0A)/\x0D\x0A/sg;
print $fh $buffer;
return length($buffer);
}
package main;
binmode(STDOUT, ':via(MyCRLF)');
*END*
#=cut
#binmode(STDOUT, ':crlf');
} else {
print "Content-type: text/plain\n\n";
}
print "First line\nSecond line\n";
__END__
## test script
use LWP::Simple;
my $exe_url = 'http://.../test.pl';
my $dll_url = 'http://.../test.plx';
my $exe_content = get $exe_url;
my $dll_content = get $dll_url;
if ($exe_content =~ /\x0D\x0A/) {
print "EXE returned CRLF\n";
} elsif ($exe_content =~ /\x0A/) {
print "EXE returned LF\n";
} elsif ($exe_content =~ /\x0D/) {
print "EXE returned CR\n";
} else {
print "EXE returned no newlines!!!\n"
}
if ($dll_content =~ /\x0D\x0A/) {
print "DLL returned CRLF\n";
} elsif ($dll_content =~ /\x0A/) {
print "DLL returned LF\n";
} elsif ($dll_content =~ /\x0D/) {
print "DLL returned CR\n";
} else {
print "DLL returned no newlines!!!\n"
}
__END__
Jenda
===== [email protected] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs