You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Paul Simon <wr...@yahoo.com> on 2002/10/03 21:10:43 UTC

Response Headers

How do HTTP headers work under Registery::ModPerl?
set up: windows2000 apache2.0.42 mod_perl/1.99_08-dev Perl/v5.8.0

I had to comment out the following in the CGI script:

#print "Expires: " . time2str( time() + 432000 ) . "\n";
#print "Content-type: text/html\n\n";

because it would print out as content to the browser??

This is in the conf file:

Alias /standards/ "C:/Apache2/application/standards2/"
<Location "/standards/">
     SetHandler perl-script
     PerlResponseHandler ModPerl::Registry
     #PerlOptions +ParseHeaders
     Options +ExecCGI
</Location>

If somebody could point me in the right direction ->

Thanks.



---------------------------------
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!

Re: Response Headers

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Fri, 4 Oct 2002, Paul Simon wrote:

> On Thu, 3 Oct 2002, Paul Simon wrote:

>> I'm still having problems with sending an Expires in the
>> header.  You mentioned, "Apache will send one for you, based
>> on, in particular, the DefaultType setting."

>> Can I configure the DefaultType in apache?

Yes, you can - look at the Apache documentation for the
syntax. "DefaultType" refers to the default mime type that
that apache will use for a request if it can't otherwise
determine one (such as from a file extension). 

> Ok. I answered my own question, using mod_expires.  A little off OT...

Not too OT for mod_perl - see
http://perl.apache.org/docs/general/correct_headers/correct_headers.html
for a discussion. For sending the Expires header yourself in a 
script, using mod_perl-2, you can do

my $expires = Apache::Util::ht_time(time + 180*24*60*60);
print <<"END";
Expires: $expires
Content-type: text/html\n\n
whatever_else
END

which would require
   PerlOptions +ParseHeaders
in the relevant section of httpd.conf.

-- 
best regards,
randy 


Re: Response Headers

Posted by Paul Simon <wr...@yahoo.com>.
Ok. I answered my own question, using mod_expires.  A little off OT...
 Paul Simon wrote:
 
 Randy Kobes wrote: 
On Thu, 3 Oct 2002, Paul Simon wrote:

> 
> How do HTTP headers work under Registery::ModPerl?
> set up: windows2000 apache2.0.42 mod_perl/1.99_08-dev Perl/v5.8.0
> 
> I had to comment out the following in the CGI script:
> 
> #print "Expires: " . time2str( time() + 432000 ) . "\n";
> #print "Content-type: text/html\n\n";
> 
> because it would print out as content to the browser??
> 
> This is in the conf file:
> 
> Alias /standards/ "C:/Apache2/application/standards2/"
> 
> SetHandler perl-script
> PerlResponseHandler ModPerl::Registry
> #PerlOptions +ParseHeaders
> Options +ExecCGI
> 
> 
> If somebody could point me in the right direction ->
> 
> Thanks.

If you send the headers yourself, as, eg,
print "Content-type: text/html\n\n";
in the script, then you should have
PerlOptions +ParseHeaders 
in the relevant section. If you don't send the header yourself,
Apache will send one for you, based on, in particular, the
DefaultType setting. In this case you shouldn't have
PerlOptions +ParseHeaders
in that section. As you found, other combinations can lead
to a double set of headers sent, resulting in one of
them appearing in the browser.

-- 
best regards,
randy kobes


I have a pilot web app running with the above set-up (It's working really well, *fingers crossed*).  

I understand your explanation. I'm still having problems with sending an Expires in the header.  You mentioned, "Apache will send one for you, based on, in particular, the DefaultType setting."

Can I configure the DefaultType in apache?

The way I have it now is:
print "Content-type: text/html\n\n";
in the CGI script

And in the conf file:

<Location "/standards/">
     SetHandler perl-script
     PerlResponseHandler ModPerl::Registry
     PerlOptions +ParseHeaders
     Options +ExecCGI
</Location>

Here's the response header from the server:

HTTP/1.1 200 OK
Date: Fri, 04 Oct 2002 13:40:30 GMT
Server: Apache/2.0.42 (Win32) mod_perl/1.99_08-dev Perl/v5.8.0
Connection: close
Content-Type: text/html; charset=ISO-8859-1

My current goal is to cache the pages on the client browser.  Ultimately, I'd like to cache on the server side too ( as you would've guessed :) ) I'm learning as I go... 



---------------------------------
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!


---------------------------------
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!

Re: Response Headers

Posted by Paul Simon <wr...@yahoo.com>.
 
 Randy Kobes wrote:
On Thu, 3 Oct 2002, Paul Simon wrote:

> 
> How do HTTP headers work under Registery::ModPerl?
> set up: windows2000 apache2.0.42 mod_perl/1.99_08-dev Perl/v5.8.0
> 
> I had to comment out the following in the CGI script:
> 
> #print "Expires: " . time2str( time() + 432000 ) . "\n";
> #print "Content-type: text/html\n\n";
> 
> because it would print out as content to the browser??
> 
> This is in the conf file:
> 
> Alias /standards/ "C:/Apache2/application/standards2/"
> 
> SetHandler perl-script
> PerlResponseHandler ModPerl::Registry
> #PerlOptions +ParseHeaders
> Options +ExecCGI
> 
> 
> If somebody could point me in the right direction ->
> 
> Thanks.

If you send the headers yourself, as, eg,
print "Content-type: text/html\n\n";
in the script, then you should have
PerlOptions +ParseHeaders 
in the relevant section. If you don't send the header yourself,
Apache will send one for you, based on, in particular, the
DefaultType setting. In this case you shouldn't have
PerlOptions +ParseHeaders
in that section. As you found, other combinations can lead
to a double set of headers sent, resulting in one of
them appearing in the browser.

-- 
best regards,
randy kobes


I have a pilot web app running with the above set-up (It's working really well, *fingers crossed*).  

I understand your explanation. I'm still having problems with sending an Expires in the header.  You mentioned, "Apache will send one for you, based on, in particular, the DefaultType setting."

Can I configure the DefaultType in apache?

The way I have it now is:
print "Content-type: text/html\n\n";
in the CGI script

And in the conf file:

<Location "/standards/">
     SetHandler perl-script
     PerlResponseHandler ModPerl::Registry
     PerlOptions +ParseHeaders
     Options +ExecCGI
</Location>

Here's the response header from the server:

HTTP/1.1 200 OK
Date: Fri, 04 Oct 2002 13:40:30 GMT
Server: Apache/2.0.42 (Win32) mod_perl/1.99_08-dev Perl/v5.8.0
Connection: close
Content-Type: text/html; charset=ISO-8859-1

My current goal is to cache the pages on the client browser.  Ultimately, I'd like to cache on the server side too ( as you would've guessed :) ) I'm learning as I go... 



---------------------------------
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!

Re: Response Headers

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Thu, 3 Oct 2002, Paul Simon wrote:

> 
> How do HTTP headers work under Registery::ModPerl?
> set up: windows2000 apache2.0.42 mod_perl/1.99_08-dev Perl/v5.8.0
> 
> I had to comment out the following in the CGI script:
> 
> #print "Expires: " . time2str( time() + 432000 ) . "\n";
> #print "Content-type: text/html\n\n";
> 
> because it would print out as content to the browser??
> 
> This is in the conf file:
> 
> Alias /standards/ "C:/Apache2/application/standards2/"
> <Location "/standards/">
>      SetHandler perl-script
>      PerlResponseHandler ModPerl::Registry
>      #PerlOptions +ParseHeaders
>      Options +ExecCGI
> </Location>
> 
> If somebody could point me in the right direction ->
> 
> Thanks.

If you send the headers yourself, as, eg,
    print "Content-type: text/html\n\n";
in the script, then you should have
    PerlOptions +ParseHeaders 
in the relevant section. If you don't send the header yourself,
Apache will send one for you, based on, in particular, the
DefaultType setting. In this case you shouldn't have
    PerlOptions +ParseHeaders
in that section. As you found, other combinations can lead
to a double set of headers sent, resulting in one of
them appearing in the browser.

-- 
best regards,
randy kobes