You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "B. Burke" <bc...@mindspring.com> on 2000/09/28 23:23:50 UTC

Update: Re: PerlSendHeader Off & socket persistence (was Re: question: usingApache for non-HTML messages)

> what is your test client?
I wrote a command line client that just sends/receives basic messages for testing.

I have been opening a socket and sending this:
GET /perl/myscript HTTP/1.1
Connection: Keep-Alive
Host: myhost.mydomain.com\n\n

It worked as expected - I was able to keep the socket open and send & receive
multiple
messages.  When I set PerlSendHeader to Off, the socket closed after the 1st query.

I finally had success with socket persistence when I tried using CGI to print the
header
by replacing this:
print "Content-type: text/html\n\n";
with this:
print header();

Once I changed how I was printing the header from the script, the socket
persistence
worked with PerlSendHeader Off.  So I guess I solved my problem although I don't
really
know why.

Brian


Doug MacEachern wrote:

> On Wed, 27 Sep 2000, B. Burke wrote:
>
> > When I set PerlSendHeader to Off in my perl.conf it doesn't send headers,
> > which
> > is good.  The bad part is that it seems to break socket persistence for some
> > reason.
> > When I have PerlSendHeader set to On, I can open a socket with my test client,
> >
> > and make multiple queries on the same socket.
>
> what is your test client?  apache will close the connection after the
> first request, unless keep-alive is maintained between client/server.


Re: Update: Re: PerlSendHeader Off & socket persistence (was Re:question: usingApache for non-HTML messages)

Posted by Doug MacEachern <do...@covalent.net>.
On Mon, 2 Oct 2000, B. Burke wrote:

> Why would the lack of a $r->send_http_header call cause socket persistence
> to go away?  I was under the impression that $r->send_http_header only affected
> what was sent to the client, but appearantly it affects Apache's socket handling
> as well.

because send_http_header calls set_keepalive underneath, set_keepalive
sets the flags so apache will keep the connection open.  try the patch
below and add $r->set_keepalive to your code.

> 2) how can I make apache stop printing the outbound message size on each response

what headers exactly is your client sending?  you must be somehow
triggering chunked encoding.

Index: src/modules/perl/Apache.xs
===================================================================
RCS file: /home/cvs/modperl/src/modules/perl/Apache.xs,v
retrieving revision 1.114
diff -u -r1.114 Apache.xs
--- src/modules/perl/Apache.xs	2000/09/28 19:28:33	1.114
+++ src/modules/perl/Apache.xs	2000/10/02 21:23:28
@@ -937,6 +937,10 @@
     send_http_header(r);
     mod_perl_sent_header(r, 1);
 
+void
+set_keepalive(r)
+    Apache	r
+
 #ifndef PERL_OBJECT
 
 int


Re: Update: Re: PerlSendHeader Off & socket persistence (was Re:question: usingApache for non-HTML messages)

Posted by "B. Burke" <bc...@mindspring.com>.
Why would the lack of a $r->send_http_header call cause socket persistence
to go away?  I was under the impression that $r->send_http_header only affected
what was sent to the client, but appearantly it affects Apache's socket handling
as well.

When I don't use $r->send_http_header, my sockets are dying after Apache's
response to the 1st query...dying from the apache side, not the client side.  I have
my test client hard-coded to keep the socket open and send keepalives on every
request.

Since I don't want the server to send headers, but I want socket persistence, I'm in
a bind.  I've tried tracing through the apache source and commenting out stuff I
don't need (manually removing headers, the ugly way).  However I cannot find the
code segiment that prints the outbound hexidecimal message size (which I also
want to remove), so I'm stuck for the moment.

It seems I need to know 1 of 2 things:
1) How do you keep sockets open when $r->send_http_header isn't used
2) how can I make apache stop printing the outbound message size on each response

Any help will be appreciated!

Brian

Doug MacEachern wrote:

> On Thu, 28 Sep 2000, B. Burke wrote:
>
> > Once I changed how I was printing the header from the script, the socket
> > persistence
> > worked with PerlSendHeader Off.  So I guess I solved my problem although I don't
> > really
> > know why.
>
> because CGI.pm will trigger a call to $r->send_http_header, regardless of
> PerlSendHeader settings.  whereas: "print Content-type: text/html\n\n";
> will not, unless PerlSendHeader is On.


Re: Update: Re: PerlSendHeader Off & socket persistence (was Re: question: usingApache for non-HTML messages)

Posted by Doug MacEachern <do...@covalent.net>.
On Thu, 28 Sep 2000, B. Burke wrote:
 
> Once I changed how I was printing the header from the script, the socket
> persistence
> worked with PerlSendHeader Off.  So I guess I solved my problem although I don't
> really
> know why.

because CGI.pm will trigger a call to $r->send_http_header, regardless of
PerlSendHeader settings.  whereas: "print Content-type: text/html\n\n";
will not, unless PerlSendHeader is On.