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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.