creating an instance of Apache2::RequestRec
hello folks, has anyone tried to create an instance of Apache2::RequestRec outside apache ? I'm not an xs expert, but if i understand correctly Apache2::RequestRec basically wraps the request_rec from apache2, therefore creating one should be initializing a struct with some params calling sv_setref_pv to get a blessed reference ? cheers, bharanee
Re: creating an instance of Apache2::RequestRec
It would work for the purpose of testing, mainly simulating a request without running apache like Apache::Test does currently. But as you say, it would mean replicating the C functions. Just wondering if someone has attempted this ? On 8/31/07, Perrin Harkins <[EMAIL PROTECTED]> wrote: > > On 8/30/07, bharanee rathna <[EMAIL PROTECTED]> wrote: > > has anyone tried to create an instance of Apache2::RequestRec outside > > apache ? > > How could that work? And even if it could work, what good what it be? > This class is a Perl version of the C API to Apache's internals. It > has no other purpose. > > - Perrin >
Re: creating an instance of Apache2::RequestRec
Just following up, this is already mentioned in perldoc Apache2::RequestUtil "It's possible to reuse the HTTP framework features outside the familiar HTTP request cycle. It's possible to write your own full or partial HTTP implementation without needing a running Apache server. You will need the "Apache2::RequestRec" object in order to be able to reuse the rich functionality supplied via this object." I'm not sure if the CommandServer example is relevant since it only works from inside apache2 On 8/31/07, Perrin Harkins <[EMAIL PROTECTED]> wrote: > > On 8/30/07, bharanee rathna <[EMAIL PROTECTED]> wrote: > > has anyone tried to create an instance of Apache2::RequestRec outside > > apache ? > > How could that work? And even if it could work, what good what it be? > This class is a Perl version of the C API to Apache's internals. It > has no other purpose. > > - Perrin >
Re: creating an instance of Apache2::RequestRec
Yep, something like FakeRequest is the easy solution, I guess one could write something similar for apache2. Still, it's intriguing that a standalone HTTP implementation is mentioned in RequestUtil's pod but I cannot find a real implementation example anywhere. -bharanee On 8/31/07, Perrin Harkins <[EMAIL PROTECTED]> wrote: > > On 8/30/07, bharanee rathna <[EMAIL PROTECTED]> wrote: > > It would work for the purpose of testing, mainly simulating a request > > without running apache like Apache::Test does currently. > > Apache::Test does it this way because it's a better way to test. It > actually tests the full code path. > > There are things like Apache::FakeRequest, but I don't think anyone > has tried to do it for the Apache 2 API yet. > > - Perrin >
Re: -X and trapping kill?
Hi guys, this is a known issue reported at http://issues.apache.org/bugzilla/show_bug.cgi?id=38848 and not modperl related. On 9/18/07, Fred Moyer <[EMAIL PROTECTED]> wrote: > > Bill Moseley wrote: > > Must be Monday. Is there a problem with the -X switch and prefork? > > > > I'm using: > > > > Apache/2.2.3 (Debian) mod_ssl/2.2.3 OpenSSL/0.9.8e mod_perl/2.0.2 > Perl/v5.8.8 > > > > > > I have a very small config and when I run with -X it starts a single > > process but I can't control-C to kill it. I can't even kill from > > another xterm, I have to kill -9 it. > > > > Tried also on Ubuntu, but it's the same versions as above. > > Just to rule out that it's not the terminal causing the problem, what > happens if you run a program like this and ctrl+c? I'm not seeing the > behavior you are describing with 2.2.4/2.0.3/5.8.8 on darwin. > > #!perl > > use strict; > use warnings; > > $SIG{INT} = sub { warn('hello interrupt') }; > > while (1) { > next; > } >
Re: -X and trapping kill?
yes, but AFAIK -X is a shortcut for -DONE_PROCESS. But then I may be wrong but a quick check now shows me that using -DONE_PROCESS, apache2 ignores SIGINT On 9/18/07, Philippe M. Chiasson <[EMAIL PROTECTED]> wrote: > > Bill Moseley wrote: > > Must be Monday. Is there a problem with the -X switch and prefork? > > > > I'm using: > > > > Apache/2.2.3 (Debian) mod_ssl/2.2.3 OpenSSL/0.9.8e mod_perl/2.0.2 > Perl/v5.8.8 > > for Apache/2.x, Shouldn't that now be: > > $> httpd -DONE_PROCESS -DNO_DETACH > > > Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5 > http://gozer.ectoplasm.org/ m/gozer\@(apache|cpan|ectoplasm)\.org/ > > >
Re: Perl section and request object
me thinks that PerlOptions +GlobalRequest should be inside your or section. http://perl.apache.org/docs/2.0/user/config/config.html#mod_perl_Directives_Argument_Types_and_Allowed_Location On 9/19/07, antoine7 <[EMAIL PROTECTED]> wrote: > > > Hello, > > I'm new to mod perl, I've setup an apache2 / MP2 on an linux debian etch > server. > I want to access in my apache conf to the HTML Request Header Host: > > I've written this code : > > NameVirtualHost 192.168.1.203 > UseCanonicalName Off > > PerlOptions +GlobalRequest > > > use Apache2::RequestUtil (); > my $r = Apache2::RequestUtil->request; > [...] > > > But when I restart the server I get the following error message > etch:~# /etc/init.d/apache2 restart > Forcing reload of web server (apache2)...Syntax error on line 7 of > /etc/apache2/sites-enabled/999-vhost: > \t(in cleanup) Global $r object is not available. Set:\n\tPerlOptions > +GlobalRequest\nin httpd.conf at /etc/apache2/sites-enabled/999-vhost line > 9.\n > failed! > > But I've already add PerlOptions +GlobalRequest ... > > Has anyone got an idea ? > > Thanks > -- > View this message in context: > http://www.nabble.com/Perl-section-and-request-object-tf4479522.html#a12773009 > Sent from the mod_perl - General mailing list archive at Nabble.com. > >
Re: Problem with RequestRec and Headers
AFAIK Apache::Singleton works for MP2, also it does both per request and per process singletons. On 9/24/07, jk jk <[EMAIL PROTECTED]> wrote: > > I've been trying to use Apache::Singleton::Request under the assumption > that you're right about Class::Singleton being the crux of the issue. > Unfortunately, I can't get it working under Apache2. Is there a different > module for mp2/apache2 ? Thanks for your patience. --JAK > > On 9/23/07, jk jk <[EMAIL PROTECTED]> wrote: > > > > Why is that? Class::Singleton is modperl compatible, Apache::Singleton > > is the same thing with a few more features. Its purpose to simplify > > singleton application creation. My understanding was it would only allow a > > single instance of the object to be created for each request, not forever. > > Please explain your reasoning. Thanks. --JAK > > > > On 9/23/07, Philippe M. Chiasson < [EMAIL PROTECTED]> wrote: > > > > > > jk jk wrote: > > > > I'm trying to port a preexisting CGI app to mod_perl2 and could use > > > some > > > > help. > > > > > > > > Here goes a test case that should illustrate my problem: > > > > > > > > The code pasted below loads the page properly the first time it's > > > > accessed. However, upon multiple reloads in firefox, the headers > > > either > > > > disappear altogether or the page is downloaded in the download > > > manager. > > > > I assume this is because the wrong $r object is being accessed by > > > the > > > > request? In any case, I'm at a loss and would really appreciate > > > some > > > > input. Thanks in advance. > > > > [...] > > > > > > > > = > > > > File: testme/testmod.pm > > > > = > > > > > > > > package testme::testmod; > > > > > > > > use Apache2::RequestUtil; > > > > use strict; > > > > > > > > use base qw /Class::Singleton/; > > > > > > ^^ > > > > > > From the documentation of Class::Singleton: > > > > > > # this only gets called the first time instance() is called > > > > > > > sub _new_instance{ > > > > > > > > my ( $class, $r ) = @_; > > > > > > > > my $self = {}; > > > > > > > > bless $self, $class; > > > > > > > > $self->{r} = $r; > > > > > > > > return ( $self ); > > > > > > > > } > > > > > > So effectively, your code will capture the $r (once for each child) > > > from the first request and keep it forever. Trying to use it for > > > subsequent > > > requests will cause the kind of problems you've seen. > > > > > > > > > > > > Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 > > > 88C3A5A5 > > > http://gozer.ectoplasm.org/ > > > m/gozer\@(apache|cpan|ectoplasm)\.org/ > > > > > > > > > > > >
Re: Problem with RequestRec and Headers
Yep, that's a bug perldoc Apache2::RequestUtil # get the global request object (requires PerlOptions +GlobalRequest) $r = Apache2::RequestUtil->request; which means u need GlobalRequest in apache config, which I'm not a big fan of. Better raise a bug in cpan rt for this module and get Tatsuhiko to fix it. By the looks of it, this hasn't been updated in a while. personally I don't really see a need for Apache::Singleton::Process unless there needs to be a module for consistency in Apache:: namespace, class::singleton does pretty much the same job. If you need a per-request singleton meanwhile, cookup something quickly of your own that uses apache pnotes to store the instance perldoc Apache2::RequestRec On 9/24/07, jk jk <[EMAIL PROTECTED]> wrote: > > I looked at the source. It does seem to be written for both. My > understanding was that everything for apache2 was supposed to be in the > Apach2:: namespace. In any case I posted the install error below. Does an > environment variable need to be set? > > > perl Makefile.PL > Warning: prerequisite mod_perl 0 not found. > Writing Makefile for Apache::Singleton > > If I install it anyway I get "[Sun Sep 23 15:09:49 2007] [error] Can't > locate Apache/RequestUtil.pm in @INC (@INC contains:.." > > Thanks. --JAK > > On 9/23/07, bharanee rathna <[EMAIL PROTECTED]> wrote: > > > > AFAIK Apache::Singleton works for MP2, also it does both per request and > > per process singletons. > > > > > > On 9/24/07, jk jk < [EMAIL PROTECTED]> wrote: > > > > > > I've been trying to use Apache::Singleton::Request under the > > > assumption that you're right about Class::Singleton being the crux of the > > > issue. Unfortunately, I can't get it working under Apache2. Is there a > > > different module for mp2/apache2 ? Thanks for your patience. --JAK > > > > > > On 9/23/07, jk jk <[EMAIL PROTECTED] > wrote: > > > > > > > > Why is that? Class::Singleton is modperl compatible, > > > > Apache::Singleton is the same thing with a few more features. Its > > > > purpose > > > > to simplify singleton application creation. My understanding was it > > > > would > > > > only allow a single instance of the object to be created for each > > > > request, > > > > not forever. Please explain your reasoning. Thanks. --JAK > > > > > > > > On 9/23/07, Philippe M. Chiasson < [EMAIL PROTECTED]> wrote: > > > > > > > > > > jk jk wrote: > > > > > > I'm trying to port a preexisting CGI app to mod_perl2 and could > > > > > use some > > > > > > help. > > > > > > > > > > > > Here goes a test case that should illustrate my problem: > > > > > > > > > > > > The code pasted below loads the page properly the first time > > > > > it's > > > > > > accessed. However, upon multiple reloads in firefox, the > > > > > headers either > > > > > > disappear altogether or the page is downloaded in the download > > > > > manager. > > > > > > I assume this is because the wrong $r object is being accessed > > > > > by the > > > > > > request? In any case, I'm at a loss and would really appreciate > > > > > some > > > > > > input. Thanks in advance. > > > > > > [...] > > > > > > > > > > > > = > > > > > > File: testme/testmod.pm > > > > > > = > > > > > > > > > > > > package testme::testmod; > > > > > > > > > > > > use Apache2::RequestUtil; > > > > > > use strict; > > > > > > > > > > > > use base qw /Class::Singleton/; > > > > > > > > > > ^^ > > > > > > > > > > From the documentation of Class::Singleton: > > > > > > > > > > # this only gets called the first time instance() is called > > > > > > > > > > > sub _new_instance{ > > > > > > > > > > > > my ( $class, $r ) = @_; > > > > > > > > > > > > my $self = {}; > > > > > > > > > > > > bless $self, $class; > > > > > > > > > > > > $self->{r} = $r; > > > > > > > > > > > > return ( $self ); > > > > > > > > > > > > } > > > > > > > > > > So effectively, your code will capture the $r (once for each > > > > > child) > > > > > from the first request and keep it forever. Trying to use it for > > > > > subsequent > > > > > requests will cause the kind of problems you've seen. > > > > > > > > > > > > > > > > > > > > Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 > > > > > 88C3A5A5 > > > > > http://gozer.ectoplasm.org/ > > > > > m/gozer\@(apache|cpan|ectoplasm)\.org/ > > > > > > > > > > > > > > > > > > > > > > > > >
Re: open and write a file with 777 permissions.
you need to do a umask(0) , try going through perldoc -f umask On 9/26/07, Tyler Bird <[EMAIL PROTECTED]> wrote: > > I was wondering if anyone knows offhand > how I can open and write to a file with 777 permissons. > > And possibly also set the owner to a specified owner string. > > I am reading through IO::File, but having some issues. > > Thanks >
Re: Mod_Perl and MaxRequestsPerChild
Although mod_proxy is a nice module with many features, I would recommend something like pound doing the proxying & load balancing. It's more light and faster, plus you have the added advantage of keeping your webservers in a local network. If you want something with more features lookup squid, but I've had best results with pound using apache2 worker for static content and apache2 prefork for modperl2 apps on different servers. On 10/19/07, Jozef Kosoru <[EMAIL PROTECTED]> wrote: > > On Wed, Oct 17, 2007 at 15:03:46 -0400, Perrin Harkins wrote: > > On 10/16/07, Mark Maunder <[EMAIL PROTECTED]> wrote: > > > This server has no proxy in front of it and only serves mod_perl > > > requests. Static content is loaded from another server with a > > > different hostname. > > > > Even so, if you run prefork, you need a proxy server. The reason is > > explained in detail here: > > > http://www.modperlbook.org/html/12-5-Adding-a-Proxy-Server-in-httpd-Accelerator-Mode.html > > > > In short, running a proxy will usually lower the number of mod_perl > > processes needed significantly. > > If my understanding is correct then if you use Apache 2.2 as a proxy > server with an even MPM you can even use KeepAlive on the front-end. The > question is whether allowing KeepAlive on the backend server will allow > the proxy server to reuse this connection to serve several clients or > will just basically lock this proxy connection for the whole duration of > a single client connection. > > There are some references about "connection pooling" to the backend > server in mod_proxy documenation (ProxyPass Directive section): > > http://httpd.apache.org/docs/2.2/mod/mod_proxy.html > > But I'm not sure this is relevant to http reverse proxies. > > -- > jozef kosoru > http://zyzstar.kosoru.com >
Re: Fwd: MPM-safe mp2 Singleton Pattern?
> The simplest way is to put the object as a pnote: What Torsten said, but have a look at http://search.cpan.org/~miyagawa/Apache-Singleton-0.07/lib/Apache/Singleton.pm Apache::Singleton::Request is probably what you want.
Re: Fwd: MPM-safe mp2 Singleton Pattern?
> I couldn't get Apache::Singleton working with mp2 (used it before with no > problems with mp1). so I switched back to Class::Singelton ... *sigh*, 2 yr old bug report. Maybe someone should write to the author/maintainer and take ownership ? http://rt.cpan.org/Public/Bug/Display.html?id=19775 Easy fix though as noted in the RT ticket. Also I think you should turn on global request, PerlOptions +GlobalRequest otherwise you would not be able to get the request object via Apache2::RequestUtil->request,. Alternatively you can set the request object in your handler initially as Apache2->request($r); - b