ANNOUNCE: Apache2::Filter::TagAware

2007-10-21 Thread Adam Prime


The uploaded file

Apache2-Filter-TagAware-0.01.tar.gz

has entered CPAN as

  file: $CPAN/authors/id/A/AP/APRIME/Apache2-Filter-TagAware-0.01.tar.gz
  size: 9124 bytes
   md5: dbf01588e4030b70d449654fb98deed8

Nearly a year after this thread: 
http://marc.info/?l=apache-modperl&m=116330817100487&w=2


I've uploaded this to CPAN.  Thanks to Geoff, and to Graham TerMarsch 
for the recent threads related to the minifier scripts which helped me 
figure out how to do some packaging/testing things.


Hopefully someone other than me finds this useful.

Adam



Re: FYI

2007-10-22 Thread adam . prime

It's been broken at least a week.

Quoting Bill Whillers <[EMAIL PROTECTED]>:


Maybe someones working?

I'm just getting generic Internal Server Errors when searching on anything
like "handler".

http://perl.apache.org/search/swish.cgi?query=handler&sbm=&submit=search




On Monday 22 October 2007 16:47, Arshavir Grigorian wrote:

Not sure if people already know about this, but running any search off
of perl.apache.org gives a 500.








Re: Migrating from mod_perl 1.x to mod_perl 2.x

2007-10-23 Thread adam . prime

http://perl.apache.org/docs/2.0/user/porting/porting.html

$r->method should be a part of Apache2::RequestRec though.  what  
version of mod_perl 2 are you using?


Adam

Quoting Daniel Corbe <[EMAIL PROTECTED]>:


Hello,
We're trying to upgrade a web application from Apache 1.3.x to Apache
2.2.x(and thus from mod_perl
1.x to mod_perl 2.x) and we're having trouble with the basics at the moment:

[Tue Oct 23 17:42:12 2007] [error] [client 207.241.167.7] Can't locate
object method "method" via package "Apache2::RequestRec" at
/usr/local/billing/WCI/Router/FreeSWITCH.pm line 69.\n

The offending line:

   if ($request->method() eq "POST")


I did make sure Bundle::Apache2 was fully installed; however, no luck.

Can anyone point me to a good document on migrating?

Thanks.

-Daniel







Re: mod_perl MVC framework.

2007-10-24 Thread adam . prime

there's a list here:

http://perl.apache.org/products/app-server.html

Adam

Quoting Tyler Bird <[EMAIL PROTECTED]>:


Hi List,

Hey I was wondering if there was any MVC framework that anybody on this
list could point
me to that work work well with mod_perl.

We are having difficulty finding a good MVC framework for perl.

I have looked at HTML::Mason and the template toolkit today. I am not
quite sure mason is a MVC framework.  The template toolkit looks
promising.

Tyler






Re: Modifiable APR::Request::Param::Table

2007-11-25 Thread Adam Prime

Perrin Harkins wrote:
 >> Get the request parameters using the tied APR::Request::Param::Table

object (which is returned by Apache2::Request->new($r)->param in
scalar context) as well as being able to modify the request parameters
in the tied APR::Request::Param::Table object.


Yes, but why?  That is simply a record of data that was in the
request.  You can't change the past.  What are you really trying to
do?  Store some data for a later handler?

The docs warn that you can't change these parameters in a way that is
visible to anyone else:

"Note: modifications to the scalar $req->param() table only affect the
returned table object (the underlying C apr_table_t is generated from
the parse data by apreq_params()). Modifications do not affect the
actual request data, and will not be seen by other libapreq2
applications."

If all you want to do is change them around in some sub as you do work
on them, copy them all into local variables and do whatever you like
with them.  You can copy them into a hash of array refs to preserver
multiple values.


The rub here for me is that in apreq1 you could modify param just fine, 
but that in apreq2 you cannot.  None of the porting documents mention 
this unfortunately.


What I ultimately did to get around this was modify the param scrubbing 
code that wanted to modify param so that what it created a new instance 
of an APR::Table, which does implement STORE when tied, and put 
everything in there.


Adam



DBD::Sybase / freetds / Apache::DBI / ?

2007-11-28 Thread adam . prime


We have a long standing problem pulling data from ntext fields in a  
server running MSSQL 2000, which i always assumed was a problem with  
freetds and or DBD::Sybase.


However, I've actually done some investigation today, and i've  
discovered that the particular code that's causing problems actually  
runs fine at the command line, as well as under plain CGI.  However,  
it blows up when running in mod_perl.  I'm about to attempt to reduce  
this down to a simple case, but if anyone has any ideas, i'd love to  
here them.


basically what happens is whenever i run a query that pulls an ntext  
field, i get this:


Unicode data in a Unicode-only collation or ntext data cannot be sent  
to clients using DB-Library (such as ISQL) or ODBC version 3.7 or  
earlier.


the freetds.conf for the DB is like this:

[clients]
host = ...
port = 1433
tds version = 8.0
client charset = CP1252

We're running freetds 0.64, and DBD::Sybase 1.08.

Any ideas would be appreciated (and no i can't just change the fields  
to not be ntext)


Adam



Re: DBD::Sybase / freetds / Apache::DBI / ?

2007-11-28 Thread adam . prime
This turned out to just be a misconfiguration more than anything else.  
 the dsn was getting changed by some rogue code, and as a result it  
wasn't defined in the freetds.conf, however, the new servername  
resolved fine through DNS so it still connected ok.  The problem was  
that it defaulted to using the default TDS level of 4.2, which doesn't  
support ntext.


bleh.

Adam

Quoting [EMAIL PROTECTED]:



We have a long standing problem pulling data from ntext fields in a
server running MSSQL 2000, which i always assumed was a problem with
freetds and or DBD::Sybase.

However, I've actually done some investigation today, and i've
discovered that the particular code that's causing problems actually
runs fine at the command line, as well as under plain CGI.  However,
it blows up when running in mod_perl.  I'm about to attempt to reduce
this down to a simple case, but if anyone has any ideas, i'd love to
here them.

basically what happens is whenever i run a query that pulls an ntext
field, i get this:

Unicode data in a Unicode-only collation or ntext data cannot be sent
to clients using DB-Library (such as ISQL) or ODBC version 3.7 or
earlier.

the freetds.conf for the DB is like this:

[clients]
 host = ...
 port = 1433
 tds version = 8.0
 client charset = CP1252

We're running freetds 0.64, and DBD::Sybase 1.08.

Any ideas would be appreciated (and no i can't just change the fields
to not be ntext)

Adam








Re: headers_out

2007-12-01 Thread adam . prime

Roberto C. Sánchez wrote:


Have you tried adding "PerlModule Apache2::compat" in your httpd.conf?



Or you can use $r->headers_out.  $r->header_out is no longer supported. see:

http://perl.apache.org/docs/2.0/user/porting/compat.html#C__r_E_gt_err_header_out_

Adam







Re: dynamic config

2007-12-04 Thread Adam Prime
I think that to truly change the ServerAlias in all your processes you 
need to restart the server, but i could very well be wrong.


However, this is something i've wanted to do too, and the way i had been 
thinking about getting around an inability to add ServerAliases in the 
short term was to set up a catch all virtual host that would use the 
requests Host header to determine what it should ultimately do with the 
request.


In the scenario i was imagining i'd have an init handler that would run 
on the catch all vhost which would stuff a handful of variables into 
pnotes.  My later phase code would then check for the existance of the 
pnotes variables, and either use them, or use it's normal route of doing 
whatever it was wanting to do.


If you were just adding additional server aliases for already set up 
sites you could just have your init handler redirect to the 'main' 
domain' of that alias or something like that.


Another option to think about anyway.

Adam



John ORourke wrote:

Hi folks,

I'm sure this has cropped up in the past but I can't see anything 
obvious in the archives (regex search on the archives would be great!)


I have some apps where users want to add extra domains and I'd like to 
do it on the fly if possible - in other words, modify the ServerAlias 
list from within mod_perl.  Does anyone have any tips/pointers/archives?


thanks
John





Re: Can output filter return "page not found"?

2007-12-15 Thread Adam Prime
If you're using the bucket brigade API you'd have to intercept the 
headers and modify them there.  You might have an easier time doing 
something like this using the stream API, but i don't really know, just 
taking a shot in the dark.  I'd think that it's certainly possible 
though, somehow.


That said you might be better served catching whatever situation is 
causing you to want to do this earlier in the request cycle and keeping 
the response phase from doing whatever it wants to do in the first place 
and just causing the 404 to happen then.


Adam

Marc M. Adkins wrote:
Hmmm...it's a bucket brigade FilterRequestHandler output filter.  It 
seems to not care what return code I use, whatever is in the bucket 
brigade goes out.  Can I not return Apache2::Const::NOT_FOUND from 
handler()?  That seems odd.


Marc M. Adkins wrote:
I'm trying to cause a 404 error from an output filter and it isn't 
doing what I expect.  Is this even possible?


mma







Re: Can output filter return "page not found"?

2007-12-16 Thread Adam Prime

[EMAIL PROTECTED] wrote:

Sounds like something I would *not* do. If you are going to return a
404, why not do it as soon as possible.
Generating data only to return a 404 sounds like useless extra work
unless you are caching the same data for future requests.



I agree, if you don't want to much up your data generation code, write 
an Access or Fixup Handler (or any other pre-response phase handler of 
your choice) checks for the existence of the template at that stage.  If 
it's not there, 404.


Adam




Re: PerlAccessHandler problems

2007-12-21 Thread Adam Prime

What does the error_log say?

Adam

Tad Johnston wrote:
I'm having problems trying to use an access handler within mod_perl2.  
If I have it in the conf file it returns a 500 Internal Server Error and 
if I don't include the PerlAccessHandler line, it runs the page just 
fine.  What's happening is when it is turned on my $ENV for my proxy 
gets set to a different host.  If it's turned on, the $ENV for the proxy 
is sent to the appropriate host.  I do have a couple REDIRECT in the 
conf file, but they all direct to the same server.  Anyone have any ideas?


Tad






Re: Find the values of Apache2::Const

2007-12-22 Thread Adam Prime

Boysenberry Payne wrote:
I only ask because I tried a $r->status(Apache2::Const::OK) and got a 
500 returned in the header

even though my handler returned with Apache::Const::OK also...

To avoid the 500 header I had to do $r->status(200);  I imagine the 
status code isn't going to change

too soon, so I ought to be okay, right?


I believe in this situation what you want is 
$r->status(Apache::Const::HTTP_OK).  HTTP_OK and OK are not the same 
thing at all.


This isn't exactly a "list" of them, but it might point you in the 
right direction.  They're buried pretty well, it seems.


Yeah, I figured it was in c, I stopped at the XSLoader.pm package

Thanks,
Boysenberry



Re: re-factoring 'print' for $r

2007-12-22 Thread adam . prime

Quoting Perrin Harkins <[EMAIL PROTECTED]>:


On Dec 22, 2007 5:21 PM, Jonathan Vanasco <[EMAIL PROTECTED]> wrote:

On Dec 22, 2007, at 4:47 PM, Perrin Harkins wrote:
> By the way, if you just call print() normally it should all be grabbed
> by mod_perl anyway.  Is there some reason you need to call $r->print()
> instead?

I thought it only does that if you bind STDOUT the right way on
compile time, otherwise it just gets lost in the ether


No, mod_perl does all of that for you.  It's been this way since 1996.



I think the print magic only happens if you are running under  
SetHandler perl-script, and not if you are running under SetHandler  
modperl.


Adam



Re: two common questions

2008-01-07 Thread Adam Prime

lists user wrote:

1. Do you run common web program under modperl handlers? or just run
them under Registry?
For me I mostly wrote web scripts with CGI methods like using CGI.pm
and CGI::Session, and run them under Modperl::Registry.
I don't know if there's a site which is fully run by pure modperl
handlers, not the registry scripts.


Nearly all of our code at work is handlers.


2. I heard that Apache::DBI will break the entire database sometime,
is it true? When will we use or not use Apache::DBI?


We've been running Apache::DBI for 6 years (or so) without issue.

Adam



Re: question on startup.pl overriding perl search path

2008-01-18 Thread Adam Prime

c chan wrote:

I use "PerlConfigRequire /var/www/html/mypath/startup.pl" in httpd.conf to 
recompile all the CGIs. Inside startup.pl, I added the line:

  use lib qw(. mylib);

To me amazement, after all the CGI is precompiled, they start to look into the "." and "mylib" path for loading Perl Modules without even having the line [use lib qw(. mylib);] incorporated in each individual cgi script. 


Can someone explain to me why this is the case? Is the mod_perl startup.pl 
script simply becomes the parent apache process for all the preloaded CGIs?


This is normal.  Under mod_perl the perl interpreter just keeps running 
until the apache child dies your modified @INC stays modified.  I'm sure 
someone with a better understanding of the internals can give a more 
detailed 'why'.  FYI though, you should probably use PerlPostConfigRequire


http://perl.apache.org/docs/2.0/user/config/config.html#C_PerlPostConfigRequire_

If I remove mod_perl, can I use the 

  PerlSetEnv -I/var/www/html/mypath -I/var/www/html/mypath/lib 


to achieve the same result.


Isn't PerlSetEnv part of mod_perl?  In which case, no that wouldn't work 
if you'd removed mod_perl



This will make a profound effect on my CGI directory because whatever I 
installed will no longer affect the system perl module search path. In effect, 
this will make my application self contained and making trouble shooting make 
easier.

- C Chan


Adam


[RFC] Apache2::DirBasedHandler

2008-01-19 Thread adam . prime


I've found myself writing similar bits of code repeatedly, and figure  
what i'm doing is probably common enough that something like this  
could have a place on CPAN.  I'm mostly curious about if the name is  
appropriate.


This is just a base class designed to speed the implementation of  
handlers that happen to work in this way.  I plan to do a subclass of  
this that'll have the generic TT generation stuff i'm always using  
stuck into it as well.  I could also see other generic base classes  
like this that might want to make uri's differently.


The idea of this handler is basically to take $r->uri, and map that to  
a function.  Similar to Apache::Dispatch, similar to what Catalyst  
does and similar to about a lot of other code i'm sure.  This thing  
does work slightly differently though, because i often need it to.


Here's a quick outline of what it does.

Given a request for /foo/bar/haha/hoho

It will loop through the split uri checking for the existance of  
subroutines like this:


foo_bar_haha_hoho_page
foo_bar_haha_page
foo_bar_page
foo_page
index

As soon as it finds one, it uses that function to generate the page.   
The part of the URI that isn't in the function name gets stuck into an  
array reference and passed into the actual page generation function  
function like this


$self->function($r,$uri_leftovers,$args)

$args is whatever you want it to be, and is generated by a call to  
$self->init($r).


here's some code to look at:

http://kabob.ca/perl/DirBasedHandler.pm

Any input would be appreciated.  I don't really even know if anyone  
other than me is writing ResponseHandlers in this fashion, or if  
everyone is just using Registry, or one of the various frameworks.


Adam



Re: [RFC] Apache2::DirBasedHandler

2008-02-06 Thread adam . prime

The first version of this is now on CPAN, if anyone is interested in it.

Adam

Quoting [EMAIL PROTECTED]:



I've found myself writing similar bits of code repeatedly, and figure
what i'm doing is probably common enough that something like this
could have a place on CPAN.  I'm mostly curious about if the name is
appropriate.

This is just a base class designed to speed the implementation of
handlers that happen to work in this way.  I plan to do a subclass of
this that'll have the generic TT generation stuff i'm always using
stuck into it as well.  I could also see other generic base classes
like this that might want to make uri's differently.

The idea of this handler is basically to take $r->uri, and map that to
a function.  Similar to Apache::Dispatch, similar to what Catalyst
does and similar to about a lot of other code i'm sure.  This thing
does work slightly differently though, because i often need it to.

Here's a quick outline of what it does.

Given a request for /foo/bar/haha/hoho

It will loop through the split uri checking for the existance of
subroutines like this:

foo_bar_haha_hoho_page
foo_bar_haha_page
foo_bar_page
foo_page
index

As soon as it finds one, it uses that function to generate the page.
The part of the URI that isn't in the function name gets stuck into an
array reference and passed into the actual page generation function
function like this

$self->function($r,$uri_leftovers,$args)

$args is whatever you want it to be, and is generated by a call to
$self->init($r).

here's some code to look at:

http://kabob.ca/perl/DirBasedHandler.pm

Any input would be appreciated.  I don't really even know if anyone
other than me is writing ResponseHandlers in this fashion, or if
everyone is just using Registry, or one of the various frameworks.

Adam








Re: [RFC] Apache2::DirBasedHandler

2008-02-10 Thread adam . prime
I uploaded a .02 release last night which i think will make something  
like this even easier to accomplish.  This version adds a function  
called uri_to_function, which takes a RequestRec (or derived) object,  
and an array of uri_bits and returns a function name that should be  
used to to handle that request.


I don't really know REST, but from my limited knowledge it seems to me  
that it would be good to be able to easily separate code for post,  
get, put, and delete to the same URI. So with this new version, if you  
subclass uri_to_function to work like this:


return join(qq[_],(lc($r->method),@$uri_bits)) . qq[_page];

then you can very easily achieve that seperation.

I also uploaded Apache2::DirBasedHandler::TT, which is a subclass of  
DirBasedHandler that will pass a Template object, and a base set of TT  
vars into each function call.  It's more or less just in illustration  
of how i thought one might use the init function in  
Apache2::DirBasedHandler.


Feedback welcome

Adam


Quoting André Warnier <[EMAIL PROTECTED]>:


I'm not a guru in the matter either, but it sounds interesting.
It looks like it could give a way to do things REST-like, but simpler.

[EMAIL PROTECTED] wrote:

The first version of this is now on CPAN, if anyone is interested in it.

Adam





Re: Running a mod_perl script at the domain root

2008-02-10 Thread Adam Prime

There are a couple of ways you can tackle this sort of thing.

1) You can modify TestSite to return DECLINED for any request that you 
want to be handled by the filesystem rather than your handler.  ie


if $r->uri =~ m|\css$| {
return Apache2::Const::DECLINED;
}

2) If you've got all your CSS and images in directories dedicated to 
those tasks, then you can add locations blocks that SetHandler 
default-handler.  ie:



SetHandler perl-script
PerlResponseHandler TestSite



SetHandler default-handler



SetHandler default-handler


There are likely other ways to handle it too.

Adam

Matthew Tylee Atkinson wrote:

I've spent at least a couple of hours trying to figure this out and
reading manuals, to no avail, hence asking here.  I hope it's not too
obvious :-).

I'm running a mod_perl (2.0.2) script from the root of my domain.  My
Apache (2.2.3) configuration is as follows.


. . .
PerlOptions +Parent
PerlSwitches -T -I/var/www/testsite


SetHandler perl-script
PerlResponseHandler TestSite




My script takes the whole URI and uses that as part of the input to tell
it which part of the site the user wants to visit (such as / for the
home page or /account to manage their contact details).

The problem is that, because the script overrides the whole domain, a
request for /logo.png or the CSS file will not work properly.

I have tried using mod_rewrite to combat this, to no avail.  I think the
problem is that when I was using mod_python on a different site (a
MoinMoin wiki as it happens), the handling of the request is different;
it'd be more like the following:

# map /wiki static files to Moin htdocs
RewriteRule ^/wiki/(.*)$ /var/www/agdev-wiki/htdocs/$1 [last]
# map everything else to server script
RewriteRule ^(.*)$ /var/www/agdev-wiki/moinmodpy.py$1

In this case, I can successfully use mod_rewrite because I can send the
request to a certain script.  I can't see how to send the request to a
certain location, as would appear to be required by the mod_perl setup.

Could someone direct me to instructions or an example Apache config
where they're running a mod_perl script at the domain root?

Thanks very much for your time,

best regards,


P.S. My site is now running much faster under mod_perl (albeit without
CSS or a logo at the moment :-)) -- mod_perl really does seem to rock
maximally and I'm looking forward to getting it all working smoothly.




Re: Periodic random script failures - Need pointers

2008-03-04 Thread Adam Prime

André Warnier wrote:


Hi.  Don't take this as an expert response, but very superficially, I 
can think of one kind of circumstance where "this happens randomly but 
periodically" : if it would happen, for instance, at the first execution 
of the script by a "new" apache child, freshly started.  Then as this 
same child re-executes the script multiple times, $r would always be 
defined, until that child dies and a new child initialises and executes 
the script for the first time, etc..
Of course there must be another underlying reason why $r is undefined, 
but maybe the above can help thinking about it.


Actually, there are (at least) 2 old threads with similar intermittent 
failures related to not getting $r objects correctly.


http://marc.info/?l=apache-modperl&m=117816111524789&w=2

http://marc.info/?l=apache-modperl&m=114226565622372&w=2

I personally haven't seen this sort of thing under mp2 though, just mp1, 
and don't really have any real solution for it.


Adam


Re: [a little OT] mod_proxy 502 errors in dual apache setup

2008-03-05 Thread adam . prime
502's show up when you have more connections from the front end to the  
back end that it can service.  The proxy server has a timeout [1], and  
if it doesn't get a response within that time frame you get a 502.


You can create a custom error document on your front end for 502's to  
make them a little less jarring.


[1] http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxytimeout

Quoting John ORourke <[EMAIL PROTECTED]>:


Hi folks,

Slightly OT but hopefully someone on here has had similar experience.
I've got a site with fairly heavy traffic and a light/heavy apache
setup.  Occasionally the back-end servers seem to get swamped and
suddenly every request from the front end starts getting a 502 proxy
timeout until I restart both apache servers.

I'm about to start digging through logs to try and track down the issue
but wondered if anyone who's seen this before could give me a head
start.

cheers
John






opting out of deflate mid request

2008-03-07 Thread adam . prime


I have a particular cgi, running under registry that uses  
Content-Disposition: attachment.  Unfortunately, it appears that IE6  
ignores the header if the page is gzipped.  So I was wondering if  
there was an easy way to keep the deflate filter from running on a per  
request basis.  I've worked around this in the short term by altering  
httpd.conf, but ideally i think it'd be useful to be able to short  
circuit this thing mid request if possible.


Adam



Re: perl at apachecon

2008-04-02 Thread adam . prime

Quoting Brian Millett <[EMAIL PROTECTED]>:


Wow, not many proposals. :-(


It's not too late to submit more (you've got one day left till the deadline).

Adam



Re: [RELEASE CANDIDATE] mod_perl-2.0.4 RC1

2008-04-02 Thread adam . prime


make test passes on

Apache/2.2.4 mod_perl/2.0.4-rc1 Perl/v5.8.8
Apache/2.2.8 mod_perl/2.0.4-rc1 Perl/v5.8.8

Adam


Quoting "Philippe M. Chiasson" <[EMAIL PROTECTED]>:


The mod_perl 2.0.4 release candidate 1 "Works with Perl 5.10" is ready.
It can be downloaded here:

http://www.apache.org/~gozer/mp2/mod_perl-2.0.4-rc1.tar.gz

MD5:  1f0a941e8b5f26b6102126ae67ddbb43
SHA1: 8b2ceede3c783b9b2cc9e0fe63a095b0e4a1f000

Please give it a spin in your favorite configuration and report
any problems. Especially needed against Perl-5.10 on Windows.

The summary of what has changed since 2.0.3 are (from Changes):

Fix $r->location corruption under certain conditions
[Gozer]

Fix a crash when spawning Perl threads under Perl 5.10
[Gozer]

Fix erratic behaviour when filters were used with Perl 5.10
[Gozer]

Fix problems with redefinitions of perl_free as free and perl_malloc
as malloc on Win32, as described at
 http://marc.info/?l=apache-modperl&m=119896407510526&w=2
[Tom Donovan]

Fix a crash when running a sub-request from within a filter where
mod_perl was not the content handler. [Gozer]

Refactor tests to use keepalives instead of same_interp [Gozer, Phred]

Apache2::Reload has been moved to an externally maintained
CPAN distribution [Fred Moyer <[EMAIL PROTECTED]>]

PerlCleanupHandler are now registered with a subpool of $r->pool,
instead of $r->pool itself, ensuring they run _before_ any other
$r->pool cleanups [Torsten Foertsch]

Fix a bug that would prevent pnotes from being cleaned up properly
at the end of the request [Torsten Foertsch]

On Win32, embed the manifest file, if present, in mod_perl.so,
so as to work with VC 8 [Steve Hay, Randy Kobes]

Expose apr_thread_rwlock_t with the APR::ThreadRWLock module
[Torsten Foertsch]

Don't waste an extra interpreter anymore under threaded MPMs when using a
modperl handler [Torsten Foertsch]

Fix a bug that could cause a crash when using $r->push_handlers() multiple
times for a phase that has no configured handlers [Torsten Foertsch]

Catch up with some httpd API changes
  2.2.4:
   The full server version information is now included in the error log at
startup as well as server status reports, irrespective of the setting
of the ServerTokens directive. ap_get_server_version() is now
deprecated, and is replaced by ap_get_server_banner() and
ap_get_server_description(). [Jeff Trawick]

  2.3.0:
ap_get_server_version() has been removed. Third-party modules must
now use ap_get_server_banner() or ap_get_server_description().
[Gozer]

fixed Apache2::compat Apache2::ServerUtil::server_root() resolution
issues [Joshua Hoblitt]

*) SECURITY: CVE-2007-1349 (cve.mitre.org)
fix unescaped variable interprolation in regular expression
[Randal L. Schwartz <[EMAIL PROTECTED]>, Fred Moyer
<[EMAIL PROTECTED]>]

Make $r->the_request() writeable
[Fred Moyer <[EMAIL PROTECTED]>]

fix ModPerl::RegistryCooker::read_script to handle all possible
errors, previously there was a case where Apache2::Const::OK was
returned on an error.  [Eivind Eklund <[EMAIL PROTECTED]>]

a minor compilation warning resolved in modperl_handler_new_from_sv
[Stas]

a minor compilation warning resolved in modperl_gtop_size_string
[Stas]

Prevent direct use of _deprecated_ Apache2::ReadConfig in
 sections with httpd Alias directives from
incorrectly generating
'The Alias directive in x at line y will probably never match'
messages.
[Philip M. Gollucci <[EMAIL PROTECTED]>]

Prevent Apache2::PerSections::symdump() from returning invalid
httpd.conf snippets like 'Alias undef'
[Philip M. Gollucci <[EMAIL PROTECTED]>]

Require B-Size 0.9 for Apache2::Status which fixes
Can't call method "script_name" on an undefined value
[Philip M. Gollucci <[EMAIL PROTECTED]>]

-march=pentium4 or anything with an = in it in CCFLAGS or @ARGV
that gets passed to xs/APR/APR/Makefile.PL broke the @ARGV
parsing.  I.E. FreeBSD port builds when users had CPUTYPE
set in /etc/make.conf.
[Philip M. Gollucci <[EMAIL PROTECTED]>]

Fixes to get bleed-ithread (5.9.5+) to comile again.
[Philip M. Gollucci <[EMAIL PROTECTED]>]

--
Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
http://gozer.ectoplasm.org/   m/gozer\@(apache|cpan|ectoplasm)\.org/






Re: undefined subroutine: get_server_description, get_server_banner

2008-04-08 Thread adam . prime

Quoting Jeff Armstrong <[EMAIL PROTECTED]>:


Folks,

 indicates that I should be   
able

to:
  $description  = Apache2::ServerUtil::get_server_description();

however, I find that
  Apache2::ServerUtil::get_server_description();
  Apache2::ServerUtil::get_server_banner();

warn => Undefined subroutine



Those functions were added in 2.0.4, which is currently in RC, as the  
docs indicate.  If you install the 2.0.4 RC1 (see:  
http://marc.info/?l=apache-modperl&m=120760945808543&w=2)



and
  Apache2::ServerUtil->user_id;
  Apache2::ServerUtil->group_id;

warn => Can't locate object method



Those functions were added in 2.0.3, as the docs indicate.  If you  
upgrade to 2.0.3, they should work.


Adam






Re: Handing over the POST input to a virtual included part?

2008-04-14 Thread adam . prime
I think that virtual includes are handled with Apache sub-requests, so  
you might be able to get it the post data through $r->prev.  Worth a  
shot anyway.


Adam


Quoting Torsten Foertsch <[EMAIL PROTECTED]>:


Hi,

is it possible to hand over the POST input of a SSI document to a virtual
included part of it?

I have an SSI document that contains



This way I can pass parameters that are passed in the URI to the subrequest.
But how can that be done if the request method is POST? (There is only one
such part that wants to read the input.)

Thanks,
Torsten







Re: Template::Toolkit and mod_perl2?

2008-04-14 Thread adam . prime
This is a guess, but are you running under SetHandler modperl, and  
then trying to print $your_page.  If that's the case, either use  
$r->print(), or change to SetHandler perl-script.


Adam

Quoting Kirk <[EMAIL PROTECTED]>:


I'm trying to do some basic conversions to an old site that uses TT, and
attempting to get it running under mod_perl2.  at the moment I'm getting no
errors but the web pages aren't displaying.  Before I get into too much
detail, I'm just wondering if TT work under mod_perl2.  Anyone have any
experience with it?  Got it running perhaps?

Thx,
Kirk





Re: Access to Server and Request objects under Registry

2008-04-16 Thread adam . prime

my $r = shift;

at the top of your file running under registry should work.  You can  
also use Apache->request in mp1, or Apache2::RequestUtil->request in  
mp2 (if you're using the prefork mpm)


Adam

Quoting Artem Kuchin <[EMAIL PROTECTED]>:


Hello!

Is there any way to access server and request objects
when script is running under Registry?

--
Regards,
Artem






Re: filter->remove

2008-04-18 Thread adam . prime

Quoting Torsten Foertsch <[EMAIL PROTECTED]>:


On Thu 17 Apr 2008, woinshet abdella wrote:



Here an output example for text/plain:

Filter Chain:
  modperl_request_output   <-- the first PrintFilterChain
  modperl_request_output   <-- RemoveNextFilterIfNotTextHtml
  includes
  modperl_request_output   <-- PrintFilterChain again
  byterange
  content_length
  http_header
  http_outerror
  log_input_output
  core

...


This leads me to believe that i could write a filter that sat at the  
head of the chain, which looked through all the filters in the chain,  
and if appropriate removed random ones through the chain.


I have a situation where i have a CGI which sometimes returns  
text/html, and sometimes returns text/csv, but IE chokes if the csv is  
gzipped by deflate.  I've had to disable deflate on ALL cgi's as a  
result, but this seems like i could just create a filter that runs on  
CGI's, that looks for a pnote that indicates that deflate should be  
taken out of the chain.


Is that correct?

Adam



Re: Access to Request Body

2008-04-28 Thread adam . prime

Quoting Tim Gustafson <[EMAIL PROTECTED]>:


Hello,

I'm writing a mod_perl logging module, and I can't seem to find anywhere in
the documentation that talks about how I can access the request body
(basically, the POST data) of a request during the logging phase.  Is this
not possible?


do you want access to the unmodified post data, or do you want access  
to the content?  Apache2::Request parses the POST data, and makes it  
available though $r->body.  (and possibly $r->upload) If you want the  
unparsed body, i'm not sure what you'd have to do offhand.


Adam



RE: Access to Request Body

2008-04-28 Thread adam . prime

Quoting Tim Gustafson <[EMAIL PROTECTED]>:


Hrmm, that doesn't seem to work.  In my code, I have:

print $fh $r->body . "\n";

And in my error log, I get:

Can't locate object method "body" via package "Apache2::RequestRec" at
/var/www/lib/Log.pm line 31.


It's part of Apache2::Request, see the documentation below

http://httpd.apache.org/apreq/docs/libapreq2/group__apreq__xs__request.html#body

It gives you access to the content through an APR::Table derived  
class, so you can do stuff like:


my $name = $r->body("name");

or

my $table = $r->body();

It doesn't give you access to the whole, unaltered POST data (afaik).

Adam





Re: Apache2::Request

2008-05-23 Thread adam . prime

Quoting xyon <[EMAIL PROTECTED]>:


Shouldn't it be:

 sub my_handler {
   my $r = shift;
   my $req = Apache2::Request->new($r, POST_MAX => "1M");
...



Provided that you've actually installed libapreq  
(http://httpd.apache.org/apreq/), that should work.




mod_perl BOF at YAPC::NA

2008-05-31 Thread Adam Prime
YAPC::NA is only a few weeks away, and I stumbled upon the beginning of 
plans for a BOF there.  There's not a whole lot on the signup page yet, 
but if you're interested (and going), you should signup.


The wiki page for the BOF is here:

http://conferences.mongueurs.net/yn2008/wiki?node=mod_perl%20BOF

Adam


Re: wrote Authen module dealing with cookies : now POST requests get corrupted. Any advice ?

2008-06-21 Thread Adam Prime

Dami Laurent (PJ) wrote:

Hi everybody,

I recently wrote  an extension to Apache2::AuthenNTLM in order to store 
the NTLM authentified username in a cookie (module 
_http://search.cpan.org/dist/Apache2-AuthenNTLM-Cookie/_).


Now I found out that this module has a critical bug : the content of 
POST requests gets corrupted (bug 
_http://rt.cpan.org/Ticket/Display.html?id=36847_).


I don't really know where to start to fix the bug. My hypothesis is that 
perhaps this is because I'm using Apache2::Cookie, which itself uses 
libaprequest, and maybe these modules are not meant to be used in an 
early Apache phase, and leave the input stream in an buggy state. I 
looked at a couple of other authentication modules using cookies, but 
they don't seem to use the Apache2::Cookie API.


Is that the hypothesis correct ? Does anybody have good advice on that 
problem ?


There is a lot of code on CPAN using libapreq and/or Apache2::Cookie in 
every phase, so I very seriously doubt that that's a problem.  The first 
thing i'd do in your situation would be to make sure that the bug 
doesn't exist in Apache2::AuthenNTLM, to confirm it's actually specific 
to you're extention.


Telling us what exactly 'gets corrupted' means might help too (ie 
error_log details, or whatever you're seeing).


Adam


Re: mod_perl: performance tips

2008-06-25 Thread adam . prime

Quoting Perrin Harkins <[EMAIL PROTECTED]>:


On Wed, Jun 25, 2008 at 11:19 AM, Christopher Taranto
<[EMAIL PROTECTED]> wrote:

Try here:

http://www.modperlbook.org/

Specifically - Part II: mod_perl Performance


Yes, read that, profile your code, and then ask for help with specific
slow parts.  There's lots of performance information in the docs on
the mod_perl site too.

- Perrin



for MP1 specific stuff, the guide has this section:

http://perl.apache.org/docs/1.0/guide/performance.html

Adam






Re: mod_captcha

2008-06-25 Thread adam . prime

Quoting Aaron Collins <[EMAIL PROTECTED]>:

Hello,
 I'm trying to write a perl based mod_captcha using the recaptcha
service, I was wondering is someone could tell me which handler I
should use that would allow me to have mod_perl intercept a request
going to a specific location and if it i return true continue with the
request.  In my case I use ProxyPass to pass request to java.  So I'd
want to have my handler jump in give a captcha and when the captcha is
approved continue forwarding it on to the proxypass.  If my
understanding of mod_perl is incorrect please let me know if their is a
better logic to approach this.


I'd use a PerlAccessHandler to achieve what you're describing.  That's  
assuming that you want to have a page that is totally distinct from  
your java based page that you're restricting access to.


Adam



mod_perl users survey

2008-07-07 Thread adam . prime
At the impromptu mod_perl BOF at YAPC::NA, Fred Moyer any myself  
hacked together a short mod_perl survey to help identify the current  
needs of mod_perl users. It was inspired by the Perl survey done last  
year by Kirrily Robert. (http://perlsurvey.org).  If you read dev@ and  
already filled this out, please don't do it again.


The link is here:

http://www.surveymonkey.com/s.aspx?sm=bQyb2RFCBuVb0P52yhaCMg_3d_3d

The survey seeks to attain these goals:

1) Determine the current breakdown of mod_perl users in terms of what  
versions, modules, and platforms mod_perl users are using.


2) Give mod_perl users a chance to provide feedback to the development  
team on where they think mod_perl development should be headed.


Please take a few minutes and fill it out.  Neither of us are  
statisticians, and there are plenty of questions that haven't been  
asked, but we only get 10 questions for free with survey monkey, so  
we've done what we could with our non-existant resources.


Thanks,
Adam




Re: mod_perl users survey

2008-07-08 Thread adam . prime


If anyone attempted to fill this out recently and got an message about  
the survey being closed, that problem has been resolved and you should  
be able to fill it out again.


Thanks to everyone who has filled it out.

Adam


Quoting [EMAIL PROTECTED]:


At the impromptu mod_perl BOF at YAPC::NA, Fred Moyer any myself
hacked together a short mod_perl survey to help identify the current
needs of mod_perl users. It was inspired by the Perl survey done last
year by Kirrily Robert. (http://perlsurvey.org).  If you read dev@ and
already filled this out, please don't do it again.

The link is here:

http://www.surveymonkey.com/s.aspx?sm=bQyb2RFCBuVb0P52yhaCMg_3d_3d

The survey seeks to attain these goals:

1) Determine the current breakdown of mod_perl users in terms of what
versions, modules, and platforms mod_perl users are using.

2) Give mod_perl users a chance to provide feedback to the development
team on where they think mod_perl development should be headed.

Please take a few minutes and fill it out.  Neither of us are
statisticians, and there are plenty of questions that haven't been
asked, but we only get 10 questions for free with survey monkey, so
we've done what we could with our non-existant resources.

Thanks,
Adam









some flawed benchmarks

2008-07-09 Thread adam . prime
A couple of months ago i was going through slides from gozers "From  
CGI to mod_perl 2.0, Fast!" talk, which has some benchmarks comparing  
CGI, perlrun and registry to each other.  At which point i realized  
that i've never really known how much faster using straight handlers  
is than using one of the CGI emulation layers.  I also didn't have any  
idea how much faster SetHandler modperl was vs SetHandler perl-script.


So i decided to see what i could figure out.  I took gozers CGI from  
the slides (slightly modified) and ran it through the paces on my  
laptop, then converted the script to run as a straight handler.


here's the CGI version:

#!/usr/bin/perl


print qq[Content-Type: text/html\r\n\r\n];

print(qq[

Hello Worlds

GATEWAY_INTERFACE: $ENV{GATEWAY_INTERFACE}
MOD_PERL: $ENV{MOD_PERL}



]);


Here's the Handler version

package Kabob::HelloWorld;

use strict;
use warnings;

use Apache2::RequestRec ();

use Apache2::Const -compile =>qw(:common);

sub handler {
my $r = shift;

$r->content_type('text/html');
$r->print(qq[

Hello Worlds

GATEWAY_INTERFACE: $ENV{GATEWAY_INTERFACE}
MOD_PERL: $ENV{MOD_PERL}




]);

return Apache2::Const::OK;
}

1;

and here's the conf (these tests were all running through a light  
mod_proxy front end too)





ProxyPass http://localhost:8080/cgi/
ProxyPassReverse http://localhost:8080/cgi/



ScriptAlias /cgi/ /www/p/



Alias /perlrun/ /www/p/


ProxyPass http://localhost:8080/perlrun/
ProxyPassReverse http://localhost:8080/perlrun/


SetHandler perl-script
PerlHandler ModPerl::PerlRun
Options +ExecCGI
PerlSendHeader On



Alias /registry/ /www/p/


ProxyPass http://localhost:8080/registry/
ProxyPassReverse http://localhost:8080/registry/


SetHandler perl-script
PerlHandler ModPerl::Registry
Options +ExecCGI
PerlSendHeader On







ProxyPass http://localhost:8080/perlscript/
ProxyPassReverse http://localhost:8080/perlscript/


SetHandler perl-script
PerlResponseHandler Kabob::HelloWorld





ProxyPass http://localhost:8080/modperl/
ProxyPassReverse http://localhost:8080/modperl/


SetHandler modperl
PerlResponseHandler Kabob::HelloWorld




and here's the results (which are no doubt flawed for a number of reasons)

running: ab -n 1 [url]

CGI
Requests per second:217.80 [#/sec] (mean)
Time per request:   4.591 [ms] (mean)
Transfer rate:  53.17 [Kbytes/sec] received

PerlRun
Requests per second:482.49 [#/sec] (mean)
Time per request:   2.073 [ms] (mean)
Transfer rate:  114.49 [Kbytes/sec] received

Registry
Requests per second:693.33 [#/sec] (mean)
Time per request:   1.442 [ms] (mean)
Transfer rate:  164.53 [Kbytes/sec] received

SetHandler perl-script
Requests per second:772.12 [#/sec] (mean)
Time per request:   1.295 [ms] (mean)
Transfer rate:  189.94 [Kbytes/sec] received

SetHandler modperl
Requests per second:1048.66 [#/sec] (mean)
Time per request:   0.954 [ms] (mean)
Transfer rate:  250.84 [Kbytes/sec] received

I'm not sure how well you can really compare the CGI emulation numbers  
to the PerlHandler numbers, but personally i think the 30%ish  
improvement from perl-script to modperl is pretty amazing.  I wouldn't  
have imagined it would have been that high.


Adam








Re: some flawed benchmarks

2008-07-10 Thread Adam Prime
I deliberately removed CGI from the script because i personally would 
never use CGI in something written to be run as straight handlers, and 
it obviously wouldn't make any sense to use CGI in the CGI emulations, 
and then not use it in the Handler version.


Not using heredoc's shouldn't really have any effect on the (already 
flawed) results, because they weren't used in any of the examples.  But 
yeah, it was late and i should have been sleeping but i was dorking 
around with this instead.


I'm personally not really interested in how using CGI affects the 
numbers, but if other people would like to see them i can do this later 
tonight.


Adam


Dodger wrote:

Oh. I would also recommend three variants, based on what people often
do, what people sometimes do, and what people probably should do when
using CGI.pm, which can make a difference (just for thoroughness):

Usually done:
#!/usr/bin/perl
use CGI;
print header;

print <<"EOF";

  
Environment dump:

  @{[map "$_\n$ENV{$_}\n", sort keys %ENV]}

  

EOF

Sometimes do:
#!/usr/bin/perl
use strict;
use CGI;
my $cgi = new CGI;
print $cgi->header;

print <<"EOF";

  
Environment dump:

  @{[map "$_\n$ENV{$_}\n", sort keys %ENV]}

  

EOF

Might do occassionally, and probably should do all the time if using CGI:

#!/usr/bin/perl
use strict;
use CGI(); # note the difference -- using CGI in OO mode, don't import
*anything*
my $cgi = new CGI;
print $cgi->header;

print <<"EOF";

  
Environment dump:

  @{[map "$_\n$ENV{$_}\n", sort keys %ENV]}

  

EOF



Re: some flawed benchmarks

2008-07-10 Thread Adam Prime

Andy Armstrong wrote:

It would be interesting to see how FCGI compares to those numbers.


I don't know anything about fastcgi, but i suppose i could look at that 
also this evening.


Adam


Re: some flawed benchmarks

2008-07-10 Thread adam . prime

Quoting Perrin Harkins <[EMAIL PROTECTED]>:


Note that CGI and FastCGI don't need the proxy frontend.


The only reason I did it that way was because that's how apache was  
already set up on my laptop, and i didn't feel like dorking around  
with it too much.  I could certainly change it around so that CGI and  
FGCGI (if added) were handled by the light apache.  I wasn't sure how  
apples to oranges that would be, but i guess in reality, people that  
are running plain CGI or fast CGI probably aren't doing it on a  
mod_perl enabled server.



It is pretty cool that it works so well.  I feel like I should point
out though, for the benefit of those using Registry, that the
difference is only this big because the code isn't doing anything.  In
a real-world scenario you'd see an improvement, but nothing close to
30%.


It's probably also worth noting that under sethandler modperl the  
GATEWAY_INTERFACE env variable has no value, which results in the page  
being 3 bytes shorter (iirc), which is actually a pretty big deal  
since the whole page is pretty short.  The examples should likely be  
modified to actually return pages that are the same length.


anything else stupid i'm missing?

adam



Re: some flawed benchmarks

2008-07-10 Thread adam . prime


i've changed some stuff and added fastcgi to the mix.  i've given  
numbers through the proxy as well as without it for all the mod_perl  
examples


I've modified the scripts so that they producing the same amount of  
output for each example (except cgi, which adds a content-length  
header, so the total data transfered is larger)


here's the cgi, used under cgi, perlrun and registry:

#!/usr/bin/perl

use strict;

print qq[Content-Type: text/html\r\n\r\n];

my $blurb = qq[1234567890\n] x 100;

print <
Hello Worlds

$blurb


EOF

here's the fastcgi version:

#!/usr/bin/perl

use strict;
use FCGI;

while (FCGI::accept >= 0) {

print qq[Content-Type: text/html\r\n\r\n];

my $blurb = qq[1234567890\n] x 100;

print <
Hello Worlds

$blurb


EOF

}

and here's the handler, used for perlscript and modperl:

package Kabob::HelloWorld;

use strict;

use Apache2::RequestRec ();
use Apache2::Const -compile =>qw(:common);

sub handler {
my $r = shift;

$r->content_type('text/html');

my $blurb = qq[1234567890\n] x 100;

$r->print(<
Hello Worlds

$blurb


EOF

return Apache2::Const::OK;
}

1;


This is the conf entry for fast-cgi

Alias /fcgi/ /www/p/


SetHandler fastcgi-script
Options +ExecCGI



the conf entries for the other examples remained the same as they were  
in the original email.  Obviously i didn't get to the different  
methods of CGI that dodger suggested.  maybe over the weekend.


results ordered by transfer rate:

cgi - no proxy
Total transferred:  1308 bytes
HTML transferred:   1164 bytes
Requests per second:95.58 [#/sec] (mean)
Time per request:   10.462 [ms] (mean)
Transfer rate:  122.09 [Kbytes/sec] received

perlrun - through proxy
Total transferred:  1286 bytes
HTML transferred:   1164 bytes
Requests per second:463.07 [#/sec] (mean)
Time per request:   2.160 [ms] (mean)
Transfer rate:  581.52 [Kbytes/sec] received

registry - through proxy
Total transferred:  1286 bytes
HTML transferred:   1164 bytes
Requests per second:641.11 [#/sec] (mean)
Time per request:   1.560 [ms] (mean)
Transfer rate:  805.10 [Kbytes/sec] received

perlrun - no proxy
Total transferred:  1286 bytes
HTML transferred:   1164 bytes
Requests per second:658.17 [#/sec] (mean)
Time per request:   1.519 [ms] (mean)
Transfer rate:  826.53 [Kbytes/sec] received

perlscript - through proxy
Total transferred:  1286 bytes
HTML transferred:   1164 bytes
Requests per second:788.59 [#/sec] (mean)
Time per request:   1.268 [ms] (mean)
Transfer rate:  990.31 [Kbytes/sec] received

modperl - through proxy
Total transferred:  1286 bytes
HTML transferred:   1164 bytes
Requests per second:1063.74 [#/sec] (mean)
Time per request:   0.940 [ms] (mean)
Transfer rate:  1335.84 [Kbytes/sec] received

registry - no proxy
Total transferred:  1286 bytes
HTML transferred:   1164 bytes
Requests per second:1160.28 [#/sec] (mean)
Time per request:   0.862 [ms] (mean)
Transfer rate:  1457.08 [Kbytes/sec] received

fastcgi - no proxy
Total transferred:  1286 bytes
HTML transferred:   1164 bytes
Requests per second:1201.28 [#/sec] (mean)
Time per request:   0.832 [ms] (mean)
Transfer rate:  1508.57 [Kbytes/sec] received

perlscript - no proxy
Total transferred:  1286 bytes
HTML transferred:   1164 bytes
Requests per second:1430.31 [#/sec] (mean)
Time per request:   0.699 [ms] (mean)
Transfer rate:  1796.18 [Kbytes/sec] received

modperl - no proxy
Total transferred:  1286 bytes
HTML transferred:   1164 bytes
Requests per second:2430.80 [#/sec] (mean)
Time per request:   0.411 [ms] (mean)
Transfer rate:  3052.59 [Kbytes/sec] received

With the proxy taken out of the mix, the jump from perlscript to  
modperl is even more pronounced.


If anyone's got any ideas about why the proxy is having as significant  
an impact as it is, i'd love to tweak it.  Also worth noting is that  
the front end is running worker, the backend is running prefork.


adam



Re: Problem getting started

2008-07-12 Thread Adam Prime

John M. Dlugosz wrote:

I'm trying to use mod_perl on Debian Etch.  I was looking at "practical 
mod_perl" book, but it appears that much has changed in mod_perl 2.0 so the second 
example doesn't work at all.

The first example, which is just two print statements to give a minimal header 
and content text, is invoked so I know the code is installed and the Apache 
configuration files are set up.

But the code from the Synopses of the Apache2::Request module documentation 
causes a segfault on the second line.  The 'use' is OK, but the 'new' shows in 
the apache logs that there was a segfault.

How do I begin to find out what the real error is?  Is there something more 
that needs to be done with Debian installing from the apt?  Could someone post 
a trivial example that ought to work?

--John


It looks like the examples from practical mod_perl are from before the 
API was changed to use Apache2:: instead of Apache::.  So for all those 
examples you'd need to s/Apache::/Apache2::/g.  If you could provide a 
link to the specific example you're having trouble with that might help. 
  The whole book is online at http://modperlbook.org/ if you weren't 
already aware.


For the Apache2::Request problem you're running:

use Apache2::Request;
$req = Apache2::Request->new($r);
@foo = $req->param("foo");
$bar = $req->args("bar");

and getting a segfault on new?

Are you running this as a handler, or through one of the CGI emulation 
layers (ModPerl::PerlRun, or ModPerl::Registry for example).  you do 
also have


my $r = shift;

somewhere above that (and ideally use strict; as well) right?

I personally normally install mp and libapreq from source, so i'm not 
familiar with how one would install/configure them using debian.


Adam


Re: Problem getting started

2008-07-12 Thread adam . prime

Please include the list on replies, so the archives are complete.

Quoting "John M. Dlugosz" <[EMAIL PROTECTED]>:


Adam Prime adam.prime-at-utoronto.ca |mod_perl mailing list| wrote:

For the Apache2::Request problem you're running:

   use Apache2::Request;
   $req = Apache2::Request->new($r);
   @foo = $req->param("foo");
   $bar = $req->args("bar");

and getting a segfault on new?


If I reduce it down to the first two lines only, I get the segfault.
If I reduce it to the first line only, I don't.


Are you running this as a handler, or through one of the CGI
emulation layers (ModPerl::PerlRun, or ModPerl::Registry for
example).  you do


ModPerl::Registry.

In my apache2.conf file:

PerlModule ModPerl::Registry


SetHandler perl-script
PerlHandler ModPerl::Registry
Options +ExecCGI
PerlSendHeader On
Allow from all


Hmm, is there a way to find out whether these settings are applying to
the directory I think it is?  /modperl/ should be applied to each
DocumentRoot, right?



correct.


also have

my $r = shift;

somewhere above that (and ideally use strict; as well) right?


No, just what it shows in the example.


This is your problem.  Apparently if you call Apache2::Request->new
with an undefined object, it segfaults.

i ran this:

use Apache2::Request;
my $req = Apache2::Request->new($r);
print qq[Content-type: text/html\n\n];
print q[hi];

through registry, and saw

[Sat Jul 12 22:58:58 2008] [notice] child pid 5703 exit signal
Segmentation fault (11)

If you change that to

use Apache2::Request;
my $r = shift;
my $req = Apache2::Request->new($r);
print qq[Content-type: text/html\n\n];
print q[hi];

it should work.  Unfortunately, it looks like the documentation for
ModPerl::Registry is kind of lacking on perl.apache.org, but what is
there is at
http://perl.apache.org/docs/2.0/api/ModPerl/Registry.html

Adam






Re: persistent database connection - Apache::DBI with mod_perl

2008-07-16 Thread adam . prime

Quoting Chris Zhuang <[EMAIL PROTECTED]>:


Hi,
 However, when I run an CGI script on the IE 6, it cannot find   
$ENV{MOD_PERL} and start new DBI connection.

 foo.cgi
#!c:/perl/bin/perl.exe -d
use DBI;
use CGI qw(:standard);

my $dbh = DBI->connect("dbi:Oracle:host=xxx;sid=xxx",
 "xxx", "xxx",
 {PrintError => 1, RaiseError => 0,   
AutoCommit => 1,}

 );
END



It looks like your CGI's are are running under CGI, not  
ModPerl::PerlRun, or ModPerl::Registry.


see:
http://perl.apache.org/docs/2.0/user/intro/start_fast.html#Registry_Scripts




Re: installed mod_perl, but no MOD_PERL in ENV

2008-08-06 Thread adam . prime

Quoting Jayson Hill <[EMAIL PROTECTED]>:


I just compiled and installed mod_perl 2.0.3 for apache Apache/2.2.8
Did a LoadModule perl_module modules/mod_perl.so in httpd.conf

No errors and get the following in logs when bounce httpd service:
[Tue Aug 05 22:44:03 2008] [notice] caught SIGTERM, shutting down
[Tue Aug 05 22:44:04 2008] [notice] suEXEC mechanism enabled   
(wrapper: /usr/sbin/suexec)
[Tue Aug 05 22:44:04 2008] [notice] Digest: generating secret for   
digest authentication ...

[Tue Aug 05 22:44:04 2008] [notice] Digest: done
[Tue Aug 05 22:44:04 2008] [notice] Apache/2.2.8 (Unix) DAV/2   
mod_perl/2.0.3 Perl/v5.8.8 configured -- resuming normal operations


However, I don't see the MOD_PERL entry in ENV, and when I print   
$CGI::MOD_PERL value to browser, it is 0.

Not sure why I don't see this as it *seems* that mod_perl is integrated.


I'm assuming that you are trying to run CGI's you were previously  
running under mod_cgi using mod_perl.  Have you added anything to your  
httpd.conf to actually tell your CGI's to run under mod_perl?


see:  
http://perl.apache.org/docs/2.0/user/intro/start_fast.html#Registry_Scripts


Adam



intermittent segfaults, and weird messages in the error log

2008-08-12 Thread adam . prime


I've been getting intermittent segfaults for a couple of days now on  
our dev server, and i'm not really sure why.  I can more or less  
reproduce them, but it's a hit or miss process.  It only seems to  
affect 2 handlers for some reason, and based on what i'm seeing it  
seems like one is some how managing to corrupt the childs  
configuration, then the other is making it segfault.


Here are some examples of the weird messages i'm seeing in the error  
log.  ZZZ::AuthSmb is a simple auth handler we've been using for years  
without any issues.  The random corruption of the name is what makes  
me thing that the config is getting corrupted, but i don't really know  
what i'm talking about.


[Tue Aug 12 09:39:06 2008] [error] lookup of 'ZZZ::AuthzSmb::8here's the backtrace or a core file with MP_DEBUG=1.  Any help would  
be appreciated, i'm at a loss.


(gdb) bt full
#0  0xb7d618cb in modperl_mgv_as_string (symbol=0x9fadc28,  
p=0x9fae240, package=0)

at modperl_mgv.c:393
string = 0x9fadc28 "\002"
ptr = 0x0
mgv = (modperl_mgv_t *) 0x2
len = 2
#1  0xb7d56b21 in modperl_callback (handler=0x85146c0, p=0x9fae240,  
r=0x9fae280, s=0x8504330,

args=0xa104b04) at modperl_callback.c:85
name = 0x11 
symbol = (modperl_mgv_t *) 0x9fadc28
gv = (GV *) 0x0
cv = (CV *) 0x0
flags = 4
sp = (SV **) 0xa24319c
count = 169833880
status = 0
__func__ = "modperl_callback"
#2  0xb7d573ae in modperl_callback_run_handlers (idx=3, type=4,  
r=0x9fae280, c=0x0, s=0x8504330,
pconf=0x0, plog=0x0, ptemp=0x0, run_mode=MP_HOOK_RUN_FIRST) at  
modperl_callback.c:262

scfg = (modperl_config_srv_t *) 0x855d0d8
dcfg = (modperl_config_dir_t *) 0x9fad130
rcfg = (modperl_config_req_t *) 0x9faeff0
handlers = (modperl_handler_t **) 0x9fadd00
p = (apr_pool_t *) 0x9fae240
av = (MpAV *) 0x9fadc88
avp = (MpAV **) 0x9faf010
i = 0
status = 0
desc = 0xb7d7c372 "PerlAuthzHandler"
av_args = (AV *) 0xa104b04
__func__ = "modperl_callback_run_handlers"
#3  0xb7d57848 in modperl_callback_per_dir (idx=3, r=0x9fae280,  
run_mode=MP_HOOK_RUN_FIRST)

at modperl_callback.c:369
No locals.
#4  0xb7d731ed in modperl_authz_handler (r=0x9fae280) at modperl_hooks.c:47
No locals.
#5  0x08076867 in ap_run_auth_checker (r=0x9fae280) at request.c:78
n = 0
rv = 159247752
#6  0x080785d5 in ap_process_request_internal (r=0x9fae280) at request.c:198
file_req = 0
access_status = 
#7  0x08094b98 in ap_process_request (r=0x9fae280) at http_request.c:256
access_status = 2
#8  0x08091e0e in ap_process_http_connection (c=0xa0545f0) at http_core.c:190
r = (request_rec *) 0x9fae280
csd = (apr_socket_t *) 0x0
#9  0x08081e27 in ap_run_process_connection (c=0xa0545f0) at connection.c:43
n = 1
rv = 159247752
#10 0x080a821d in child_main (child_num_arg=) at  
prefork.c:650

numdesc = 0
pdesc = (const apr_pollfd_t *) 0x0
current_conn = (conn_rec *) 0xa0545f0
csd = (void *) 0xa054458
ptrans = (apr_pool_t *) 0xa054418
allocator = (apr_allocator_t *) 0x9f43550
status = 
i = 
lr = 
pollset = (apr_pollset_t *) 0xa052468
sbh = (ap_sb_handle_t *) 0xa052460
bucket_alloc = (apr_bucket_alloc_t *) 0x9faa230
last_poll_idx = 0
#11 0x080a84f6 in make_child (s=0x80d4ce0, slot=4) at prefork.c:746
pid = 0
#12 0x080a85aa in startup_children (number_to_start=1) at prefork.c:764
i = 4
#13 0x080a91d7 in ap_mpm_run (_pconf=0x80d00a8, plog=0x810e1a0,  
s=0x80d4ce0) at prefork.c:985

active_children = 
cutoff = 
index = 
remaining_children_to_start = 5
rv = 
#14 0x08068948 in main (argc=135061664, argv=0xa052410) at main.c:730
c = 68 'D'
configtestonly = 0
confname = 0xbfbb07c0 "/www/conf/httpd.conf"
def_server_root = 0x80b2523 "/www/apache/heavy"
temp_error_log = 0x0
error = 
process = (process_rec *) 0x80ce130
server_conf = 
pglobal = (apr_pool_t *) 0x80ce0a0
pconf = (apr_pool_t *) 0x80d00a8
plog = (apr_pool_t *) 0x810e1a0
ptemp = (apr_pool_t *) 0x80d60c0
pcommands = (apr_pool_t *) 0x80d20b0
opt = (apr_getopt_t *) 0x80d2150
rv = 
optarg = 0xbfbb07d7 "BackEnd"




Re: mod_perl users survey

2008-09-03 Thread adam . prime


One final call for responses.  It'd also be appreciated if you could  
forward the survey on to your local Perl Mongers Groups to help us  
reach some people that might be a little more disconnected from the  
mod_perl community.


We've got over 300 responses so far, thanks to everyone that has taken  
the time to respond.


Adam



Quoting [EMAIL PROTECTED]:


At the impromptu mod_perl BOF at YAPC::NA, Fred Moyer any myself
hacked together a short mod_perl survey to help identify the current
needs of mod_perl users. It was inspired by the Perl survey done last
year by Kirrily Robert. (http://perlsurvey.org).  If you read dev@ and
already filled this out, please don't do it again.

The link is here:

http://www.surveymonkey.com/s.aspx?sm=bQyb2RFCBuVb0P52yhaCMg_3d_3d

The survey seeks to attain these goals:

1) Determine the current breakdown of mod_perl users in terms of what
versions, modules, and platforms mod_perl users are using.

2) Give mod_perl users a chance to provide feedback to the development
team on where they think mod_perl development should be headed.

Please take a few minutes and fill it out.  Neither of us are
statisticians, and there are plenty of questions that haven't been
asked, but we only get 10 questions for free with survey monkey, so
we've done what we could with our non-existant resources.

Thanks,
Adam














Re: question on downloading CGI

2008-09-05 Thread adam . prime

Quoting [EMAIL PROTECTED]:


Hello,

I want to generate a data file which should be downloaded by clients.
Rather than generate this file and put it in a web dir and tell
clients to download it, is there any way to generate the content
dynamicly and put it to cients? I mean I don't want to generate the
temporary file. Thanks.


This reads to me like you just want to cause the browser to prompt the  
user to save the file to disk instead of render the content you are  
generating in which case you should read about the Content-Disposition  
header:


http://www.ietf.org/rfc/rfc1806.txt

The quick summary of which is to add a header to your response that  
looks like this:


Content-Disposition: attachment; filename=filename.extention

Adam







Re: How to extract name/value pairs from the query string?

2008-09-23 Thread adam . prime

Quoting Fred Moyer <[EMAIL PROTECTED]>:

See Apache2::Request, it mirrors the CGI param api.


In case you dont know, Apache2::Request is part of libapreq2  
(http://httpd.apache.org/apreq/).  IMO, using it is the best way to  
achieve what you're trying to do if you're developing for mod_perl  
only.  (ie you don't care if the code will run under plain CGI or not)


Adam




Re: Apache::DBI 1.07 requires global $r - workaround?

2008-09-24 Thread adam . prime
1.07 is broken.  PGOLLUCCI said it was going to get reverted, but  
apparently it hasn't happened.


see http://rt.cpan.org/Public/Bug/Display.html?id=36346

Adam

Quoting Perrin Harkins <[EMAIL PROTECTED]>:


On Wed, Sep 24, 2008 at 12:39 PM, Fred Moyer <[EMAIL PROTECTED]> wrote:

I went ahead and use 1.06 in my production setup.  If you want to use 1.07,
you will need to include the GlobalRequest option in your config setup.


It should be fine to use GlobalRequest.  The warnings against it are  
 outdated.


- Perrin







Re: live and dev versions of a module on the same server

2008-10-03 Thread adam . prime

Quoting John Drago <[EMAIL PROTECTED]>:


There are a few options:

1---
Run your VirtualHost with PerlOptions +Parent.
This gives each VirtualHost its own Perl interpreter.


This is mod_perl 2 specific, and until right now i personally was  
completely unaware of it.  Has anyone actually used it?  Does it work  
under all the MPM's?


Adam



Re: questions on Apache2::Connection

2008-10-11 Thread Adam Prime

André Warnier wrote:

Hi gurus.

Do I understand this correctly that if in a Perl Handler i get
my $c = $r->connection();
then $c is the object that represents the persistent TCP/IP connection 
between the browser and the server, in case there is "keep-alive" going 
on ?

>
Now lets say that I create an authentication method based on the Request 
(as they tend to be usually).
On the first request, the authentication happens, and I set a 
$c->notes('credentials') value. I also set a browser cookie.


On subsequent requests, I could check this $c->notes('credentials') 
first, in case a previous request over the same connection already 
resulted in authentication, could I not ?


I just read the docs, and though it doesn't explicitly say that that 
that would, or wouldn't work, but the existance of $c->keepalives() 
makes me think that it would work.  It'd be pretty easy to confirm 
though, so i'd suggest you do that.


In the worst case, the connection is new and I would not have these 
notes (meaning I then need to get the cookie, and in its absence redo an 
authentication); but in the vast majority of cases (depending on 
keep-alive), I could save myself some overhead by considering the 
connection as authenticated instead of the request, no ?


Or are there some pitfalls here of which I am ignorant ?
Or is the potential gain not worth the cost of getting the $r->connection ?


If you've got a heavily trafficked site, and confirming that your auth 
cookies are valid is expensive, then doing something like this could 
make sense.  How much of an effect it's going to have is something that 
would be very dependent on the clients your site has more than anything 
though.  You'd might want to do some investigation into how much of your 
traffic actually comes from from requests through a connection that was 
kept-alive by keep-alive.


It is an interesting idea though.

Adam


Re: auto configuration

2008-10-12 Thread adam . prime

Quoting valerio crini <[EMAIL PROTECTED]>:


Hallo,
I'm trying to use modperl2's feature 'auto configuration' but without
success.

Manual says in

http://perl.apache.org/docs/general/testing/testing.html#Auto_Configuration

that in order to add automatically new items to location is necessary
adding a package called

TestResponse::'packagename'

that magically will be converted in a

/TestResponse__'packagename' entry in apache configuration

I've tried create such package (simple renaming existing and working
package) with name 'TestResponse::TestHandler2'
but when i issue following command:

my $content2 = GET_BODY(
'/TestResponse__TestHandler2?provider=1012&uid=%
2B12233051141&app_id=1223305114-245452&channel=channel&description=bla
+bla+bla&debug_response=OK&service_code=acl-service2&command=book'
);
ok( t_cmp( $content2, '' ) );

I've this response

# received: 
# 
# 404 Not Found
# 
# Not Found
# The requested URL /TestResponse__TestHandler2 was not found on this
server.
# 

I think i'm failing in something but i can't understard where my error
is, googling I'didn't found any clue.
May some sage help me?



I just had a look at this stuff, and it seems like there is one big  
whole in the documentation which is how exactly Apache::Test finds the  
packages that it needs to create Location blocks for.  I tried a  
couple of things (including them directly in the .t file, in a plain  
path in the t/ directory) but they didn't work.


Perhaps Fred or Geoff, or someone else with a little more experience  
with Apache::Test can shed some light onto this feature.


Adam




Re: requests and sub-requests

2008-10-12 Thread Adam Prime

André Warnier wrote:

Torsten,

Many thanks for the excellent information, I will ponder that.

More below, but one more question here :
Where does $r->internal_redirect "live" (in which package) ?
I am having trouble finding it.


http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_internal_redirect_

As a first stage of the AAA, for some Locations, there is a filtering on 
the remote IP of the caller.  Some IP's get an "automatic" user-id, 
which can vary according to the IP. In some cases, this is authoritative 
(no access unless you have the right IP), in some cases not (you get a 
second chance).  Some Locations don't have the IP filter, they always 
get the second chance below.  This IP filter is implemented as a 
PerlAccessHandler. This is the main reason for trying to optimise, 
because it is expensive : the IP of the caller must be compared to 
several ranges of IP, not necessarily matching regular subnets.


It seems odd to me to set $r->user in an AccessHandler.  It's probably 
not a problem, but it seems (at least to me) that that would make more 
sense as a part of the Authen code.  You can then control all your 
'second chance' stuff with normal state checking within your Authen 
Handler instead of doing funky stuff with set_handlers (which seems to 
be what you're doing)


Adam


Re: mod_perl2 start one script twice

2008-10-22 Thread Adam Prime

CthuMP wrote:

I have follow simple script:
!#/usr/bin/perl

print "Content-Type: text/html\n\n";

print "Counter: " . (++$counter) . "\n";
print time(), "\n";

sleep(20);

print time(), "\n";

Starting that script twice in two different browser windows gives me same
results. In second window I start script after some period (about 10
seconds) after first script started. First and Second scripts ends at the
same time.
So, I misunderrstand, why results are same?
  
If you're actually seeing the same results from the 'print time()' 
calls, something weird is going on. A proxy server between you and the 
server might cause that i suppose, or something the browser is doing 
with caching, but that shouldn't really happen at the server end i don't 
think (unless there is some sort of caching mechanism going on there too.



As I see it, apache must give work to second child processes for second
request (because first busy). And scripts must end works in different time
(first script in 10 seconds before second) and give different results (same
counter result, but different times).
  

That sounds accurate to me


Even if script runs sequentially for each request, results will difference
and second script ends after 30 seconds (10 remained for 1st script and 20
for 2nd). But it is not!
If I copy script and run two same scripts with different names it works
fine.


Second question about childs. I not fully understand, how childs work. One
child can handle only one script? It's important, because if one child can
handle different scripts, than module global variables saves their values
between different script calls.
For example, if script1 and script2 uses module My::TestPackage, first
script sets $My::TestPackage::variable = 123, then script2, after it
request, will see in $My::TestPackage::variable value 123, but I haven't
seen mention about that situation in official documentations.
  
Each apache child will handle any and all scripts. You can't reliably 
share global variables like that for exactly the reason you mention. 
Generally, if you're running code under mod_perl you should be running 
it under 'use strict' (which would break your original example).


Adam




Re: PerlAuthenHandler & phpMyAdmin

2008-10-22 Thread Adam Prime
Usually, if you run into problems that only affect POST requests, that 
means that somewhere earlier in the apache cycle there is something 
consuming the posted data.  Looking at the code you've posted though, 
it's not immediately obvious that that is the problem, nor is it obvious 
that it's actually the even related to the problem that phpMyAdmin is 
displaying.  That is something you can look into further though  Perhaps 
part of DataJoy::Application is reading the post variables out of STDIN.


Adam



Miha Lampret wrote:

Hello all,

Today I tried to limit access to phpMyAdmin using my own Authen.pm
module. It works well but not always. Looks like phpMyAdmin has
problems with HTTP post method if I enable my PerlAuthenHandler
Authen.pm. Otherwise phpMyAdmin and Authen.pm work well.

The error I get in phpMyAdmin is:
Fatal error: PMA_sendHeaderLocation called when headers are already
sent! in /opt/datajoy/www/lib/phpMyAdmin/libraries/common.lib.php on
line 650

I am not sure what causes this problem. It may be phpMyAdmin issue or
there is something wrong in my Authen.pm. But since my Authen.pm works
well when limiting access to directories/files and since I have no
problem with phpMyAdmin if I use .htaccess with password file
(AuthUserFile) I thought it might be mod_perl issue. Anyone else
noticed strange behaviour when using PerlAuthenHandler? It is the same
if I use PerlAccessHandler.

I hope someone can direct me where to look for solution.

Best regards,
Miha

Server software:
Apache/2.2.9 (Debian) PHP/5.2.6-5 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.0
I also noticed this problem in older versions of Apache, perl, mod_perl and php.

Bellow are my Apache settings for phpMyAdmin dir and Authen.pm module:


PerlSendHeader Off
AuthName DatajoyWebAuth
AuthType Basic
PerlAuthenHandler Datajoy::Authen
require valid-user



package Datajoy::Authen;

use strict;
use Apache2::Access ();
use Apache2::RequestUtil ();
use Apache2::Const -compile => qw(OK DECLINED HTTP_UNAUTHORIZED);

use Datajoy::Application;
use Datajoy::Config;

sub Authenticate {
my ($domain,$user,$pass,$file)[EMAIL PROTECTED];
my $result=0;

my $app=Datajoy::Application->new();
$app->Db_Connect;

my $sth=$app->{dbh}->prepare("select users.org_id, users.id, pages.path
  from domains,users,pages
  where domains.page_id=pages.id and users.org_id=domains.org_id
  and domains.domain=? and users.username=?");
$sth->execute($domain,$user);
my ($org_id,$user_id,$domain_path)=$sth->fetchrow_array;

if ($org_id && $user_id) {
my $auth=undef;
eval '$auth='.$app->{config}->{auth_module}.'->new($app)';
if (! $@) {
my ($logged_in,$uref)=$auth->Login($org_id,$user,$pass);
if ($logged_in>0) {
$result=1;
}
}
}

return $result;
}

sub handler {
my $r=shift;

my ($status,$pass)=$r->get_basic_auth_pw;

return $status unless $status == Apache2::Const::OK;

my $domain=$r->hostname();
my $user=$r->user;
my $file=$r->filename();

if (Authenticate($domain,$user,$pass,$file)) {
return Apache2::Const::OK;
} else {
$r->note_basic_auth_failure;
return Apache2::Const::HTTP_UNAUTHORIZED;
}

}

1;
  




reading apache configuration via mod_perl

2008-10-23 Thread Adam Prime


At $work we have a situation where large chunks of configuration are 
being created with PerlSections, in combonation with mod_macro.  There 
is a desire to see what exactly that all get mapped to in a more 
traditional Apache configuration like style.  PerlSections->dump kind of 
does what we want, except that it doesn't expand the macro's that are 
used.  mod_info also has the same sort of problem.


Is it theoretically possible to actually generate something like that?  
I imagine that you'd have to somehow get at the actual data structures 
that the server creates to represent the parsed configuration and then 
somehow turn that back into something human readable.


Any ideas?

Adam


Re: reading apache configuration via mod_perl

2008-10-23 Thread Adam Prime

Michael Peters wrote:

Adam Prime wrote:


Is it theoretically possible to actually generate something like that?

> Any ideas?

I'm definitely ignorant enought about Apache's internals to be able to 
answer that question. And the following doesn't really answer your 
question, but this is how we handle having a dynamic config while 
still being able to see what it looks like. We use a template. We have 
a wrapper script around Apache that queries the database and config 
files and then starts Apache pointing to the generated conf file. This 
gives us the benefit of a data driven config but we still get a real 
config file out of it that we can inspect.


I suggested this when I started here, but we were already too committed 
to PerlSections at that point. I don't think that that's likely to 
change but it is an option to be considered though if we have to 
refactor.  If we were starting this now, I would definitely favor doing 
it that way.


Adam


Re: reading apache configuration via mod_perl

2008-10-23 Thread Adam Prime

Perrin Harkins wrote:

On Thu, Oct 23, 2008 at 3:22 PM, Perrin Harkins <[EMAIL PROTECTED]> wrote:
  

On Thu, Oct 23, 2008 at 2:55 PM, Adam Prime <[EMAIL PROTECTED]> wrote:


PerlSections->dump kind of does what we want,
except that it doesn't expand the macro's that are used.
  

This may be obvious in hindsight, but using mod_macro was probably a
bad idea.  I'd suggest using perl to handle what you were doing with
mod_macro.  Actually, I'd suggest staying far away from PerlSections
and doing a templated conf file as Michael recommend, but that may too
much to change all at once.



On second though, before you do anything else, ask the mod_macro
people how they deal with this.  They must get this question a dozen
times a day.

- Perrin
  


Good idea.  I'm pretty sure they are just going to tell us to use 
mod_info though, which unfortunately doesn't play well at all with 
mod_perl's PerlSections, but i've asked anyway.


Adam



Re: Bug: APR::Finfo->protection is not (stat $filename)[2]

2008-10-29 Thread Adam Prime

Philip M. Gollucci wrote:

Joachim Zobel wrote:

Hi.

If stat returns 777 (octal), protection returns 0x777 (hexadecimal). The
documentaion claiming this as the same value should be fixed.
If you can submit a patch or point to this documentation, I'll be glad 
to update that for you.




I'm guessing this is the page he was referring to.

http://perl.apache.org/docs/2.0/api/APR/Finfo.html#C_protection_

Adam


Re: $r->status no correct

2008-10-29 Thread Adam Prime

Michael Peters wrote:


But when I make the request to just /foo (instead of /foo/index.pl) I 
only get this in my error log:

URI: /foo/ STATUS: 200

you've said to /foo, but your error_log is saying /foo/.  What's going 
on there?  mod_dir redirecting a bare directory request?


The stranger part is that the access log still reports it correctly as 
an error:

GET /foo/ HTTP/1.1" 500

And the error still appears in the error log, it's just that 
$r->status (and $r->notes('error-notes') don't contain the right 
information).


So what's going on here. Shouldn't the 2 requests (/foo and 
/foo/index.pl) be treated exactly the same?


Is this happening with just a mod_perl enabled server, and no proxies or 
anything?  I don't really know how directory index works, but i'm pretty 
sure that what it issues internal redirects (or lookup_uri's) for all 
the filenames you've got in your DirectoryIndex config.  Is that 
behavoir what you're expecting (if not, might it be involved in this odd 
behavoir?).  Does the client see the 200, or the 500?


Adam



Re: $r->status no correct

2008-10-29 Thread Adam Prime

Michael Peters wrote:
The client always sees the 500 which is what the access log reports as 
well. It's just that in the CleanupHandler it comes back as 200 for 
/foo/, but 500 for /foo/index.pl.


That really is strange.  Perhaps the status is getting mangled at the 
end of the Log phase or something?  Maybe it has something to do with 
the fact that the Cleanup phase isn't actually an apache phase?  What 
happens if you try to run your code as a LogHandler instead of a 
CleanupHandler?


Adam



Re: $r->status no correct

2008-10-29 Thread Adam Prime

Michael Peters wrote:


The client always sees the 500 which is what the access log reports as 
well. It's just that in the CleanupHandler it comes back as 200 for 
/foo/, but 500 for /foo/index.pl.



Just to be clear, when you do this:

GET /foo/

do you get this in the error log?

URI: /foo/index.pl STATUS: 500 (the sub request from Directory Index)
URI: /foo/ STATUS: 200 (the original request)

If that's the case, then the 200 is a bit weird, because it's not 
consistent with the actual status returned by the request (which would 
be the status of the subrequest), but might be understandable because 
the request for /foo/ itself didn't 500.  In which case it might 
actually be a bug either in Apache, or in mod_perl (i have no idea)


Adam






Re: $r->status no correct

2008-10-29 Thread Adam Prime

Ryan Gies wrote:

Not a permanent home, but here is module which will slip in and give
you similar messages.

  http://dev.livesite.net/Apache-Trace.pm

just put it in a dirctory named 'Apache2' in your @INC and add:

  PerlPostReadRequestHandler Apache2::Trace->http_phases
  

You should package that up and put it on CPAN.


Re: Modperl memory exceedance under mason webmail

2008-11-02 Thread Adam Prime
Jim Donovan wrote:
> Hi,
>
> We run a webmail system which was written in Mason. It won't let you download 
> or read large attachments (~5MB upwards). This seems to be some sort of 
> memory allocation error.
>
> If you watch the server with top(1) while downloading a 2MB attachment, you 
> can see the memory usage climb quickly to 45MB. With larger attachments, 
> growth is ppresumably even faster and some limit is passed, crashing httpd.
>
> Does anyone know what is happening and how to control it, please?
>   
This is happening when you're serving a file that's encoded into an
email down to a logged in webmail user?  That just sounds like bad code
to me or something.  mod_perl doesn't do anything on it's own that would
justify that kind of memory usage just serving a file.  I could see how
it'd be easy to chew up RAM if you're reading a MIME encoded attachment
into a scalar, then converting it to binary, then serving it back to the
client though.

Adam


Re: Remove Perl*Handler from subfolder

2008-11-03 Thread Adam Prime

Jan-Aage Frydenbø-Bruvoll wrote:

Example:


  SetHandler perl-script
  PerlResponseHandler myreponsehandler
  PerlAccessHandler myaccesshandler



  SetHandler default-handler
  # how to disable the PerlAccessHandler?


As you can see I've found how to disable/re-set the response handler, 
but the Access handler is still active. Any tips, please?




I believe you can do something like:

PerlAccessHandler "sub {return Apache2::Const::DECLINED;}"

Adam


Re: mod_perl survey results

2008-11-10 Thread Adam Prime

André Warnier wrote:
The responses there are indeed a bit scary.  It feels like we're a dying 
breed.
I believe this is to a large extent a "marketing issue" for perl in 
general, and mod_perl by extension, with regard to the younger 
programmers generation.  At least in various European countries I know, 
perl is not really being taught in programming schools as a "serious" 
programming language for applications. These young people have all heard 
the name, but seem to consider it as a powerful but somewhat messy 
scripting language to create system administration scripts.
I am personally doing my best to introduce these newbies to the beauties 
of perl and mod_perl, but it feels rather lonely sometimes.

Java and PHP seem definitely more popular, or better-known.


I agree that this does echo perl's problems in general, but mod_perl has 
a long history of not really being very good at marketing itself.  I 
know Perrin and some other people did try at the launch of mod_perl2, 
but that effort (and the associated mailing list) has long since dried up.


- A surprising number of people are running mod_perl under the worker 
MPM.

What is so surprising about this ? (genuine curious question)


It's surprising to me, and probably to Torsten, because the perceived 
common wisdom is to run prefork, because worker may or may not be as 
well tested, and has all the bonus issues related to thread-safeness.



- the documentation could use some work.  Specifically more tutorial /
intro kind of stuff.
Agreed.  There is a definite need also for something like a new mod_perl 
Guide and Cookbook all-in-one, updated for mod_perl 2 and with a section 
about the framework/template systems mentioned above. Written in a style 
meant to show that these are not old-fashioned technologies only 
practised by oldies like me (us?).
What I mean is that to cover all one needs to know to create some 
serious web applications in Java, you'd need at least 6 thick volumes, 
while for Perl 800-1000 pages would be more than enough.

O'Reilly, where are you ?


Honestly, I think this stuff is currently better handled by the 
community.  As such, i'm going to take a stab at writing some very basic 
intro / tutorial kind of documentation to be added to perl.apache.org. 
When i started with mod_perl 1, the Guide on thought the "guide" 
perl.apache.org was amazing, but it seems to me that mod_perl 2 doesn't 
have that in the same way.  Much of the content has been ported over to 
the 2.0 section, but there are many pages that haven't been updated from 
the 1.0 tree at all.


Adam


Re: Substituting URLs in PerlOutputFilterHandler

2008-11-10 Thread Adam Prime

Puneet Lakhina wrote:

Hi,

I am trying to write a handler that modifies the content of the page
based on a regex match. essentially im trying to modify 
tags in the outgoing HTML pages.
Now I am trying to do this using PerlOutputFilterHandler. I have the
following questions:
a) Is this the right filter to use for an application like this?
b) As per my understanding my hander can be invoked multiple times
based on the no. of buckets. Is this correct? If yes, then how should
I handle the situation where a part of the tag like say '' comes in another.


This is exactly the situation that Apache2::Filter::TagAware was built for.

http://search.cpan.org/~aprime/Apache2-Filter-TagAware-0.02/lib/Apache2/Filter/TagAware.pm

Adam


Re: mod_perl survey results

2008-11-10 Thread Adam Prime

Steven Siebert wrote:

I'm relatively new to mod_perl - moving to a new job who's application
is solely written in it.  This is a return to Perl for me, having
worked in PHP, Java, and .NET since Perl 4.  As I'm learning to love
mod_perl and Perl in general, perhaps it's a good time for me to
contribute back by writing perl/mod_perl blogs and tutorials to help
others easing in from other languages (written with a set of
assumptions).  I've seen the "to-do" list, if you will, on the
mod_perl Advocacy page
(http://perl.apache.org/docs/general/advocacy/advocacy.html) but not
sure how dated this is or what is the best to tackle.
  
That page probably dates back to late 2004, which is when mod_perl 2 
actually hit the streets, and the last time the advocacy mailing list 
saw any sort of usage.  The mp-advocacy archives can been seen here: 
http://marc.info/?l=apache-modperl-advocacy&r=1&w=2, and is, as you 
noticed, pretty much dead.  I'm not in any way the boss of this sort of 
stuff, but i'd say if you want to bring anything up,  you should 
probably bring it up here.  If, by some miracle advocacy talk (and even 
better work), starts getting too chattery on this list, then it could be 
moved.


I think people blogging about mod_perl would be great, but personally, I 
think that the best place for tutorials is ultimately on perl.apache.org.



Let me know how to get involved - it is my job security after all =).
Seriously, though, the flexibility of mod_perl is just not available
in many of the other languages and I think it's "don't know what you
don't know" sort of thing...so much work is done in the application
code when it could be solved with a few lines using mod_perl at the
httpd abstract layer.  I have a blog site but if perl.apache.org
desires host tutorials and blogs, so much the better (better
discoverability).
  
http://perl.apache.org/contribute/ has some pointers about different 
ways you can help, but this page too probably hasn't been updated in 
years.  I think you're absolutely right about the "don't know what you 
don't know thing".  If more people we're blogging about problems they'd 
defeated with mod_perl it couldn't hurt  the situation, at least IMO.  I 
believe that most, if not all, of perl.apache.org is built out of the 
/modperl-docs/ SVN repository.


Adam



Re: mod_perl survey results

2008-11-10 Thread Adam Prime

André Warnier wrote:

Maybe this is the time to ask.
I am using Linux Debian, and getting Apache 2, perl and mod_perl 2 
from there (apt-get).
I have never been quite sure which mpm the packager decided to 
configure, as the apache2.conf contains parameters for prefork, 
pthread and perchild. So,

a) which is the best way to find out ?
b) if it happened to be "worker" or something, could I just change 
that to "prefork", or is there more to it ?


(Also so far, even if it is using a threaded mpm, it does not seem to 
have any deleterious effect on my systems, which are pretty stable).


Thanks

./httpd -V
Server version: Apache/2.0.54
Server built:   Sep 25 2005 00:31:31
Server's Module Magic Number: 20020903:9
Architecture:   32-bit
Server compiled with
-D APACHE_MPM_DIR="server/mpm/prefork"
...

The -D APACHE_MPM_DIR tells you which MPM your apache is using.  In 
order to change MPM's you need to recompile apache, and quite possibly 
mod_perl as well, i have no idea how you'd accomplish that on debian 
using apt.





mod_perl survey results

2008-11-09 Thread Adam Prime
The results of the mod_perl survey that Fred Moyer and I conducted can
be found at the following link:

http://kabob.ca/mod_perl_survey/

Here's a quick list of obvious (though arguable) conclusions:

- a lot of people have switched to mod_perl 2, mod_perl 1 is still very
significant.
- most of the people using mod_perl have been using it for a long time.
- the rate of new people coming into the community has been declining.
- linux is by far the most popular platform. the BSD's, Solaris and
Windows also make a significant showing.
- Fred and I didn't really break down frameworks very well, but mason,
Catalyst and CGI::Application are quite popular.  TT is also very
popular, but not exactly a framework, but not quite as popular is old
fashioned Handlers.
- A surprising number of people are running mod_perl under the worker MPM.
- Most of the Handler phases are getting some use.
- There are a lot of people using CGI Emulation, which is not a surprise.
- not very many people are using the mod_perl2 filter api.
- there is quite a bit of interest in a mod_perl Workshop, but location
would be a key factor for a lot of people
- the documentation could use some work.  Specifically more tutorial /
intro kind of stuff.

 Adam


Re: [mp2.0.4] t/hooks/authen_basic (Wstat: 0 Tests: 4 Failed: 1)

2008-11-10 Thread Adam Prime

Chen, Peter wrote:


Hi,

 

I have been trying to install mp2.0.4. In addition to having problems 
with authen_basic, I am also getting a test fail for t/hooks/authz as 
well.


 

My perl Makefile command is as follows: *perl Makefile.PL 
MP_APXS=/home/Intranet/ssiweb/apache/bin/apxs*


 


Here are the relevant contents from the log file:

END in modperl_extra.pl, pid=19963

END in modperl_extra.pl, pid=19962

END in modperl_extra.pl, pid=19979

[Mon Nov 10 13:00:43 2008] [info] removed PID file 
/home/src/perl_modules/mod_perl-2.0.4/t/logs/httpd.pid (pid=19955)


[Mon Nov 10 13:00:43 2008] [notice] caught SIGTERM, shutting down

END in modperl_extra.pl, pid=19955

 

What's in modperl_extra.pl?  You didn't really describe what's you're 
seeing, so i'm assuming that apache isn't starting up correctly, and 
that that's what you're seeing in the error_log with the LogLevel set to 
debug.


Re: [mp2.0.4] t/hooks/authen_basic (Wstat: 0 Tests: 4 Failed: 1)

2008-11-10 Thread Adam Prime

Chen, Peter wrote:

Apache isn't starting up correctly? I already have the apache server
running. Will this affect the configuration? When I type the command "ps
-eaf | grep apache", it seems to indicate that apache is running.
  

Please CC the list on your replies, it has much more wisdom than I do.

I'm trying to understand what you're asking for help with.  Your subject 
is about a build test failing, but then you included a wall of error_log 
output, which doesn't really seem to be related, but does seem to 
indicate that you've got mod_perl 2.0.4 installed and running.


mod_perl 2 has frequently had it's tests start failing when new versions 
of httpd have come out and changed things around a bit, those tests have 
frequently resided in the auth subsystem, but generally have been 
problems with the test, not with mod_perl or apache.  I have no idea if 
that is the case in this particular situation though, i personally 
haven't built 2.0.4 against 2.2.10 on any platform, never mind solaris.  
Personally, i think that when this occurs, a new version of mod_perl 
should be pushed out that corrects the problem (even if it doesn't 
correct anything else), but I'm not on the dev team ;)


So I guess my question is, what's your question?

Adam




Re: mod_perl survey results

2008-11-11 Thread Adam Prime

Perrin Harkins wrote:


It's the same with mod_perl: you can restart your backend server
without touching the frontend proxy server.  It's possible that some
FastCGI implementations have a truly seamless way to do this though,
holding requests while the backend restarts.  I haven't played with it
enough to know.

- Perrin
  
I'd really love to see a best practices kind of document, or at least a 
more detailed document that described getting the light front / heavy 
backend stuff working.  The mp1 guide has a pretty extensive section on 
the various options, but it hasn't been updated to reflect apache2/mp2.  
It also doesn't address any of the little hoops that need to be jumped 
through to get all the ancillary, but important, bits working.  Things 
like getting backend server authentication info logged on the front end 
server, getting the front end remote_ip to the backend server, how to 
manage configs between the front and back end.  I'm sure there's other 
stuff that I'm missing.  It'd actually be nice just to see a list of 
'things you might not have thought about' that go along with that 
configuration model.


I suppose that arguably this is beyond the scope of mod_perl, but if 
we're constantly going to trot out the idea that you should be running 
in this kind of configuration, we should probably do everything we can 
to make deploying that configuration as painless as possible.


Adam


Re: Apache doesn't execute perl scripts

2008-11-12 Thread Adam Prime

Mustafa Aldemir wrote:



AddType application/x-perl-httpd .pl
AddHandler perl-script .pl

LoadModule perl_module /usr/lib/apache2/modules/mod_perl.so
LoadModule cgi_module /usr/lib/apache2/modules/mod_cgi.so


 AllowOverride None
 Options FollowSymLinks +ExecCGI -MultiViews +SymLinksIfOwnerMatch
 Order allow,deny
 Allow from all
 SetHandler perl-script


Alias /awstatsclasses "/usr/share/awstats/lib/"
Alias /awstats-icon/ "/usr/share/awstats/icon/"
Alias /awstatscss "/usr/share/doc/awstats/examples/css"
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
ScriptAlias /awstats/ /usr/lib/cgi-bin/



You need:

PerlHandler Apache::Registry

(or one of the other CGI emulators) in your directory section.  take a 
look at:


http://perl.apache.org/docs/1.0/guide/intro.html#toc_Apache__Registry

It looks like you're running mp1, so this response assumes that.

Adam


Re: [mp2] build (make) error and 2 questions

2008-11-13 Thread Adam Prime

[EMAIL PROTECTED] wrote:


Philip: but I liked the idea of a static build?  Not just for operational
performance, but for startup performance and perhaps for some possible 
better

integration of the symbol tables for debugging?  Are you saying that the
1.2 error cannot be worked around, and I should just give up on the static
build idea?  Like I had to on perl SSI's (

Re: Apache 1.3 -> 2.x portability

2008-11-14 Thread Adam Prime

Michael Peters wrote:

Phil Carmody wrote:
I'm currently running only Apache 1.3 (mod_perl 1.22) and am wondering 
what kinds of issues there might be if I were to want to migrate my 
server to Apache 2.x and mod_perl 2.
Are there any things that I can do (or avoid) to make such a migration 
as close to trivial as possible.


http://perl.apache.org/docs/2.0/user/porting/compat.html

The biggest problem that I've seen is that not all of the Apache:: 
modules on CPAN have been ported to Apache2 or been setup to work for 
both. Most of the big ones have so it depends on what you're using. And 
it's not that hard to port one of them if you need to.




There are also some details about porting from libapreq1 
(Apache::Request) to libapreq2 (Apache2::Request) that are mentioned at 
the bottom of this page:


http://httpd.apache.org/apreq/docs/libapreq2/group__apreq__xs__request.html

There's another thing that isn't currently mentioned as well, which is 
that my @params = $r->param() under libapeq2 no longer returns a 
unique'd list of params.  on a request like ?a=b&a=c, it will return (a, 
a).  under apreq1 it returned (a).


Adam


Re: How to reject requests before request body is sent?

2008-11-24 Thread Adam Prime

Thomas Lindgren wrote:

Hi all,

I'm using mod_perl2. I'd like to reject user requests, e.g., very 
large PUTs, after examining headers and authorizing the user, but 
before the request body is read. Quota checking could be an example of 
where this is useful.


However, at this time, even if I return an error in the handler, it 
(surprisingly) seems as if the request body still is uploaded. What to do?



The only way to trigger an early close so far has been to die in the 
handler, which confuses clients and so on.


The server could as a worst case alternative actually close the 
socket, but that feels inelegant and hackish. So, my question to the 
esteemed list, how should this sort of thing best be done? Have I 
forgotten something basic? Should I return something else? Is there a 
more appropriate phase to do this? Should I do it another way entirely?
This could be useful, but I think it's also pretty much impossible.  
From what I understand, the entire request is read before any 
processing is done at all, and definitely before the HeaderParserPhase 
is executed, which is why you're seeing the behavior you describe.


The only other technique you might try would be an InputFilter, but I 
have a feeling that even that wouldn't really stop the upload from 
happening (ie the consumption of bandwidth).  I think this has more to 
do with TCP pipelining than it does with anything else, so it's actually 
not "fixable" in the application at all.


Adam


Re: Best filesystem type for mod_cache in reverse proxy?

2008-11-24 Thread Adam Prime

Neil Gunton wrote:


It seems like this might have something to do with mod_deflate, which 
I am using in combination with mod_disk_cache. This page gives a clue 
that there might be a problem with the way files are cached when these 
modules are both enabled:


http://www.digitalsanctuary.com/tech-blog/general/apache-mod_deflate-and-mod_cache-issues.html 



Seems like a very recent post (Nov 18th).

Any ideas? Seems like a big problem, if you're trying to use a reverse 
proxy on a large dynamic site, and also optimize bandwidth by using 
mod_deflate too.


Neil
That does look like a big deal, if i were in your situation, I'd try 
running with only mod_deflate, then only mod_cache, and see what 
happens.  There are benefits to running the reverse proxy alone (without 
mod_cache), so that'd be the first scenario i'd try.


Adam


Re: Help -- how can I make the Apache process die at the end of the request?

2008-12-04 Thread Adam Prime

Victor Danilchenko wrote:
I need to do it forcibly, no matter what happens during the request. 
I have to slightly relax security constraints to call an unusual 
subrequest, and since I cannot guarantee that the cleanup code will be 
reached (what if the subrequest is terminated by the client, or dies on 
a bug?), I figure my best bet it to make sure that at the end of the 
request execution, the current apache process dies so that a new one can 
be spawned. 'kill $$' is obviously inadequate.


Does anyone have any idea how this can be achieved? perhaps 
utilizing MaxRequestsPerChild somehow, I could trick the parent process 
into terminating this one after the request completes? or is there some 
mod_perl feature which tells mod_perl to not re-use the perl runtime in 
a given process?


Any help and/or ideas are much appreciated. Thanks in advance.



$r->child_terminate()

mp2:
http://perl.apache.org/docs/2.0/api/Apache2/RequestUtil.html#C_child_terminate_

mp1:
http://perl.apache.org/docs/1.0/guide/snippets.html#Terminating_a_Child_Process_on_Request_Completion

Adam


Re: [mp2] where did Apache2::Cookie go in freebsd?

2008-12-09 Thread Adam Prime

Foo JH wrote:

Hi all,

I'm testing the latest mp2 stack on FreeBSD 7. While everything installs
ok, I'm having difficulties locating the Apache2::Cookie module.

I understand Apache2::Cookie is part of the libapreq2 package. I
installed that via ports, and the installation did not report errors.
The module mod_apreq2.so loaded quite happily. But when I tried to 'use
Apache2::Cookie' Apache22 throws out the error in http-error.log:

Can't locate Apache2/Cookie.pm in @INC (@INC contains:
/usr/local/lib/perl5/5.8.8/BSDPAN
/usr/local/lib/perl5/site_perl/5.8.8/mach
/usr/local/lib/perl5/site_perl/5.8.8 /usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.8/mach /usr/local/lib/perl5/5.8.8 . /usr/local)

I did a 'find / -name *ookie* -print' but I can't find Cookie.pm.

Other details:
1. FreeBSD 7.0
2. Apache 2.2.6_2
3. mod_perl 2.0.3
4. libapreq 2.08

Please enlighten...Thanks.


This is a linux box, but libapreq2 should just be libapreq2 regardless 
of platform right?


$ find /usr/lib -name *ookie.pm
/usr/lib/perl5/site_perl/5.8.8/i686-linux/APR/Request/Cookie.pm
/usr/lib/perl5/site_perl/5.8.8/i686-linux/Apache2/Cookie.pm

Perhaps your install from ports didn't install the perl bindings for 
libapreq2 at all?  Are any of the APR/Apache2 modules that should have 
been installed actually there?


Adam


solaris, perl 5.8.8, apache 1.3.41, mod_perl 1.30, t/internal/auth.t failure

2008-12-09 Thread Adam Prime
Some co-workers were trying to build mod_perl with the setup mentioned 
in the subject line, and the 2nd test in t/internal/auth.t was failing.


This test is really short (and weird IMO) but all it does it issue to 
requests to the server to test basic auth.  the first one should pass 
dougm and mod_perl as the login credentials and get a 200, and the 
second request should pass bad and one, and get a 403.


In this environment the second test was also sending dougm/mod_perl and 
thus the test failed.  This seems like a perl bug to me more than 
anything else, but if someone can confirm that for me (and point me at 
how to report it) it'd be appreciated.


Here's the original test:

---
use Apache::testold;

my $ua = Apache::UserAgent->new;
my $url = URI::URL->new("http://$net::httpserver/auth/.htaccess";);
my $i;
my $request = HTTP::Request->new(GET => $url);

unless($net::callback_hooks{PERL_AUTHEN}) {
print "1..1\nok 1\n";
exit(0);
}

print "1..2\n";

my $response = $ua->request($request, undef, undef);

test ++$i, $response->is_success;
#print $response->as_string;
$ua->creds(qw(bad one));

$response = $ua->request($request, undef, undef);

test ++$i, $response->is_error;

BEGIN {
package Apache::UserAgent;
@ISA = qw(LWP::UserAgent);
@creds = qw(dougm mod_perl);

sub get_basic_credentials { shift->creds }

sub creds {
shift;
@creds = @_ if @_;
@creds;
}

}
---

and here's what I changed the test to, which gets it to pass:

---
use Apache::testold;

my $ua = Apache::UserAgent->new;
my $ua2 = Apache::UserAgent2->new;
my $url = URI::URL->new("http://$net::httpserver/auth/.htaccess";);
my $i;
my $request = HTTP::Request->new(GET => $url);

unless($net::callback_hooks{PERL_AUTHEN}) {
print "1..1\nok 1\n";
exit(0);
}

print "1..2\n";

my $response = $ua->request($request, undef, undef);

test ++$i, $response->is_success;
#print $response->as_string;

$response = $ua2->request($request, undef, undef);

test ++$i, $response->is_error;

BEGIN {
package Apache::UserAgent;
@ISA = qw(LWP::UserAgent);
@creds = qw(dougm mod_perl);

sub get_basic_credentials { shift->creds }

sub creds {
shift;
@creds = @_ if @_;
@creds;
}

package Apache::UserAgent2;
@ISA = qw(LWP::UserAgent);
@creds = qw(bad one);

sub get_basic_credentials { shift->creds }

sub creds {
shift;
@creds = @_ if @_;
@creds;
}

}
---

Here's the contents of perl -V, if that's any help.

perl -V
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
osname=solaris, osvers=2.10, archname=i86pc-solaris
uname='sunos fxbuild-i386 5.10 generic_127112-11 i86pc i386 i86pc 
solaris '

config_args='-Dcc=gcc -Dprefix=/oanda/system'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef 
usemultiplicity=undef

useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
  Compiler:
cc='gcc', ccflags ='-fno-strict-aliasing -pipe 
-Wdeclaration-after-statement -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 
-DPERL_USE_SAFE_PUTENV',

optimize='-O',
cppflags='-fno-strict-aliasing -pipe -Wdeclaration-after-statement'
ccversion='', gccversion='4.2.1', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=8

alignbytes=4, prototype=define
  Linker and Libraries:
ld='gcc', ldflags =' '
libpth=/usr/lib /usr/ccs/lib /oanda/system/lib
libs=-lsocket -lnsl -ldl -lm -lc
perllibs=-lsocket -lnsl -ldl -lm -lc
libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version=''
  Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-fPIC', lddlflags='-G'


Characteristics of this binary (from libperl):
  Compile-time options: PERL_MALLOC_WRAP PERL_USE_SAFE_PUTENV
USE_LARGE_FILES USE_PERLIO
  Built under solaris
  Compiled at Oct 21 2008 11:41:57
  @INC:
/oanda/system/lib/site_perl/i86pc-solaris
/oanda/system/lib/site_perl
/oanda/system/lib/site_perl/i86pc-solaris
/oanda/system/lib/site_perl
/oanda/system/lib/site_perl
/oanda/lib/site_perl/i86pc-solaris
/oanda/lib/site_perl
/oanda/lib/site_perl
.


Adam


Re: [mp2] where did Apache2::Cookie go in freebsd?

2008-12-11 Thread Adam Prime
Foo JH wrote:
>> Path:/usr/ports/www/libapreq2
>> Path:/usr/ports/www/p5-libapreq
>> Path:/usr/ports/www/p5-libapreq-static
>> Path:/usr/ports/www/p5-libapreq2
>> You'd want either p5-libapreq2 or p5-libapreq WITH_MODPERL2=yes
> 
> Thanks. Does the fact that libapreq can be installed w/o modperl mean
> that other languages (eg. PHP) can use it as well?
> 
> Sorry if this sounds off-topic.

libapreq provides C bindings as well as perl.  AFAIK that's it.


Re: which reverse proxy for modperl?

2008-12-13 Thread Adam Prime

William A. Rowe, Jr. wrote:

Jeff Pang wrote:

Hello,

I have a modperl application on a host which is running with heavy load.
I have the plan to put a reverse proxy before it.
There are two well known reverse proxy software, one is Squid, another
is nginx.
Which one is better for modperl application? or is there any others
which are better than these two?


And there is httpd which you are already running, and you can run a very
low cost, separate instance with very minimal modules loaded.  With the
mod_proxy_balancer, you can shuffle off some of the traffic to a second,
third machine for good measure.

Is either better?  Google both for problems to determine how many people
are irritated with either.


I believe that there are a number of people that use lighttpd on the 
frontend too, so you can add it to the list.  All of them have their 
pluses and minuses, and all of them will help relieve the load on your 
server.


Adam


Re: Keep-Alive, Apache processes and $r->connection

2008-12-21 Thread Adam Prime

André Warnier wrote:

Hi.

Am I right, or horribly wrong, to assume that in case of a "keep-alive" 
client connection, the multiple requests sent over that connection will 
be processed by the same Apache "process" (child or thread) ?


I am assuming the above, from the fact that there exists a
$request->connection->notes table.  It seems that it would make little 
sense for such a structure to exist otherwise.


That is correct,  You can also write other protocol handlers to run 
under apache that are long running conversations like SMTP (ie: 
Apache::Qsmtpd), or do the same using the C module api (ie: mod_smtpd), 
so it's not necessarily just about keep-alive in HTTP.


Adam


Re: Bug#509457: [BUG] mod_perl2 test failures (when building Debian package)

2008-12-23 Thread Adam Prime

Philip M. Gollucci wrote:

Niko Tyni wrote:

On Mon, Dec 22, 2008 at 10:47:18AM -0600, Gunnar Wolf wrote:
The attached patch works around the problem by providing a credentials()
wrapper too. It's probably not quite correct, but the tests pass with
this on both libwww-perl 5.813 and 5.822.


Committed revision 728811.
http://svn.apache.org/viewvc?rev=728811&view=rev

Thanks!



mod_perl 1 is affected by this as well.  This is actually the same bug i 
ran reported in this thread:


http://marc.info/?l=apache-modperl&m=122886595126742&w=2

Attached is a patch against the 1.x svn branch which resolves the 
problem there as well using the same technique the Niko used for 
TestRequest.pm


Adam

Index: t/internal/auth.t
===
--- t/internal/auth.t	(revision 729005)
+++ t/internal/auth.t	(working copy)
@@ -28,6 +28,7 @@
 @creds = qw(dougm mod_perl);  
 
 sub get_basic_credentials { shift->creds }
+sub credentials { shift->creds }
 
 sub creds {
 shift;


Re: preserving request body across redirects

2008-12-29 Thread Adam Prime

Mark Hedges wrote:


The question is, since the handler doing the preservation
and installing the input filter also instantiates an
Apache2::Request object, when it gets to the response phase
controller, will the response handler's Apache2::Request
instance read the replaced data or the cached data?



From what I understand, as soon as you try to use the body of a request 
using Apache2::Request, it reads it all in.  Which might play havoc with 
the idea of using a Filter to modify a request / inject a body to replay 
an old post request.


However, without that complication it may be possible.  Have you looked 
at the filter documentation on perl.apache.org? Particularly the 
examples in this section:


http://perl.apache.org/docs/2.0/user/handlers/filters.html#Input_Filters

My suggestion would be to try it and see what happens.  Filters are one 
aspect of mp2 that it seems like a lot of people haven't really used.  I 
personally have used OuputFilters for a bunch of things, but i haven't 
used InputFilters at all.  I'm also not familiar enough with how OpenID 
works to really be able to comment on what you're trying to do.


Adam


Re: Quotes in uploaded filenames are not parsed correctly.

2009-01-02 Thread Adam Prime

Miles Crawford wrote:

When you handle a multipart/form-data post with libapreq quotes in
filenames are mishandled.  For example, a post that includes:

Content-Disposition: form-data; name="foo"; filename="break"here.jpg"


Isn't that a malformed header?  I would think that the internal '"' 
should be escaped for it to be properly represent that filename. 
Assuming that's the case, the rest of the behavior that you describe is 
what I'd expect.


Adam


Re: Quotes in uploaded filenames are not parsed correctly.

2009-01-05 Thread Adam Prime

Miles Crawford wrote:

I agree it looks bogus, but safari and firefox send the header in that
format.  Not sure about IE since Windows does not allow files with a "
in the name.

I looked over the Content-Disposition header RFC but it does not seem
to address escaping directly.

Either way, it seems that this format is a "browser fact of life"


I suggested this in IRC, but never saw a reply.  Perhaps it's because 
you're using $r->param for a input type=file?  I'd check to see what 
$upload->filename gives you when you use Apache2::Upload to handle the 
file upload instead.


Adam


Re: Quotes in uploaded filenames are not parsed correctly.

2009-01-05 Thread Adam Prime

Miles Crawford wrote:

That's actually what my production code does (where I originally found
this error) and I was trying to simplify the testcase down for the bug
report. ;)


Theoretically I guess you should report the bug to 
apreq-...@httpd.apache.org.  It does seem wrong, but to me it mostly 
seems like it's the browsers that are behaving badly.


Adam


Re: APR, libapreq2, mod_perl2, APR::*, Apache2::*

2009-01-08 Thread Adam Prime

Michael Ludwig wrote:


It is said in the thread referred to above that "the splitting of the
APIs [...] is strange and confusing", and coming from mod_perl 1.0, I
agree. But it probably has advantages as well.


i think that comment about splitting the api was with respect to 
RequestRec, RequestUtil, RequestIO, not really to do with 
Apache2::Request.  Apache::Request for mp1 is a part of libapreq, just 
as Apache2::Request is part of libapreq2.  Maybe you realized that and 
i'm just misunderstanding though.


Personally, i think libapreq should be part of core httpd (or at least a 
'normal' module, and libapreq2's perl bindings should be part of stock 
mod_perl.


Adam


Re: APR, libapreq2, mod_perl2, APR::*, Apache2::*

2009-01-08 Thread Adam Prime

Philip M. Gollucci wrote:
Oh, but we started work for this in 2.4 of httpd for libapreq.so and 
mod_apreq.so for http core.


cool


after httpd 2.6/3.0 we might be able to swing the perl bindings peices.


So where does that leave the perl binding between 2.4 and 3.0?  Or will 
we all be running mod_parrot/mod_perl6 by then (which looks like it's 
made great progress since YAPC)


Adam


Re: APR, libapreq2, mod_perl2, APR::*, Apache2::*

2009-01-08 Thread Adam Prime

Mark Hedges wrote:

So where does that leave the perl binding between 2.4 and
3.0?  Or will we all be running mod_parrot/mod_perl6 by
then (which looks like it's made great progress since
YAPC)


Great, all code where '.' was the concatenator operator
breaks, hurray. (?)


You don't have to switch if you don't want to, it's not like mod_perl 
(or perl 5) is going to disappear from production anytime soon.  I'm 
just glad that someone (Jeff Horwitz) is actually already working on it, 
because to me, perl6 without a mod_perl6 is close to useless.


I'm also hopeful that the eventual migration might be as simple as the 
oft dreaded migration from mp1, mp2 (ie not all that hard).  Only time 
will tell.


Adam


Re: apache DBI Global $r object is not available

2009-01-12 Thread Adam Prime

Philip M. Gollucci wrote:

Tech list wrote:

I've used the SVN version, but still have this issue with Apache 2.2
on FreeBSD 7.1.  Is there a fix?

Surely there is, can you provide some more context.



Is this issue actually fixed in SVN?

http://rt.cpan.org/Public/Bug/Display.html?id=36346

My suggestion is to run 1.06 until such time as it is.


Re: PerlAddVar: documentation bug (regression?)

2009-01-13 Thread Adam Prime
Michael Ludwig wrote:
> http://perl.apache.org/docs/2.0/user/config/config.html#C_PerlAddVar_
> 
> |PerlAddVar foo bar
> |PerlAddVar foo bar1
> |PerlAddVar foo bar2
> |
> | You would retrieve these values with:
> |
> |   my @foos = $r->dir_config('foo');
> 
> This is wrong. You have to say:
> 
> my @foos = $r->dir_config->get('foo');
> 
> This may have been fixed a while ago, but apparently, the mistake in the
> documentation has reappeared.
> 
> http://www.gossamer-threads.com/lists/modperl/modperl/82834#82834
> 
> Michael Ludwig

Committed revision 734312, which updates the two examples on that page
that require use of the underlying APR::Table get method.

Adam


Re: PerlAddVar: documentation bug (regression?)

2009-01-14 Thread Adam Prime

Michael Ludwig wrote:

Adam Prime schrieb:

Michael Ludwig wrote:

http://perl.apache.org/docs/2.0/user/config/config.html#C_PerlAddVar_



|   my @foos = $r->dir_config('foo');

This is wrong. You have to say:

my @foos = $r->dir_config->get('foo');



Committed revision 734312, which updates the two examples on that page
that require use of the underlying APR::Table get method.


Thank you!

(The printed version of the User's Guide also has the mistake, but it is
probably generated from the same source documents, so it should be fine.)


The PDF's are regenerated once a day.  They should update at some point 
over the next 12 hours I think.


Adam


Re: [mp2] a way to map a uri to a physical path

2009-01-14 Thread Adam Prime
Foo JH wrote:
> Hi all,
> 
> I'm trying to find the class/ method which allows me to get the physical
> path base on the uri. Something similar to Server.MapPath('/index.htm')
> in ASP.NET.
> 
> Any advise is appreciated. Thanks.

$r->document_root . $r->uri

but that won't actually tell you if that file exists, it's just where
you'd probably expect that file to reside.  Not having any idea how that
ASP.NET function works, i don't know if that really answers your
question or not.

Adam


  1   2   3   4   >