mod_perl and mod_python

2022-08-19 Thread pengyh

I know perl and python a bit well, most time use both of them for work.
besides mod_perl, there is also mod_python.
do you know what's the difference between them?
I never heard people using mod_python to make some jobs.

Thanks


Re: Experience running mod_perl2 with mpm_event on Solaris 11

2022-08-19 Thread pengyh

does perl5 support threading?

j...@sunstarsys.com wrote:

I discuss different Dynamic Programming Language thread support 
athttps://sunstarsys.com/CMS/technology.  The people in the Perl community at 
large who knock Perl5's ithreads support are doing nobody any favors.


shuffle a array

2022-08-16 Thread pengyh

in my modperl app I want to shuffle an array. such as this method in ruby,

irb(main):005:0> array
=> [1, 2, 3, 4]
irb(main):006:0> array.shuffle
=> [1, 4, 3, 2]


do you know how to achieve it in perl?

Thanks.


Re: is mpm_event safe for modperl handler? [EXT]

2022-08-10 Thread pengyh

thanks for letting me know this.


James Smith wrote:

mpm_event like all Apache mpm_s is much better at handling "issues" where nginx 
just goes F* and returns nothing. When we have issues we can detect them on apache mpms - 
but we often fail to see nginx errors as it sort of just dies!


Re: is mpm_event safe for modperl handler? [EXT]

2022-08-09 Thread pengyh
I think running Ignix as front-end server and mod_perl for backend 
server is the more popular choice.





If you want the speed of mod_event for static content and the power of mod_perl 
for dynamic content - the best way is to run a lightweight mod_event apache in 
front of a mod_prefork to run the mod_perl


Re: is mpm_event safe for modperl handler?

2022-08-04 Thread pengyh



thanks. that does sound sorry.


No and neither is mod_worker. The only mpm you can safely use is 
prefork. This is, in my opinion, mod_perl's fatal flaw which will doom it.


Re: PerlAccessHandler for POST access

2022-08-04 Thread pengyh






LoadModule apreq_module modules/mod_apreq2.so

in your httpd.conf?


yes. as you see:
lrwxrwxrwx 1 root root 27 Aug  4 14:00 perl.load -> 
../mods-available/perl.load
lrwxrwxrwx 1 root root 29 Aug  4 14:01 apreq2.load -> 
../mods-available/apreq2.load





Have you tried it with mpm_prefork?


the development environment is mpm_prefork.



What version of Apache and mod_perl are you using exactly?


Apache/2.4.41 (Ubuntu) mod_apreq2-20101207/2.8.0 mod_perl/2.0.11 
Perl/v5.30.0 configured



ubuntu 20.04 x64 OS.

Thanks


Re: PerlAccessHandler for POST access

2022-08-04 Thread pengyh

multiple -d "x=y" should be working.




   -d "param1=value1¶m2=value2"


Re: PerlAccessHandler for POST access

2022-08-04 Thread pengyh






You need to share the complete GET & POST request with the data section.


OK as you can test this GET works:

http://fb.cloudcache.net/?timestamp=12345&authkey=906434463477769dba188a4b670ef425

but this POST doesn't work:

curl -X POST -d 'timestamp=12345' \
 -d 'authkey=906434463477769dba188a4b670ef425' \
 http://fb.cloudcache.net/


The server responds with:

Forbidden
You don't have permission to access this resource.


So how to fix it?

Thanks


is mpm_event safe for modperl handler?

2022-08-03 Thread pengyh

Hello

yes i know mpm_prefork is pretty good for modperl applications.
if I run modperl handler (for example, PerlAccessHandler) under 
mpm_event, is it safe for a production environment?


thanks.


Re: PerlAccessHandler for POST access

2022-08-03 Thread pengyh






Have you checked that the values of $key and $digest are equal?


as i have said, GET always works, but POST doesn't. so I am not sure 
where is wrong.




Re: PerlAccessHandler for POST access

2022-08-03 Thread pengyh






return $key eq $digest ? Apache2::Const::OK : Apache2::Const::FORBIDDEN;


there are no further customized code for Apache2::Const::OK.

the httpd.conf just as:


ServerAdmin webmaster@localhost
ServerName my.site.net
DocumentRoot /var/www/feedback

PerlPostConfigRequire /etc/apache2/modperl/startup.pl


SetHandler modperl
PerlAccessHandler MLFB



ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/mlfb.access.log combined




Re: PerlAccessHandler for POST access

2022-08-03 Thread pengyh



POST always gets a 403 error. but GET does get the correct response.

Thanks


What do you mean by “doesn’t work”.  Do you mean your code isn’t executed at 
all, or that it isn’t executing correctly?  It would be helpful to see the 
associated Apache config, as well.


PerlAccessHandler for POST access

2022-08-03 Thread pengyh
do you know for my this simple PerlAccessHandler, why HTTP GET works, 
but POST doesn't?


use strict;
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::Connection ();
use APR::Table ();
use Apache2::Const -compile => qw(OK FORBIDDEN);
use Apache2::Request;
use Digest::MD5 qw(md5_hex);


sub handler {

my $r = shift;
my $req = Apache2::Request->new($r);
my $ts = $req->param("timestamp");
my $key = $req->param("authkey");
my $digest = md5_hex($ts);

return $key eq $digest ? Apache2::Const::OK : 
Apache2::Const::FORBIDDEN;

}


1;


Thanks.