Forum Moderators: DixonJones
I made this nph script and put it in my cgi-bin directory. I gave it the clever name of 'nph-script'
#! /usr/bin/perl -w
use strict;
print "HTTP/1.1 200 OK\n";
print "Content-Type: text/plain\n\n";
print "1234567";
I do the necessary chmod's and call it up on my browser through the web; it works fine. But then I look in the logfiles and see
198.137.240.91 - - [12/Jul/2001:23:59:02 -0400] "GET /cgi-bin/nph-script HTTP/1.1" 200 -
What's that "-" doing where the transfer length is supposed to be? So think, aha! My nph script doesn't give a proper content-length. So I fix it like this:
#! /usr/bin/perl -w
use strict;
print "HTTP/1.1 200 OK\n";
print "Content-Length: 7\n"; # set content-length
print "Content-Type: text/plain\n\n";
print "1234567";
Good idea, but that doesn't fix it. Just to make sure I'm not going batty, I rename the script to "not-an-nph-script", rem off the "print HTTP/1.1" line, and voila, I get the correct logfile entry:
198.137.240.91 - - [13/Jul/2001:00:02:40 -0400] "GET /cgi-bin/not-an-nph-script HTTP/1.1" 200 7
What's up? Is this some bug that I should know about logging nph-scripts on Apache?
Bolotomus
No luck. Your comment that the nph-script shows a length bigger than the actual output (presumably in the logfiles) makes sense to me--of course, apache would consider the header of an NPH script as part of the output whereas normally it wouldn't. BUT in my case I cannot get the logfiles to show any length for nph-scripts, ever. Maybe I should try this experiment on a few other servers... perhaps its something about the particular release of Apache I'm using, or something...
One thing I've learned. If I ever use somebody's system where I'm paying by the BYTE for execution of cgi scripts, I'm gonna make *everything* an nph script... :)
Bolotomus
Like little said, it is Apache's inability to count the output and record it. Apache uses the same routine to report content length to the browser. Apache Can NOT know what the header length is going to be and turns off the content length counter on nphs's (has too). It's a known issue and it will require more code overhead for them to address - so they've skipped it. There was a message last fall (couldn't find it via google) in comp info servers about this issue.