Re: Creating a filter for all text/html files

2005-02-01 Thread Philippe M. Chiasson
Scott Gifford wrote:
Hello,
[...]
I've got it working right now, but I'd like it to know the
Content-Type that Apache would use for a document, so I can decide
whether to filter it and so I can send a correct Content-Type header.
$r->content_type should tell you that.
http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html#C_content_type_
I can try to guess the content-type from the filename (which is what
I'm doing now), but I'd prefer not to re-implement Apache's system for
deciding content types, and I'd also like it to Do The Right Thing for
CGI/mod_perl scripts, where you can't tell by the filename what
content-type they're going to output.
Yes, certainly a good idea not to do anything of the sort. Let Apache tell 
you
that.

Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5


signature.asc
Description: OpenPGP digital signature


Re: Creating a filter for all text/html files

2005-02-01 Thread Geoffrey Young

> I can try to guess the content-type from the filename (which is what
> I'm doing now), but I'd prefer not to re-implement Apache's system for
> deciding content types, and I'd also like it to Do The Right Thing for
> CGI/mod_perl scripts, where you can't tell by the filename what
> content-type they're going to output.

in addition to what philippe said, Apache::Clean for mp2 should prove as a
good example for you to follow:

  http://search.cpan.org/~geoff/Apache-Clean-2.00_4/

see also the two articles on perl.com that talk about this particular module:

  http://www.perl.com/pub/a/2003/04/17/filters.html
  http://www.perl.com/pub/a/2003/05/22/testing.html

HTH

--Geoff


Re: [mp2] retrieving the calling handler

2005-02-01 Thread Philippe M. Chiasson
Dorian Taylor wrote:
how would i go about retrieving (mod_perl or otherwise) the name
of the immediate calling handler of the current handler being
executed?
i'm trying to do loop checking in which a given handler may need
to be executed as a result of multiple subrequests, but never back
to back.
There was someone with a similar problem just a while ago:
http://gossamer-threads.com/lists/modperl/modperl/77721
I believe it is relevant to your question.

Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5


signature.asc
Description: OpenPGP digital signature


Re: Barrier to implementing web content compression in mod_perl

2005-02-01 Thread Rob Mueller
I'm surprised nobody has mentioned this yet on the list, but one approach 
I'd recommend is going to 2 separate apache servers. A light frontend one 
that does all the SSL/compression work, and a heavy backend mod_perl one.

http://modperlbook.org/html/ch12_01.html
This works fantastic for us, and avoids any of the issues of chained filters 
in the mod_perl process. The light weight servers can easily do the 
compression and SSL work and deal with clients on slow networks, leaving our 
mod_perl servers to do the actual processing. Even though we process 2M+ 
requests a day, we generally don't have more than 20 mod_perl httpd procs at 
any one time, while having 500-1000 frontend apache procs dealing with the 
slow network clients.

We personally use mod_accel and mod_deflate written by Igor Sysoev. Although 
most of the docs are in russian, we managed to get it working, and it's been 
one of those things that has "just worked" since day 1. Anytime we've had 
any technical issues, I've emailed Igor, and he's been fast and responsive 
to reply and help, and he knows his stuff!

http://sysoev.ru/en/
See the link at the bottom for our success story and compilation procedure.
Good luck.
Rob


Re: setting environment variables

2005-02-01 Thread colin_e
Geoff,
   I ran into some weirdness in this area (on a Win XP machine running 
Apache 2.0.52)
that seemed to be related to using lowercase environment variable names. 
It looked as if
PerlSetEnv uppercased the variable names, whereas SetEnv just ignored 
vars with lower
case names.

Sounds weird I know, and I didn't pin it down exactly, but try uppercase 
variables and
see if this works for you.

Regards: Colin
Geoffrey Young wrote:
Octavian Rasnita wrote:
 

Hi,
I have tried to put the following lines in httpd.conf:
SetEnv user "gigel"
SetEnv pass "parola"
Well, if I print the environment variables using a cgi script, they are
printed fine, but if I use MP, their values are not printed, and I can see
just a:
user=
pass=
Please tell me how can I do this to work fine with ModPerl also.
   

please see
 http://perl.apache.org/bugs/
and report back with all the relevant info.  whether you are using a handler
or Registry is also important.
--Geoff
 




Memory Question

2005-02-01 Thread shawn








Hi, I am sure this is a simple question but I just can’t
seem to find any documentation that can tell me exactly what is wrong. The
current box I am running my apache 1.3.28 / Mod_perl server is a quad zeon 500
with 3GB of Ram, the server in general doesn’t get all that many hits,
around 300,000 a day. Lately I have been seeing “server reached
MaxClients setting, consider raising the MaxClients
setting” about 6 seconds after I start up apache. Then I added

 

#memory info

perl-status>

    PerlModule Apache::Status

    PerlModule B::TerseSize

    SetHandler perl-script

    PerlHandler Apache::Status

    PerlSetVar StatusTerse On

    PerlSetVar StatusTerseSize On

    PerlSetVar StatusTerseSizeMainSummary
On

    PerlSetVar StatusDumper On

    PerlSetVar StatusPeek On



 

and found the
average site to be 37MB so I added 

 

PerlFixupHandler Apache::SizeLimit

$Apache::SizeLimit::MAX_UNSHARED_SIZE
= 5;

$Apache::SizeLimit::CHECK_EVERY_N_REQUESTS
= 10;

 

 

Which I thought should cap it at 50MB so 3000 / 50 = 60 so I
set

 

MinSpareServers 5

MaxSpareServers 10

StartServers 20

MaxClients 60

MaxRequestsPerChild 5000

 

Which in my mind should basically use up all 3GB of memory
before I see the “server reached MaxClients
setting, consider raising the MaxClients setting”
but when the MaxClients error appears the memory is
hardly being used at all

 

Cat /proc/meminfo

MemTotal:  3116164 kB

MemFree:   1929260 kB

Buffers:
40656 kB

Cached:
127360 kB

SwapCached:  11028 kB

Active:   
1094232 kB

Inactive:   
49228 kB

HighTotal: 2228208 kB

HighFree:  1133632 kB

LowTotal:   887956 kB

LowFree:   
795628 kB

SwapTotal: 1048536 kB

SwapFree:  1031008 kB

Dirty:
340 kB

Writeback:  
0 kB

Mapped:
974096 kB

Slab:   
29068 kB

Committed_AS:  1390760 kB

PageTables:   3156 kB

VmallocTotal:   114680 kB

VmallocUsed:   648 kB

VmallocChunk:   114032 kB

HugePages_Total: 0

HugePages_Free:  0

Hugepagesize: 4096 kB

 

Free –lm –s 3


   total   used   free shared    buffers cached

Mem: 
  3043   1126   1916 
0
39    124

Low:  
  867
90   
777 
0 
0 
0

High:
    2175   1036   1139 
0 
0 
0

-/+ buffers/cache:       961   2081

Swap:
  1023
17  
1006

 

Which I can’t understand….. Why is there free
memory if the max clients has already been reached? Shouldn’t there be
3GB used or cached before it wants more? Consequently the server is very up and
down…… If anyone could explain this to me I would greatly
appreciate it.

 

Thanks

Shawn

 








Re: make test failed on solaris 8

2005-02-01 Thread Stas Bekman
Tulan W. Hu wrote:
I'm not sure what went wrong, but there is nothing in the log. And there
must be something since you had 'Access Denied'

Does it need to access on internet? I need to have a proxy setting to go
out.
No, no, none of the tests require that.
Please do:
t/TEST -clean
t/TEST -verbose t/protocol/pseudo_http.t t/apr/util.t

t/protocol/pseudo_http# connecting to localhost:8544

# send: foobar
# testing : banner
# expected: Welcome to TestProtocol::pseudo_http
# received: Access Denied
not ok 5
So for some reason one of the AAA phases fail. Please apply this patch, run:
t/TEST -clean
t/TEST -verbose t/protocol/pseudo_http.t
and post only t/logs/error_log.
Index: t/protocol/TestProtocol/pseudo_http.pm
===
--- t/protocol/TestProtocol/pseudo_http.pm  (revision 148914)
+++ t/protocol/TestProtocol/pseudo_http.pm  (working copy)
@@ -84,6 +84,8 @@
 for my $method (qw(run_access_checker run_check_user_id
run_auth_checker)) {
+warn "starting method: $method\n";
+
 my $rc = $r->$method();
 if ($rc != Apache::OK and $rc != Apache::DECLINED) {
@@ -98,8 +100,13 @@
 my $username = prompt($socket, "Login");
 my $password = prompt($socket, "Password");
+warn "u/p: $username/$password\n";
+
 $r->set_basic_credentials($username, $password);
 }
+
+warn "finished method: $method\n";
+
 }
 return Apache::OK;
t/apr/util1..4
# Running under perl version 5.008006 for solaris
# Current time local: Mon Jan 31 09:16:52 2005
# Current time GMT:   Mon Jan 31 14:16:52 2005
# Using Test.pm version 1.25
# Using Apache/Test.pm version 1.21
ok 1
# crypt
ok 2
# sha1
not ok 3
here the sha1 fails. it's strange because apparently the same test running 
outside of modperl (i.e. t/apr-ext/util.t) doesn't have this problem. Is 
that correct? Can you post the output of:

t/TEST -v t/apr-ext/util.t

--
__
Stas BekmanJAm_pH --> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: setting environment variables

2005-02-01 Thread Stas Bekman
colin_e wrote:
Geoff,
   I ran into some weirdness in this area (on a Win XP machine running 
Apache 2.0.52)
that seemed to be related to using lowercase environment variable names. 
It looked as if
PerlSetEnv uppercased the variable names, whereas SetEnv just ignored 
vars with lower
case names.

Sounds weird I know, and I didn't pin it down exactly, but try uppercase 
variables and
see if this works for you.
That's probably due to the differences of how perl and Apache interpret 
environ on win32. mod_perl really calls perl's funcs to get the env. I'm 
sure if you try that on the command line (plain perl) you will see the 
same behavior. something like:

setenv foo bar (whatever it is on win32)
perl -le 'print $ENV{FOO}'
on unix that won't work, but on win32 it should print 'bar'.
I believe Randy has mentioned this before.
How does mp1 deals with that?
Randy?
--
__
Stas BekmanJAm_pH --> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: Memory Question

2005-02-01 Thread Stas Bekman
shawn wrote:
Hi, I am sure this is a simple question but I just can’t seem to find 
any documentation that can tell me exactly what is wrong. The current 
box I am running my apache 1.3.28 / Mod_perl server is a quad zeon 500 
with 3GB of Ram,
wow! I won't mind having one of those warming my room on the cold nights :)
the server in general doesn’t get all that many hits, 
around 300,000 a day. Lately I have been seeing “server reached 
MaxClients setting, consider raising the MaxClients setting” about 6 
seconds after I start up apache. Then I added
[]
and found the average site to be 37MB so I added
PerlFixupHandler Apache::SizeLimit
$Apache::SizeLimit::MAX_UNSHARED_SIZE = 5;
$Apache::SizeLimit::CHECK_EVERY_N_REQUESTS = 10;
but it gets checked every 10 requests per process! So if you have 60 
processes. that means only on the 600th request it'll get checked. At 
least while debugging I'd check every request. But see below.

Which I thought should cap it at 50MB so 3000 / 50 = 60 so I set
What this has to do with the memory limit? You hit the maxclients because 
Apache has spawned 60 clients, not because you run out of memory. That 
normally means that you either have 60 concurrent requests or you have 
some sort of run-away processes, which don't return to the pool of free 
servers.

I suggest that you install Apache::VMonitor and observe what exactly 
happens to your servers. Hint: it'll also show you the real memory usage, 
which you may have calculated incorrectly with other tools.

And you may want to review those chapters/sections:
http://modperlbook.org/html/ch10_01.html
http://modperlbook.org/html/ch11_01.html#pmodperl-CHP-11-SECT-1
--
__
Stas BekmanJAm_pH --> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Storing Objects in a Session

2005-02-01 Thread jonathan vanasco
slightly OT, but i'm doing this in mod_perl!
server
Apache/2.0.52 (Unix)
mod_perl/1.99_16
Perl/v5.8.1
use
use Apache::Cookie;
use Apache::Request ();
use Apache::Session;
use Apache::Session::File;
is there any way to store an object into an Apache Session ?
all attempts have been fruitless.  i'd rather not rebuild the object by 
hand each time, but if needed i will.



Re: setting environment variables

2005-02-01 Thread Randy Kobes
On Tue, 1 Feb 2005, Stas Bekman wrote:

> colin_e wrote:
> > Geoff,
> >I ran into some weirdness in this area (on a Win XP
> > machine running Apache 2.0.52) that seemed to be related
> > to using lowercase environment variable names.  It
> > looked as if PerlSetEnv uppercased the variable names,
> > whereas SetEnv just ignored vars with lower case names.
> >
> > Sounds weird I know, and I didn't pin it down exactly,
> > but try uppercase variables and see if this works for
> > you.
>
> That's probably due to the differences of how perl and
> Apache interpret environ on win32. mod_perl really calls
> perl's funcs to get the env. I'm sure if you try that on
> the command line (plain perl) you will see the same
> behavior. something like:
>
> setenv foo bar (whatever it is on win32)
> perl -le 'print $ENV{FOO}'
>
> on unix that won't work, but on win32 it should print 'bar'.

That's right, Stas - on Win32,
   C:\> set foo=bar
   C:\> perl -le "print $ENV{FOO}"
prints "bar".

> I believe Randy has mentioned this before.
>
> How does mp1 deals with that?
>
> Randy?

There is a difference in this respect between mp1 and mp2.
For example, with a registry script that has
   print "Foo = $ENV{Foo}";
   print "FOO = $ENV{FOO}";
   print "foo = $ENV{foo}";
one obtains:

- under Apache1/mp1,
   SetEnv Foo Bar
   SetEnv FOO BAR
yields
  Foo = BAR
  FOO = BAR
  foo = BAR
whereas
   PerlSetEnv Foo Bar
   PerlSetEnv FOO BAR
yields
  Foo = BAR
  FOO = BAR
  foo = BAR
So under mp1, SetEnv and PerlSetEnv behave the same,
as far as case goes.

- under Apache2/mp2,
   SetEnv Foo Bar
   SetEnv FOO BAR
yields
  Foo = bar
  FOO = bar
  foo = bar
whereas
   PerlSetEnv Foo Bar
   PerlSetEnv FOO BAR
yields
  Foo = BAR
  FOO = BAR
  foo = BAR

So the behaviour of SetEnv changed from Apache-1 to
Apache-2, as far as Win32 case goes, while PerlSetEnv
maintained the same behaviour from mp1 to mp2.

I suppose one could argue that we should change
PerlSetEnv under mp2 to lower-case things, so as
to be consistent with SetEnv?

-- 
best regards,
randy


Re: Storing Objects in a Session

2005-02-01 Thread David J Radunz
On Tue, 2005-02-01 at 23:52 -0500, jonathan vanasco wrote:
> slightly OT, but i'm doing this in mod_perl!
> 
> server
>   Apache/2.0.52 (Unix)
>   mod_perl/1.99_16
>   Perl/v5.8.1
> 
> use
>   use Apache::Cookie;
>   use Apache::Request ();
>   use Apache::Session;
>   use Apache::Session::File;
> 
> is there any way to store an object into an Apache Session ?
> 

Have you tried to freeze your object and then thaw it on retrieve?

perl -MCPAN -e install Storable
perldoc Storable

> all attempts have been fruitless.  i'd rather not rebuild the object by 
> hand each time, but if needed i will.
> 

This email and any files transmitted with it are confidential and intended 
solely for the 
use of the individual or entity to whom they are addressed. Please notify the 
sender 
immediately by email if you have received this email by mistake and delete this 
email 
from your system. Please note that any views or opinions presented in this 
email are solely
 those of the author and do not necessarily represent those of the 
organisation. 
Finally, the recipient should check this email and any attachments for the 
presence of 
viruses. The organisation accepts no liability for any damage caused by any 
virus 
transmitted by this email. 



Re: Storing Objects in a Session

2005-02-01 Thread Perrin Harkins
jonathan vanasco wrote:
is there any way to store an object into an Apache Session ?
Yes, you put any object in Apache::Session as long as it can be handled 
by Storable.  You'll need to tell us what you tried and what didn't work 
about it before we can help you more.

- Perrin