Re: How to keep Connection: Keep-Alive

2000-04-03 Thread Ask Bjoern Hansen

On Sat, 1 Apr 2000, Jaime Teng wrote:

 How do you make perl script (either on Linux+Apache+Mod_perl
 or in NT+IIS4 environment) make a "Connection: Keep-Alive".

Set the Content-Length header or play with the Transfer-Encoding:
chunked thing.

From ap_set_keepalive in http_protocol.c.

/* The following convoluted conditional determines whether or not
 * the current connection should remain persistent after this response
 * (a.k.a. HTTP Keep-Alive) and whether or not the output message
 * body should use the HTTP/1.1 chunked transfer-coding.  In English,
 *
 *   IF  we have not marked this connection as errored;
 *   and the response body has a defined length due to the status code
 *   being 304 or 204, the request method being HEAD, already
 *   having defined Content-Length or Transfer-Encoding: chunked, or
 *   the request version being HTTP/1.1 and thus capable of being set
 *   as chunked [we know the (r-chunked = 1) side-effect is ugly];
 *   and the server configuration enables keep-alive;
 *   and the server configuration has a reasonable inter-request timeout;
 *   and there is no maximum # requests or the max hasn't been reached;
 *   and the response status does not require a close;
 *   and the response generator has not already indicated close;
 *   and the client did not request non-persistence (Connection: close);
 *   andwe haven't been configured to ignore the buggy twit
 *   or they're a buggy twit coming through a HTTP/1.1 proxy
 *   andthe client is requesting an HTTP/1.0-style keep-alive
 *   or the client claims to be HTTP/1.1 compliant (perhaps a proxy);
 *   THEN we can be persistent, which requires more headers be output.
 *
 * Note that the condition evaluation order is extremely important.
 */



 - ask

-- 
ask bjoern hansen - http://www.netcetera.dk/~ask/
more than 70M impressions per day, http://valueclick.com




How to keep Connection: Keep-Alive

2000-03-31 Thread Jaime Teng

Hi,

How do you make perl script (either on Linux+Apache+Mod_perl
or in NT+IIS4 environment) make a "Connection: Keep-Alive".

On both environment, the connections always closes after the
perl script finished execution.

Any idea?

Jaime



Re: How to keep Connection: Keep-Alive

2000-03-31 Thread Buddy Lee Haystack

If you're referring to a database connection, the Apache DBI module
keeps the connection alive, not the mod_perl module.

Jaime Teng wrote:
 
 Hi,
 
 How do you make perl script (either on Linux+Apache+Mod_perl
 or in NT+IIS4 environment) make a "Connection: Keep-Alive".
 
 On both environment, the connections always closes after the
 perl script finished execution.
 
 Any idea?
 
 Jaime



Re: How to keep Connection: Keep-Alive

2000-03-31 Thread Clayton Cottingham aka DrFrog

r u  talking about db persistence?

postgres does concurrent persistence checking

what does this mean?

it means it handles the whole db in such a way that  coding persistence 
into your perl progs really isnt nessecary
as postgres handles it all for youn automagically

btw anyone notice how much mysql has been dropping out at freshmeat
lately?!




Buddy Lee Haystack wrote:
 
 If you're referring to a database connection, the Apache DBI module
 keeps the connection alive, not the mod_perl module.
 
 Jaime Teng wrote:
 
  Hi,
 
  How do you make perl script (either on Linux+Apache+Mod_perl
  or in NT+IIS4 environment) make a "Connection: Keep-Alive".
 
  On both environment, the connections always closes after the
  perl script finished execution.
 
  Any idea?
 
  Jaime



Re: How to keep Connection: Keep-Alive

2000-03-31 Thread Jaime Teng

nope. im not referring to database connection.

im referring to the HTTP's "Connection: Keep-Alive"
wherein the browser and the server maintains a socket
connection even after the perl script finished execution.

jaime

At 05:33 PM 3/31/00 -0500, Buddy Lee Haystack wrote:
If you're referring to a database connection, the Apache DBI module
keeps the connection alive, not the mod_perl module.

Jaime Teng wrote:
 
 Hi,
 
 How do you make perl script (either on Linux+Apache+Mod_perl
 or in NT+IIS4 environment) make a "Connection: Keep-Alive".
 
 On both environment, the connections always closes after the
 perl script finished execution.
 
 Any idea?
 
 Jaime
 



Re: How to keep Connection: Keep-Alive

2000-03-31 Thread Buddy Lee Haystack

Hello Dr. Frog!

Any relation to Kermit?

I'm not sure Jaime is referring to PostgreSQL [my favorite open source DB] in 
particular, or even database persistence in general.


Clayton Cottingham aka DrFrog wrote:
 
 r u  talking about db persistence?
 
 postgres does concurrent persistence checking
 
 what does this mean?
 
 it means it handles the whole db in such a way that  coding persistence
 into your perl progs really isnt nessecary
 as postgres handles it all for youn automagically
 
 btw anyone notice how much mysql has been dropping out at freshmeat
 lately?!
 
 Buddy Lee Haystack wrote:
 
  If you're referring to a database connection, the Apache DBI module
  keeps the connection alive, not the mod_perl module.
 
  Jaime Teng wrote:
  
   Hi,
  
   How do you make perl script (either on Linux+Apache+Mod_perl
   or in NT+IIS4 environment) make a "Connection: Keep-Alive".
  
   On both environment, the connections always closes after the
   perl script finished execution.
  
   Any idea?
  
   Jaime



Re: How to keep Connection: Keep-Alive

2000-03-31 Thread Tobias Hoellrich

At 06:40 AM 4/1/00 +0800, Jaime Teng wrote:
nope. im not referring to database connection.

im referring to the HTTP's "Connection: Keep-Alive"
wherein the browser and the server maintains a socket
connection even after the perl script finished execution.

jaime


Keep-Alive is a function of the web-server. There are no script changes
involved to keep a connection alive. All you have to do on the server side
is to enable Keep-Alive. See http://www.apache.org/docs/keepalive.html for
an explanation. 

Hope this helps
  Tobias




Re: How to keep Connection: Keep-Alive

2000-03-31 Thread Cliff Rayman

I just tested my keep-alive via telnet as you suggested.
I am using embperl and mod_perl.
I was able to make three separate requests on the same connection
without a problem.

Here is a copy of one of the headers:
HTTP/1.1 200 OK
Date: Fri, 31 Mar 2000 23:59:53 GMT
Server: Apache/1.3.9 (Unix) mod_perl/1.21 mod_ssl/2.4.8 OpenSSL/0.9.4
Set-Cookie: GWCUID=ad912cb7a7e771d1; domain=.genwax.com; path=/; expires=Friday,
31-Dec-2010 14:00:00 GMT
Content-Length: 26413
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1

does yours come back with:
200 OK
Connection: Keep-Alive
Keep-Alive: timeout etc..  ??

cliff rayman
genwax.com

Jaime Teng wrote:

 Keep-Alive is a function of the web-server. There are no script changes
 involved to keep a connection alive. All you have to do on the server side
 is to enable Keep-Alive. See http://www.apache.org/docs/keepalive.html for
 an explanation.

 The web servers (apache, IIS) already have the Keepalive setting on and
 properly keeps connection alive. The web server keeps the connection alive
 when the browser is fetching static HTML pages.

 Proof: telnet to fetch static document will remain open, ie, i can
 fetch as many static pages from one single telnet session without
 getting "connection to host lost" so long I specify
 "Connection: Keep-Alive" in the telnet session.

 BUT the connection dies when the browser is fetching dynamic mod_perl pages.
 This is where I would like to know if this is a perl/modperl issue or an
 apache/IIS issue.

 Proof: telnet to fetch the perl script will be closed after perl
 finished running the script, ie, I get "connection to host lost"
 immediately after the script finishes.

 is this a perl/modperl issue? where can i get docs to solve this?

 jaime




Re: How to keep Connection: Keep-Alive

2000-03-31 Thread Cliff Rayman

my pages end in '.htm' but they are
dynamically generated.

cliff rayman
genwax.com

Jaime Teng wrote:

 At 04:05 PM 3/31/00 -0800, Cliff Rayman wrote:
 I just tested my keep-alive via telnet as you suggested.
 I am using embperl and mod_perl.
 I was able to make three separate requests on the same connection
 without a problem.
 
 Here is a copy of one of the headers:
 HTTP/1.1 200 OK
 Date: Fri, 31 Mar 2000 23:59:53 GMT
 Server: Apache/1.3.9 (Unix) mod_perl/1.21 mod_ssl/2.4.8 OpenSSL/0.9.4
 Set-Cookie: GWCUID=ad912cb7a7e771d1; domain=.genwax.com; path=/;
 expires=Friday,
 31-Dec-2010 14:00:00 GMT
 Content-Length: 26413
 Keep-Alive: timeout=15, max=100
 Connection: Keep-Alive
 Content-Type: text/html; charset=iso-8859-1
 
 does yours come back with:
 200 OK
 Connection: Keep-Alive
 Keep-Alive: timeout etc..  ??

 what were you fetching above? an html static page or a dynamic
 perl generated page? My problem is making connection keep-alive
 on perl generated pages.

 for static web pages yes i get same one like that
 but for dynamic perl generated pages (with PerlSendHeader On) I get:
 200 OK
 Connection: Closed

 Of course I have to make my  wn http header when I set
 "PerlSendHeader Off" but with same effect
 connection is closed on dynamic perl generated pages.

 also, im sure the perl pages are executed as mod_perl as evident
 by the existence of the "my() subroutine problem" assosiated with
 Apache::Registry

 
 cliff rayman
 genwax.com
 
 Jaime Teng wrote:
 
  Keep-Alive is a function of the web-server. There are no script changes
  involved to keep a connection alive. All you have to do on the server side
  is to enable Keep-Alive. See http://www.apache.org/docs/keepalive.html for
  an explanation.
 
  The web servers (apache, IIS) already have the Keepalive setting on and
  properly keeps connection alive. The web server keeps the connection alive
  when the browser is fetching static HTML pages.
 
  Proof: telnet to fetch static document will remain open, ie, i can
  fetch as many static pages from one single telnet session without
  getting "connection to host lost" so long I specify
  "Connection: Keep-Alive" in the telnet session.
 
  BUT the connection dies when the browser is fetching dynamic mod_perl
 pages.
  This is where I would like to know if this is a perl/modperl issue or an
  apache/IIS issue.
 
  Proof: telnet to fetch the perl script will be closed after perl
  finished running the script, ie, I get "connection to host lost"
  immediately after the script finishes.
 
  is this a perl/modperl issue? where can i get docs to solve this?
 
  jaime
 




Re: How to keep Connection: Keep-Alive

2000-03-31 Thread Jaime Teng

At 04:48 PM 3/31/00 -0800, Cliff Rayman wrote:
my pages end in '.htm' but they are
dynamically generated.

how'd you do it?

can you send me a copy of your http.conf file?
at least the ones that deals with the ".htm" file extensions
and the server config group.

what I have is:

Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 30
MinSpareServers 3
MaxSpareServers 5
StartServers 3
MaxClients 150

Files ~ "\.pl$"
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
PerlSendHeader Off
PerlModule Apache::DBI
/Files



cliff rayman
genwax.com

Jaime Teng wrote:

 At 04:05 PM 3/31/00 -0800, Cliff Rayman wrote:
 I just tested my keep-alive via telnet as you suggested.
 I am using embperl and mod_perl.
 I was able to make three separate requests on the same connection
 without a problem.
 
 Here is a copy of one of the headers:
 HTTP/1.1 200 OK
 Date: Fri, 31 Mar 2000 23:59:53 GMT
 Server: Apache/1.3.9 (Unix) mod_perl/1.21 mod_ssl/2.4.8 OpenSSL/0.9.4
 Set-Cookie: GWCUID=ad912cb7a7e771d1; domain=.genwax.com; path=/;
 expires=Friday,
 31-Dec-2010 14:00:00 GMT
 Content-Length: 26413
 Keep-Alive: timeout=15, max=100
 Connection: Keep-Alive
 Content-Type: text/html; charset=iso-8859-1
 
 does yours come back with:
 200 OK
 Connection: Keep-Alive
 Keep-Alive: timeout etc..  ??

 what were you fetching above? an html static page or a dynamic
 perl generated page? My problem is making connection keep-alive
 on perl generated pages.

 for static web pages yes i get same one like that
 but for dynamic perl generated pages (with PerlSendHeader On) I get:
 200 OK
 Connection: Closed

 Of course I have to make my  wn http header when I set
 "PerlSendHeader Off" but with same effect
 connection is closed on dynamic perl generated pages.

 also, im sure the perl pages are executed as mod_perl as evident
 by the existence of the "my() subroutine problem" assosiated with
 Apache::Registry

 
 cliff rayman
 genwax.com
 
 Jaime Teng wrote:
 
  Keep-Alive is a function of the web-server. There are no script changes
  involved to keep a connection alive. All you have to do on the
server side
  is to enable Keep-Alive. See
http://www.apache.org/docs/keepalive.html for
  an explanation.
 
  The web servers (apache, IIS) already have the Keepalive setting on and
  properly keeps connection alive. The web server keeps the connection
alive
  when the browser is fetching static HTML pages.
 
  Proof: telnet to fetch static document will remain open, ie, i can
  fetch as many static pages from one single telnet session without
  getting "connection to host lost" so long I specify
  "Connection: Keep-Alive" in the telnet session.
 
  BUT the connection dies when the browser is fetching dynamic mod_perl
 pages.
  This is where I would like to know if this is a perl/modperl issue or an
  apache/IIS issue.
 
  Proof: telnet to fetch the perl script will be closed after perl
  finished running the script, ie, I get "connection to host lost"
  immediately after the script finishes.
 
  is this a perl/modperl issue? where can i get docs to solve this?
 
  jaime
 
 



Re: How to keep Connection: Keep-Alive

2000-03-31 Thread Jaime Teng

At 04:48 PM 3/31/00 -0800, Cliff Rayman wrote:
my pages end in '.htm' but they are
dynamically generated.

ps.

are these ".htm" generated by perl?

you mentioned embperl... I dont use embperl.
I strictly use a ".pl" file there must be an
execution difference there making your situation
different from mine.



cliff rayman
genwax.com

Jaime Teng wrote:




Re: How to keep Connection: Keep-Alive

2000-03-31 Thread Cliff Rayman

here are my relevant httpd.conf settings
--- snip ---
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MinSpareServers 5
MaxSpareServers 10
StartServers 5
MaxClients 50
MaxRequestsPerChild 300
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0

Directory /usr/local/apache/htdocs/
  FilesMatch ".*\.html?$"
SetHandler  perl-script
PerlHandler HTML::Embperl
Options ExecCGI
  /FilesMatch
/Directory

PerlRequire conf/startup.pl
--- snip ---

cliff rayman
genwax.com


Jaime Teng wrote:

 At 04:48 PM 3/31/00 -0800, Cliff Rayman wrote:
 my pages end in '.htm' but they are
 dynamically generated.

 how'd you do it?

 can you send me a copy of your http.conf file?
 at least the ones that deals with the ".htm" file extensions
 and the server config group.

 what I have is:

 Timeout 300
 KeepAlive On
 MaxKeepAliveRequests 100
 KeepAliveTimeout 30
 MinSpareServers 3
 MaxSpareServers 5
 StartServers 3
 MaxClients 150

 Files ~ "\.pl$"
 SetHandler perl-script
 PerlHandler Apache::Registry
 Options ExecCGI
 PerlSendHeader Off
 PerlModule Apache::DBI
 /Files

 
 cliff rayman
 genwax.com
 
 Jaime Teng wrote:
 
  At 04:05 PM 3/31/00 -0800, Cliff Rayman wrote:
  I just tested my keep-alive via telnet as you suggested.
  I am using embperl and mod_perl.
  I was able to make three separate requests on the same connection
  without a problem.
  
  Here is a copy of one of the headers:
  HTTP/1.1 200 OK
  Date: Fri, 31 Mar 2000 23:59:53 GMT
  Server: Apache/1.3.9 (Unix) mod_perl/1.21 mod_ssl/2.4.8 OpenSSL/0.9.4
  Set-Cookie: GWCUID=ad912cb7a7e771d1; domain=.genwax.com; path=/;
  expires=Friday,
  31-Dec-2010 14:00:00 GMT
  Content-Length: 26413
  Keep-Alive: timeout=15, max=100
  Connection: Keep-Alive
  Content-Type: text/html; charset=iso-8859-1
  
  does yours come back with:
  200 OK
  Connection: Keep-Alive
  Keep-Alive: timeout etc..  ??
 
  what were you fetching above? an html static page or a dynamic
  perl generated page? My problem is making connection keep-alive
  on perl generated pages.
 
  for static web pages yes i get same one like that
  but for dynamic perl generated pages (with PerlSendHeader On) I get:
  200 OK
  Connection: Closed
 
  Of course I have to make my  wn http header when I set
  "PerlSendHeader Off" but with same effect
  connection is closed on dynamic perl generated pages.
 
  also, im sure the perl pages are executed as mod_perl as evident
  by the existence of the "my() subroutine problem" assosiated with
  Apache::Registry
 
  
  cliff rayman
  genwax.com
  
  Jaime Teng wrote:
  
   Keep-Alive is a function of the web-server. There are no script changes
   involved to keep a connection alive. All you have to do on the
 server side
   is to enable Keep-Alive. See
 http://www.apache.org/docs/keepalive.html for
   an explanation.
  
   The web servers (apache, IIS) already have the Keepalive setting on and
   properly keeps connection alive. The web server keeps the connection
 alive
   when the browser is fetching static HTML pages.
  
   Proof: telnet to fetch static document will remain open, ie, i can
   fetch as many static pages from one single telnet session without
   getting "connection to host lost" so long I specify
   "Connection: Keep-Alive" in the telnet session.
  
   BUT the connection dies when the browser is fetching dynamic mod_perl
  pages.
   This is where I would like to know if this is a perl/modperl issue or an
   apache/IIS issue.
  
   Proof: telnet to fetch the perl script will be closed after perl
   finished running the script, ie, I get "connection to host lost"
   immediately after the script finishes.
  
   is this a perl/modperl issue? where can i get docs to solve this?
  
   jaime
  
 




Re: How to keep Connection: Keep-Alive

2000-03-31 Thread Cliff Rayman

these are all generated thru embperl.

cliff

Jaime Teng wrote:

 At 04:48 PM 3/31/00 -0800, Cliff Rayman wrote:
 my pages end in '.htm' but they are
 dynamically generated.

 ps.

 are these ".htm" generated by perl?

 you mentioned embperl... I dont use embperl.
 I strictly use a ".pl" file there must be an
 execution difference there making your situation
 different from mine.

 
 cliff rayman
 genwax.com
 
 Jaime Teng wrote:
 




Re: How to keep Connection: Keep-Alive

2000-03-31 Thread Jaime Teng

At 05:05 PM 3/31/00 -0800, Cliff Rayman wrote:
these are all generated thru embperl.

cliff



I guess i'll have to install HTML::Embperl to see if it solves my problem.

Unless anyone can show me a solution using Apache::Registry

i prefer to use strict perl program to generate the HTML pages.
I grew accustomed to it already.

jaime



Re: How to keep Connection: Keep-Alive

2000-03-31 Thread Cliff Rayman

how are you sending your headers?
$r-send_cgi_header OR $r-send_http_header('text/html');

is the child that serves the request surviving or is it
dying directly after?

cliff rayman
genwax.com

Jaime Teng wrote:

 At 05:05 PM 3/31/00 -0800, Cliff Rayman wrote:
 these are all generated thru embperl.
 
 cliff
 
 

 I guess i'll have to install HTML::Embperl to see if it solves my problem.

 Unless anyone can show me a solution using Apache::Registry

 i prefer to use strict perl program to generate the HTML pages.
 I grew accustomed to it already.

 jaime




Re: How to keep Connection: Keep-Alive

2000-03-31 Thread Jaime Teng

At 05:19 PM 3/31/00 -0800, you wrote:

my understanding is that you _must_ know the message size in advance and
generate all the appropriate headers (one of them being the size of the
body to follow ... and that's very important since there is no otherway to
know when the whole body has been received) ... embperl may well do that
for you by buffering all the output...

are you saying that with Apache::Registry,  I can write a perl scripted 
dynamic page that can have "Connection: Keep-Alive"?

my .pl scripts puts all output into one single variable $HTTP
and at the very end of the script, it performs print $HTTP;
no print or output to STDOUT is done other than that one.

therefore, the size of the document can be determined before
any IO can be done. 

i'll try that one out now.


On Sat, 1 Apr 2000, Jaime Teng wrote:

 At 04:48 PM 3/31/00 -0800, Cliff Rayman wrote:
 my pages end in '.htm' but they are
 dynamically generated.
 
 ps.
 
 are these ".htm" generated by perl?
 
 you mentioned embperl... I dont use embperl.
 I strictly use a ".pl" file there must be an
 execution difference there making your situation
 different from mine.
 
 
 
 cliff rayman
 genwax.com
 
 Jaime Teng wrote:
 
 

--
[EMAIL PROTECTED]   | Courage is doing what you're afraid to do.
http://BareMetal.com/  | There can be no courage unless you're scared.
   | - Eddie Rickenbacker 
 



Re: How to keep Connection: Keep-Alive

2000-03-31 Thread Jaime Teng

At 05:22 PM 3/31/00 -0800, you wrote:
how are you sending your headers?
$r-send_cgi_header OR $r-send_http_header('text/html');

i dont use CGI.pm.

all output is first sent to a single variable: $HTTP
ie,

$HTTP .= "Content-type: text/html\n\n";
$HTTP .= "HTML\n";

$HTTP .= "/HTML\n";

then at the very end:
print $HTTP;

is the child that serves the request surviving or is it
dying directly after?

err... how do i find that out?

what do you mean by dying? for one thing, If I use a test
script with the classic "my() subroutine problem" it will
show up. - i guess that means, the child is surviving
right?

jaime

cliff rayman
genwax.com

Jaime Teng wrote:

 At 05:05 PM 3/31/00 -0800, Cliff Rayman wrote:
 these are all generated thru embperl.
 
 cliff
 
 

 I guess i'll have to install HTML::Embperl to see if it solves my problem.

 Unless anyone can show me a solution using Apache::Registry

 i prefer to use strict perl program to generate the HTML pages.
 I grew accustomed to it already.

 jaime
 



Re: How to keep Connection: Keep-Alive

2000-03-31 Thread Jaime Teng

At 05:19 PM 3/31/00 -0800, you wrote:

my understanding is that you _must_ know the message size in advance and
generate all the appropriate headers (one of them being the size of the
body to follow ... and that's very important since there is no otherway to
know when the whole body has been received) ... embperl may well do that
for you by buffering all the output...


That solved the problem! I am now able to make the script "Keep-Alive"
the magic was to give out also: "Content-length: sizeofdata" before
the "Content-type: text/html"

Thanks to tom for your insight
and to cliff for giving me something to think about re Embperl!

your help are well appreciated!

jaime