Hi, I had a problem whereby when sending a '304 Not Changed' Perl/Apache would send a Content-Type, which the HTTP/1.1 protocol states should not be sent with this status. rfc2616 Section 10.3.5
Try:
print "Status: 304 Not Changed\n\n";
or using CGI
print header(-status => '304 Not Changed');
and you will see the Content-Type header is generated.
I was directed towards using NPH CGI NPH and so prepended 'nph-' to my script name and added all the appropriate headers that were prevously filled in by Apache.
Now with this code the Content-Type is no longer sent, which is what is specified in the rfc
print "Status: 304 Not Changed\n\n";
But using CGI
print header(-status => '304 Not Changed');
With this the Content-Type header is still generated.
So I used the print method and not the CGI method for sending HTTP headers.
Now my issue is that Connection: Keep-Alive no longer functions, I can create and send the headers to the client but when my script exits the connection is closed. I tested this using telnet and performing GET requests. rfc2616 Section 14.10 Apache Keep-Alive
So my questions are, can I interact with Apache in some way so that I can use Connection: Keep-Alive when running a NPH script or is there some other solution that I have missed along the way that fixes both the 304 and Keep-Alive issue? (I am using Perl 5.6.1 and Apache 1.3.26 on a hosted server over which I have little control.)
Any help or pointers are greatly appreciated
In reply to NPH and Connection: Keep-Alive by gfairweather
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |