Here are 2 snippets that you can try to see the effect.

hello.pl

#!/usr/bin/perl -w use CGI::Carp qw(fatalsToBrowser); use strict; use warnings; use CGI qw(:standard ); my $http_body_length = 0; my $http_body = "<html>\n<head>\n</head>\n<body>\n<p>Hello World</p>\n +</body>\n</html>\n"; { use bytes; $http_body_length = length($http_body); } print header(-type => 'text/html', -content_length => $http_body_length ); print $http_body;

You will see that hello.pl sends keep-alives as expected as the headers are parsed by Apache and the connection remains open

nph-hello.pl

#!/usr/bin/perl -w use CGI::Carp qw(fatalsToBrowser); use strict; use warnings; use CGI qw(:standard ); my $http_body_length = 0; my $http_body = "<html>\n<head>\n</head>\n<body>\n<p>Hello World</p>\n +</body>\n</html>\n"; { use bytes; $http_body_length = length($http_body); } print header(-type => 'text/html', -content_length => $http_body_length, -nph => 1); print $http_body;

You will see that nph-hello.pl does not send keep-alives as the headers are not parsed by Apache and the connection closes upon exit

I have tried adding the 'Connection' and 'Keep-Alive' headers to nph-hello.pl and of course they are sent but Apache does not keep the connection open. Example:

print header(-type => 'text/html', -content_length => $http_body_length, -connection => 'Keep-Alive', -nph => 1);

This is what I am trying to accomplish.


In reply to Re^4: NPH and Connection: Keep-Alive by gfairweather
in thread 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.