gfairweather has asked for the wisdom of the Perl Monks concerning the following question:
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: NPH and Connection: Keep-Alive
by ikegami (Patriarch) on Mar 24, 2009 at 13:53 UTC | |
by gfairweather (Novice) on Mar 24, 2009 at 15:06 UTC | |
by ikegami (Patriarch) on Mar 24, 2009 at 16:39 UTC | |
by gfairweather (Novice) on Mar 25, 2009 at 11:32 UTC | |
by gfairweather (Novice) on Apr 01, 2009 at 02:26 UTC | |
Re: NPH and Connection: Keep-Alive
by eric256 (Parson) on Mar 24, 2009 at 21:59 UTC | |
by gfairweather (Novice) on Mar 24, 2009 at 23:28 UTC | |
by gfairweather (Novice) on Apr 01, 2009 at 02:29 UTC |