Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Apache2 Frustrations

by !1 (Hermit)
on Nov 21, 2003 at 20:31 UTC ( #309042=note: print w/replies, xml ) Need Help??

in reply to Apache2 Frustrations

There are a few things about mod_perl 2 that you should know. First and foremost: Apache::Request doesn't work with mod_perl 1.99 yet. You can directly use $r if you so wish. $r->hostname, $r->get_server_port, $r->uri, and $r->args can be very helpful if you wish to get the current URI. However, you'll need to add quite a bit of code to get the same functionality as either Apache::Request or CGI. You can use CGI as long as you use Apache::compat.

In all, I wouldn't suggest migrating to mod_perl 1.99 yet. The documentation is sparse and there are still a few bugs. Still checking out mod_perl 1.99_11 to see if some of my concerns are still there. I hope this helps you with your problem.

Replies are listed 'Best First'.
Re: Re: Apache2 Frustrations
by dragonchild (Archbishop) on Nov 21, 2003 at 20:45 UTC
    This is a completely new web app, so would you recommend using modperl 1.x right now, then migrating to MP2 when it comes out?

    We are the carpenters and bricklayers of the Information Age.

    The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

    ... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

      modperl 1.x will be around for a long time. It makes a lot of sense to use that now and migrate to version 2 when the latter has stabilised :)

      Yes, I am telling you to wait for the time being and instead go with mod_perl 1.x. If you take a gander at the API documentation and run through some of the modules, you might notice that some of them are less than complete. I'm not saying that I dislike MP2 at this point. I'm saying that in order to get a feel for the entire API you either have to read an assload of source code or pay 99 cents a minute talking to the Psychic Friends Network getting yes/no/vaguely detailed answers to API questions (pricey, but definitely very entertaining...I never knew that APR::Table had a spirit that wishes for me to release it. No lies. Ask antirice). I'm certainly excited about MP2. I like the control that Apache 2.0 seems to offer. Unfortunately, it just isn't there yet. I have a couple of document servers running on our intranet with Apache 2 using a mod_perl handler to check for authentication and whatnot in an attempt to get a feel for the new way of doing everything (ok, not everything but things like args parsing in list context(ok, multi value didn't work) doesn't work the same and send_cgi_header is gone). I've already started to develop libraries (mostly by stealing chunks from that work outside of Apache::compat however it's mostly a side project. It'll have to wait until antirice and I finish with our HTML::Template extension modules.

Re: Re: Apache2 Frustrations
by cees (Curate) on Nov 22, 2003 at 00:55 UTC
    You can use CGI as long as you use Apache::compat.

    Are you sure about this? According to the porting docs you can use with mod_perl2 as long as you use version 2.93 or greater. is capable of taking the apache request object so it can deal with any mod_perl specific issues (like cleaning up globals) that need to be done. The more people that try it, the quicker it will be release quality.

    my $r = Apache->request; my $query = CGI->new($r);

    Note that to get access to the Apache->request object you may need to activate 'PerlOptions +GlobalRequest' in your apache config.

    Also, the Apache::Request module for mod_perl2 is coming along nicely. Although it is not quite ready for production, I don't think it will be much longer.

    - Cees

      The only issue of which I am aware that had me use Apache::compat deals with's header subroutine. Since it uses $r->send_cgi_header. According to the docs, send_cgi_header is not available under mod_perl2. Am I incorrect in my interpretation? If so, I am quite sorry. If not then I apologize for not mentioning it earlier.

        It may have been a problem before, as in the early versions of mod_perl2 there were a lot of missing functions, but send_cgi_header is there now.

        cees@tim:~$ perl -MApache2 -MModPerl::MethodLookup -e print_method sen +d_cgi_header To use method 'send_cgi_header' add: use Apache::Response ();

        So it is definately available now. However, I just checked through the source and can't find any place where it loads Apache::Response. So there is a possibility that is won't work without that. And a quick check shows that it doesn't get brought in by any other Apache2 modules that does load...

        tim:~# MOD_PERL=1 perl -MApache2 -MCGI -e '$,=$/;print sort keys %INC; +' APR/ APR/ Apache/ Apache/ Apache/ ...

        The reasons Apache::compat fixes the problem is because it automatically loads Apache::Response which makes cgi_send_header available again.

        So short of writing a bit of code that uses's header function under mod_perl2 and actually testing it, I guess you might be right... It might be best to ask this on the mod_perl list.

        Update: I wrote a quick script using the sample script at the top of the docs and ran it under mod_perl 1.99_11 successfully. So I guess we can let this worry to rest :)


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://309042]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2021-09-17 05:14 GMT
Find Nodes?
    Voting Booth?

    No recent polls found