Re: Apache::SSI forces text/html?

2000-04-14 Thread Joshua Chamas

Ken Williams wrote:
 
 [EMAIL PROTECTED] (Dan McCormick) wrote:
 Hi,
 
 I was just trying to hack a script into showing its HTML output to a
 browser by setting the content type to 'text/plain', but it looks like
 Apache::SSI, which I'm using, always sets the content type to
 'text/html' (line 23 Apache::SSI).
 
 I'll remove it if it won't break anything - will Apache set the type to
 text/html if no other information is given?
 

Can you just do $r-content_type and see if had been set
already ?  Then set it if blank ?

-- Joshua
_
Joshua Chamas   Chamas Enterprises Inc.
NodeWorks  free web link monitoring   Huntington Beach, CA  USA 
http://www.nodeworks.com1-714-625-4051



Re: PLEASE HELP!!!!! I cannot get mod_perl/apache compiled

2000-04-14 Thread Ask Bjoern Hansen

On Thu, 13 Apr 2000, Sam Carleton wrote:

 I simply cannot get mod_perl/apache to compile.  My understanding is
 that I configure .makepl_args.mod_perl to compile both mod_perl.  Then I
 do the following:
 
 perl Makefile.PL
 make
 make test
 make install
 
 Assuming there where no problems, all should be installed and ready to
 go.  But all is not well.  First some version info.  I just downloaded
 mod_perl-1.22 and apache_1.3.12 and am working with fresh trees.  I run
 the perl Makefile.PL and that seems to work well, I don't see any
 errors.  When I try to run make, I get this error:

Where do you have the .makepl_args.mod_perl file? Does it get "picked up"?

With the (.)makepl_args.mod_perl file you have you should not need the
apache configure thing you posted in the bottom of the mail.

And yes, "make" should work after running perl Makefile.PL.

In what directories did you untar the tar balls with the source for apache
and modperl?

What is the output from perl Makefile.PL?


 - ask

-- 
ask bjoern hansen - http://www.netcetera.dk/~ask/
more than 70M impressions per day, http://valueclick.com




Fwd: apache_1.3.12 / mod_perl-1.22 ... Bug in mod_perl 1.22 on certain platform ?

2000-04-14 Thread Frédéric Schwien

Hi

Following to my last email, I tried to build apache_1.3.12 with mod_perl-1.21.
And it worked well with the same makepl_args.mod_perl file .

So does that mean that there is a bug in mod_perl-1.22 ? Or That my conf file
had wrong arguments in it, even if I could build it on an other server (see my
other email)?

Fred 

-
 
here is my make makepl_args.mod_perl file : 

#example makepl_args.mod_perl files
#copy this file to $ENV{HOME}/.makepl_args.mod_perl and edit to taste
 
#mod_perl's Makefile.PL will also look for this file in ./ ../ relative
#to the mod_perl-x.xx source tree
 
#EVERYTHING=1 will enable:
#ALL_HOOKS=1 PERL_SSI=1 PERL_SECTIONS=1
#PERL_STACKED_HANDLERS=1 PERL_METHOD_HANDLERS=1 PERL_TABLE_API=1
 
EVERYTHING=1
 
#build against the first apache_x.xx source tree found, without prompts
# DO_HTTPD=1
 
DO_HTTPD=1
 
#could tell Makfile.PL exactly where the source is
# APACHE_SRC=/tmp/apache_x.xx/src
 
APACHE_SRC=../apache_1.3.12/src
 
#this would configure in mod_proxy, mod_unique_id, mod_info and mod_status
# ADD_MODULE=proxy,usertrack,unique_id,info,status
 
 ADD_MODULE=info,status
 
#if you wish to use a Configuration file other than what's in the
#apache_x.xx/src directory
# CONFIG=Configuration.custom
 
#depending on your os and site_perl modules, see mod_perl's INSTALL
# PERL_STATIC_EXTS=...
 
#apache header files are installed by default, stop that if you wish
# APACHE_HEADER_INSTALL=0
 
#Apache and Apache::Constants modules will be built as shared libraries
# DYNAMIC=1
 
DYNAMIC=1
 
USE_APACI=1
 
APACI_ARGS=--enable-module=so
 
#turn on mod_perl tracing
# PERL_TRACE=1
 
#for perl.c's perl_destruct() which in run by mod_perl during child_exit
#comment from perl.c: /* 0=none, 1=full, 2=full with checks */
#default level is 0
# PERL_DESTRUCT_LEVEL=2
 
#-add `-g' to EXTRA_CFLAGS
#-turn on PERL_TRACE
#-set PERL_DESTRUCT_LEVEL=2
#-link against libperld if -e $Config{archlibexp}/CORE/libperld$Config{lib_ext}
# PERL_DEBUG=1
 
#
#experimental features, use at own risk
#but please report success or failure if you try
 
#try to stop "Use of uninitialized value." with no line/filename info
# PERL_MARK_WHERE=1 





--
--

| Frédéric Schwien   
| Administrateur WebMails.com   
| E-mail: [EMAIL PROTECTED] Solutions Internet/Intranet sécurisées"
|http://www.igtech.fr
|Centre de Formation Agréé  
|CheckPoint Software 
| 153, avenue Jean Lolive
| 93500 Pantin   
| Tél: 33 (0) 1 56 96 01 23
| Fax: 33 (0) 1 56 96 01 33
|Votre Email gratuit et sécurisé : http://www.webmails.com 




[perhaps OT] Re: PHP is breaking Sybase::DBlib

2000-04-14 Thread Mike Miller

David,

Does PHP (of which I know nothing) use any of the dbm libraries statically?  I 
remember that I had a 
hard time using DBlib a while back because there is a sybase dblib function called db 
and one in the dbm 
libraries called db, and they were conflicting.  I had to recompile perl not to 
statically use any dbm 
libraries.  There is an entry in the DBlib FAQ about this, IIRC (its on the DBLib web 
page).  

Perhaps this is the same thing or a similar issue?  Just a thought to help you out, 
YMMV.

Brgds,

Mike.

On Thu, 13 Apr 2000 23:32:49 -0600 (MDT), David Hojo Hajoglou wrote:

So, I was having a hell of a time to get DBlib to work in a module.  The
code worked fine as a script, but the database handle was not created
properly when with a module.  As I prepared for Harikari, I looked at the
loggs and php glared back at me.

My compile was:
Apache/1.3.12 (Unix) mod_perl/1.22 PHP/3.0.15

Change to 
Apache/1.3.12 (Unix) mod_perl/1.2

And the code worked. So, I have discovered an incompatibility of sorts and
guess what?  I have no idea how to fix it only that I need to have php and
mod_perl together.  Why me  AAAGH.


-hoj








Httpd process growing

2000-04-14 Thread Dimas Kotvan



Hello All!

I'm runningApache 1.3.12 with mod_perl 
1.21inLinux Mandrake 7.0.
After some time running my modperl scripts in the webserver I have noticed, 
using
the system utility top, that the httpd processes had grown from 7mb to 30mb 
each.
It's my first script in modperl, and I have no idea about what could be 
wrong with it.
Someone have a tip about what could caused that?

Thanks in advance,
Dimas Kotvan



Re: PHP is breaking Sybase::DBlib

2000-04-14 Thread Michael Peppler

David Hojo Hajoglou writes:
  So, I was having a hell of a time to get DBlib to work in a module.  The
  code worked fine as a script, but the database handle was not created
  properly when with a module.  As I prepared for Harikari, I looked at the
  loggs and php glared back at me.
  
  My compile was:
  Apache/1.3.12 (Unix) mod_perl/1.22 PHP/3.0.15
  
  Change to 
  Apache/1.3.12 (Unix) mod_perl/1.2
  
  And the code worked. So, I have discovered an incompatibility of sorts and
  guess what?  I have no idea how to fix it only that I need to have php and
  mod_perl together.  Why me  AAAGH.

Do you happen to have libdb (berkeley DB) linked in to the first
mod_perl binary? libdb.a and SYbase DBlib both have a dbopen()
function, and that causes some (obvious) problems.

Michael
-- 
Michael Peppler -||-  Data Migrations Inc.
[EMAIL PROTECTED]-||-  http://www.mbay.net/~mpeppler
Int. Sybase User Group  -||-  http://www.isug.com
Sybase on Linux mailing list: [EMAIL PROTECTED]



RE: Httpd process growing

2000-04-14 Thread Geoffrey Young



check out
http://perl.apache.org/guide/performance.html
for some guidance

HTH

--Geoff

  -Original Message-From: Dimas Kotvan 
  [mailto:[EMAIL PROTECTED]]Sent: Thursday, April 13, 2000 7:09 
  PMTo: [EMAIL PROTECTED]Subject: Httpd process 
  growing
  Hello All!
  
  I'm runningApache 1.3.12 with mod_perl 
  1.21inLinux Mandrake 7.0.
  After some time running my modperl scripts in the webserver I have 
  noticed, using
  the system utility top, that the httpd processes had grown from 7mb to 
  30mb each.
  It's my first script in modperl, and I have no idea about what could be 
  wrong with it.
  Someone have a tip about what could caused that?
  
  Thanks in advance,
  Dimas Kotvan


Re: Apache::SSI forces text/html?

2000-04-14 Thread Vivek Khera

 "KW" == Ken Williams [EMAIL PROTECTED] writes:

KW I'll remove it if it won't break anything - will Apache set the type to
KW text/html if no other information is given?

Apache has a default document type parameter, and I believe the
shipped configurations say text/plain.



Apache::ASP problem running the example.

2000-04-14 Thread Andy Yiu

Hi,

I installed the Apache ASP package and the mod_perl with the Apache server.

I guess there is no error in the setup and everything should run fine.

Then I run the example.  When I try to run index.html, it returned a error
message saying that it couldn't find the global.asa or something like that.
But I checked that it's in the directory actually.

Next, I tried other *.asp files and they all work fine.

Can you please help me out with this?

Thanks.

Andy


__
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com



cgiwrap for Apache::ASP?

2000-04-14 Thread Philip Mak

Hello,

I searched the egroups.com mod_perl archive for "cgiwrap" and didn't find
anything relevant to ASP.

I'm wondering if there's any documentation about how to use cgiwrap with
the ASP extension. Currently I have a modified version of cgiwrap
installed on my system such that all .cgi/.pl files are transparently
(i.e. no need to put cgiwrap in the URL) suid'ed to the script owner
before being executed.

I also have ASP installed, and I'd like to be able to transparently suid
the .asp scripts too. Do you know how I could go about doing this?

Thanks,

-Philip Mak ([EMAIL PROTECTED])




Re: Apache::ASP problem running the example.

2000-04-14 Thread Ime Smits

| I installed the Apache ASP package and the mod_perl with the Apache
server.
| I guess there is no error in the setup and everything should run fine.
| Then I run the example.  When I try to run index.html, it returned a error
| message saying that it couldn't find the global.asa or something like
that.
| But I checked that it's in the directory actually.
| Next, I tried other *.asp files and they all work fine.
| Can you please help me out with this?

Give us some insight: relevant sections of your httpd.conf, .htaccess files
and the exact errors from your error.log...

Ime




Re: cgiwrap for Apache::ASP?

2000-04-14 Thread Ime Smits

| I also have ASP installed, and I'd like to be able to transparently suid
| the .asp scripts too. Do you know how I could go about doing this?

I think this is a general bad idea. The only purpose of running scripts via
a suexec or setuid mechanism I can think of is to stop different users 
websites running an the same httpd digging and interfering in each other's
data and files.

As Apache::ASP is built on top of mod_perl which takes advantage of
*internally sharing  caching* as much as possible between httpd processes,
doing setuid scripts would not fix the problem.

I'm not into the gory details, but I guess what you have then is the same
access to the same data as before, you just have another uid. So for disk
i/o this is ok, but to shield users from messing up each others mod_perl
namespace in case they have a bad coding style, this is useless.

If you're not trusting the people making websites and you're looking for a
virtual hosting solution, I think some postings earlier this week about
proxying requests to a user-dedicated apache listening on localhost is the
best solution.

Ime




apache 1.3.12 make failure with mod_perl 1.2.2

2000-04-14 Thread Michael Moen

Hi Folks- I tried searching the archives and the only thing I found close to
this was re-building perl dynamically, I (think) I got this done, although I
could be wrong.

I will include any output I think might be relevant. Any suggestions would
be greatly appreciated.

Thanks- Michael

mod_perl builds fine, when I try to build apache 1.3.12
with --activate-module=src/modules/perl/libperl.a the make fails. with this
error.

apache_1.3.12/make

SNIP...
=== modules/perl
cc -O2 -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE
_OFFSET_BITS=64 -I/usr/local/lib/perl5/5.6.0/i686-linux-multi/CORE  -DMOD_PE
RL_VERSION=\"1.21\" -DMOD_PERL_STRING_VERSION=\"mod_perl/1.21\" -I../..  -I/
usr/local/lib/perl5/5.6.0/i686-linux-multi/CORE  -I../../os/unix -I../../inc
lude   -DLINUX=2 -DMOD_PERL -DUSE_PERL_SSI -fno-strict-aliasing -I/usr/local
/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DUSE_HSREGEX -DUSE_EXPA
T -I../../lib/expat-lite -DNO_DL_NEEDED -DMOD_PERL -c mod_perl.c
mod_perl.c:1049: macro `hv_exists' used with only 2 args
mod_perl.c:1050: macro `hv_fetch' used with only 3 args
mod_perl.c:1056: macro `hv_store' used with only 4 args
make[3]: *** [mod_perl.o] Error 1
make[2]: *** [all] Error 1
make[1]: *** [subdirs] Error 1
make[1]: Leaving directory `/usr/src/apache_1.3.12/src'
make: *** [apache_httpd] Error 2

#

Her is the output from perl

perl -v

This is perl, v5.6.0 built for i686-linux-multi

Copyright 1987-2000, Larry Wall

Perl may be copied only under the terms of either the Artistic License or
the
GNU General Public License, which may be found in the Perl 5.0 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.

#

perl -V
Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
osname=linux, osvers=2.2.14-5.0, archname=i686-linux-multi i
config_args=''
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=define
useperlio=undef d_sfio=undef uselargefiles=define
use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
cc='cc', optimize='-O2', gccversion=egcs-2.91.66 19990314/Linux
(egcs-1.1.2 release)
cppflags='-fno-strict-aliasing -I/usr/local/include'
ccflags
='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFS
ET_BITS=64'
stdchar='char', d_stdstdio=define, usevfork=false
intsize=4, longsize=4, ptrsize=4, doublesize=8
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, usemymalloc=n, prototype=define
  Linker and Libraries:
ld='cc', ldflags =''
libpth=/usr/lib /lib
libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
libc=/lib/libc-2.1.2.so, so=so, useshrplib=true, libperl=libperl.so
  Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef,
ccdlflags='-rdynamic -Wl,-rpath,/usr/local/lib/perl5/5.6.0/i686-linux-multi/
CORE'
cccdlflags='-fpic', lddlflags='-shared'


Characteristics of this binary (from libperl):
  Compile-time options: MULTIPLICITY USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
  Built under linux
  Compiled at Apr 13 2000 19:39:52
  @INC:
/usr/local/lib/perl5/5.6.0/i686-linux-multi
/usr/local/lib/perl5/5.6.0
/usr/local/lib/perl5/site_perl/5.6.0/i686-linux-multi
/usr/local/lib/perl5/site_perl/5.6.0
/usr/local/lib/perl5/site_perl




[RFC] Benchmarking Apache::Registry and Perl Content Handler

2000-04-14 Thread Stas Bekman

Disclaimer: the numbers here are too low for mod_perl, because my machine
is to slow :( I'll rerun the same tests on a much faster machine
before releasing the new version of the Guide. 

=head1 Benchmarking Apache::Registry and Perl Content Handler

=head2 Empty scripts

First lets see the overhead that Apache::Regsitry adds. In order to do
that we will use an almost empty scripts, that only send a basic
header and one word as a content.

The Iregistry.pl script running under CApache::Registry:

  registry.pl
  ---
  use strict;
  print "Content-type: text/plain\r\n\r\n";
  print "Hello";

The Perl Content handler:

  Benchmark/Handler.pm
  
  package Benchmark::Handler;
  use Apache::Constants qw(:common);
  
  sub handler{
$r = shift;
$r-send_http_header('text/html');
$r-print("Hello");
return OK;
  }
  1;

with settings:

  PerlModule Benchmark::Handler
  Location /benchmark_handler
SetHandler perl-script
PerlHandler Benchmark::Handler
  /Location

The benchmark:

  % ab -n 1000 -c 10 http://localhost/perl/benchmarks/registry.pl
  
  Requests per second:21.27
  Time taken for tests:   43.924 seconds
  Connnection Times (ms)
min   avg   max
  Connect:0 3   218
  Processing:   223   435   679
  Total:223   438   897

  % ab -n 1000 -c 10 http://localhost/benchmark_handler
  
  Requests per second:49.03
  Time taken for tests:   20.394 seconds
  Connnection Times (ms)
min   avg   max
  Connect:0 1   201
  Processing:59   201   605
  Total: 59   202   806

So we can see that the average added overhead is about:

  438 - 202 = 236 milli-seconds

per script.

=head2 Heavy Scripts

Of course this overhead is insignificant when the code itself is
significantly heavier and slower. Let's leave the above code examples
umodified but add some CPU intensive processing operation (it can be
also an IO operation or a database query.)

  my $x = 100;
  my $y = log ($x ** 100)  for (0..1);

  % ab -n 1000 -c 10 http://localhost/perl/benchmarks/registry.pl

  Time taken for tests:   121.944 seconds
  Requests per second:8.20
  
  Connnection Times (ms)
min   avg   max
  Connect:011   950
  Processing:   747  1204   888
  Total:747  1215  1838

  %ab -n 1000 -c 10  http://localhost/benchmark_handler

  Time taken for tests:   41.166 seconds
  Requests per second:24.29
  
  Connnection Times (ms)
min   avg   max
  Connect:0 3   150
  Processing:73   407  1211
  Total: 73   410  1361

META: something is wrong here! It shouldn't be that slower. Should try
run it on a faster machine!




__
Stas Bekman | JAm_pH--Just Another mod_perl Hacker
http://stason.org/  | mod_perl Guide  http://perl.apache.org/guide 
mailto:[EMAIL PROTECTED]  | http://perl.orghttp://stason.org/TULARC/
http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org
--




[RFC] Benchmarking CGI.pm and Apache::Request

2000-04-14 Thread Stas Bekman

=head1 Benchmarking CGI.pm and Apache::Request

Let's write two registry scripts that use CCGI.pm and
CApache::Request to process the form's input and print it out.

  benchmarks/cgi_pm.pl
  
  use strict;
  use CGI;
  my $q = new CGI;
  print $q-header('text/plain');
  print join "\n", map {"$_ = ".$q-param($_) } $q-param;

  benchmarks/apache_request.pl
  
  use strict;
  use Apache::Request ();
  my $r = Apache-request;
  my $q = Apache::Request-new($r);
  $r-send_http_header('text/plain');
  print join "\n", map {"$_ = ".$q-param($_) } $q-param;


Now let's benchmark the two:

  % ab -n 1000 -c 10 \

'http://localhost/perl/benchmarks/cgi_pm.pl?a=bc=+k+d+d+fd=asfas=+1+2+3+4'

  Time taken for tests:   57.112 seconds
  Requests per second:17.51
  
  Connnection Times (ms)
min   avg   max
  Connect:0 6   319
  Processing:   191   561  4563
  Total:191   567  4882

  % ab -n 1000 -c 10 \

'http://localhost/perl/benchmarks/apache_request.pl?a=bc=+k+d+d+fd=asfas=+1+2+3+4'
  
  Time taken for tests:   23.662 seconds
  Requests per second:42.26
  
  Connnection Times (ms)
min   avg   max
  Connect:0 3   263
  Processing:   152   232   597
  Total:152   235   860

Apparently the latter script using CApache::Request is more than
twice and a half faster.

Again this benchmark shows that the real timing of the input
processing, when the script is much heavier the overhead of using
CCGI.pm can be insignificant.





__
Stas Bekman | JAm_pH--Just Another mod_perl Hacker
http://stason.org/  | mod_perl Guide  http://perl.apache.org/guide 
mailto:[EMAIL PROTECTED]  | http://perl.orghttp://stason.org/TULARC/
http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org
--




Re: [RFC] Benchmarking Apache::Registry and Perl Content Handler

2000-04-14 Thread Buddy Lee Haystack

Hello!

Can you please provide the technical specifications for the hardware that performed 
these tests.

Thanks!



Stas Bekman wrote:
 
 Disclaimer: the numbers here are too low for mod_perl, because my machine
 is to slow :( I'll rerun the same tests on a much faster machine
 before releasing the new version of the Guide.
 
 =head1 Benchmarking Apache::Registry and Perl Content Handler
 
 =head2 Empty scripts
 
 First lets see the overhead that Apache::Regsitry adds. In order to do
 that we will use an almost empty scripts, that only send a basic
 header and one word as a content.
 
 The Iregistry.pl script running under CApache::Registry:
 
   registry.pl
   ---
   use strict;
   print "Content-type: text/plain\r\n\r\n";
   print "Hello";
 
 The Perl Content handler:
 
   Benchmark/Handler.pm
   
   package Benchmark::Handler;
   use Apache::Constants qw(:common);
 
   sub handler{
 $r = shift;
 $r-send_http_header('text/html');
 $r-print("Hello");
 return OK;
   }
   1;
 
 with settings:
 
   PerlModule Benchmark::Handler
   Location /benchmark_handler
 SetHandler perl-script
 PerlHandler Benchmark::Handler
   /Location
 
 The benchmark:
 
   % ab -n 1000 -c 10 http://localhost/perl/benchmarks/registry.pl
 
   Requests per second:21.27
   Time taken for tests:   43.924 seconds
   Connnection Times (ms)
 min   avg   max
   Connect:0 3   218
   Processing:   223   435   679
   Total:223   438   897
 
   % ab -n 1000 -c 10 http://localhost/benchmark_handler
 
   Requests per second:49.03
   Time taken for tests:   20.394 seconds
   Connnection Times (ms)
 min   avg   max
   Connect:0 1   201
   Processing:59   201   605
   Total: 59   202   806
 
 So we can see that the average added overhead is about:
 
   438 - 202 = 236 milli-seconds
 
 per script.
 
 =head2 Heavy Scripts
 
 Of course this overhead is insignificant when the code itself is
 significantly heavier and slower. Let's leave the above code examples
 umodified but add some CPU intensive processing operation (it can be
 also an IO operation or a database query.)
 
   my $x = 100;
   my $y = log ($x ** 100)  for (0..1);
 
   % ab -n 1000 -c 10 http://localhost/perl/benchmarks/registry.pl
 
   Time taken for tests:   121.944 seconds
   Requests per second:8.20
 
   Connnection Times (ms)
 min   avg   max
   Connect:011   950
   Processing:   747  1204   888
   Total:747  1215  1838
 
   %ab -n 1000 -c 10  http://localhost/benchmark_handler
 
   Time taken for tests:   41.166 seconds
   Requests per second:24.29
 
   Connnection Times (ms)
 min   avg   max
   Connect:0 3   150
   Processing:73   407  1211
   Total: 73   410  1361
 
 META: something is wrong here! It shouldn't be that slower. Should try
 run it on a faster machine!
 
 __
 Stas Bekman | JAm_pH--Just Another mod_perl Hacker
 http://stason.org/  | mod_perl Guide  http://perl.apache.org/guide
 mailto:[EMAIL PROTECTED]  | http://perl.orghttp://stason.org/TULARC/
 http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org
 --



[RFC] Transitioning from Apache::Registry to Apache handlers

2000-04-14 Thread Stas Bekman

Someone has asked how to move from registry scripts to perl handlers, this
is my attempt to show in details the process. Comments are welcome.

=head1 Transitioning from Apache::Registry to Apache handlers

Even if you are a CGI script die-hard at some point you might want to
move a few or all your scripts to Apache Perl handlers. Actually this
is an easy task, since we saw already what CApache::Registry does to
our scripts so they will appear as Perl handlers to Apache.

Now when you are no longer need a backward mod_cgi compatibility you
can benefit from the Perl libraries working only under
mod_perl. We will see why in a moment.

Let's see an example. We will start with a mod_cgi compatible CGI
script running under CApache::Registry, transpose it into a Perl
content handler and then convert it to use CApache::Request and
CApache::Cookie.

=head2 Starting with mod_cgi Compatible Script

This is the original script's code we are going to work with:

  cookie_script.pl
  
  use strict;
  use CGI;
  use CGI::Cookie;
  use vars qw($q $switch $status $sessionID);
  
  init();
  print_header();
  print_status();
  
  ### -- subroutines -- ###
  
  # the init code
  ###
  sub init{
$q = new CGI;

$switch = $q-param("switch") ? 1 : 0;

  # try to retrieve the session ID
  # fetch existing cookies
my %cookies = CGI::Cookie-fetch;
$sessionID = exists $cookies{'sessionID'} 
   ? $cookies{'sessionID'}-value : '';

  # 0 = not running, 1 = running
$status = $sessionID ? 1 : 0;

  # switch status if asked to
$status = ($status+1) % 2 if $switch;

if ($status){
# preserve sessionID if exists or create a new one
  $sessionID ||= generate_sessionID() if $status;
} else {
# delete the sessionID
  $sessionID = '';
}

  } # end of sub init
  
  #
  sub print_header{
  # prepare a cooke
my $c = CGI::Cookie-new
  (-name= 'sessionID',
   -value   = $sessionID,
   -expires = '+1h');

print $q-header
  (-type   = 'text/html',
   -cookie = $c);
  
  } # end of sub print_header
  
  
  # print the current Session status and a form to toggle the status
  #
  sub print_status{

print qq{HTMLHEADTITLECookie/TITLE/HEADBODY};
  
  # print status
print "BStatus:/B ",
  $status
? "Session is running with ID: $sessionID"
: "No session is running";


  # change status form
my $button_label = $status ? "Stop" : "Start";
print qq{HR
 FORM
   INPUT TYPE=SUBMIT NAME=switch VALUE=" $button_label " 
 /FORM
   };

print qq{/BODY/HTML};
  
  } # end of sub print_status
  
  # A dummy ID generator
  # Replace with a real session ID generator
  
  sub generate_sessionID {
return scalar localtime;
  } # end of sub generate_sessionID


The code is very simple. It creates a session if you've pressed the
I'Start' button or deletes it if the I'Stop' button has been
pressed. The session is stored and retrieved using the cookies
technique.

Note that we have split the obviously simple and short code into a
three logical units, by putting the code into three subroutines.
init() to initialize global variable and parse incoming data,
print_header() to print the HTTP headers including the cookie header
and finally print_status() to generate the output. Later we will see
that this logical separation will allow us an easy conversion to Perl
content handler code.

We have used global variables for a few variables since we didn't want
to pass them from function to function. In a big project you should be
very restrictive about what variables should be allowed to be global
if any at all. In any case, the init() subroutine makes sure all these
variables are re-initialized for each code reinvocation.

Note that we have used a very simple generate_sessionID() function
that return a date string (i.e. SWed Apr 12 15:02:23 2000) as a
session ID. You want to replace this one with code which generates a
unique session every time it was called. And it should be secure,
i.e. users will not be able to forge one and do nasty things.



=head2 Converting into Perl Content Handler

Now let's convert this script into a content handler. There are two
parts to be done; the first one is to configure Apache to run this new
code as a Perl handler, the second one is to modify the code itself.

First we add the following snippet to Ihttpd.conf:

  PerlModule Test::Cookie
  Location /test/cookie
SetHandler perl-script
PerlHandler Test::Cookie
  /Location

After we restart the server, when there is a request whose URI starts
with I/test/cookie, Apache will execute CTest::Cookie::handler()
subroutine as a content handler.  We made sure to preload the
CTest::Cookie module at the server start-up, with the CPerlModule
directive.

Now we are 

Re: [RFC] Benchmarking Apache::Registry and Perl Content Handler

2000-04-14 Thread Stas Bekman

On Fri, 14 Apr 2000, Buddy Lee Haystack wrote:

 Hello!
 
 Can you please provide the technical specifications for the hardware that performed 
these tests.

Sure, but the point here is a comparison and not absolute values,
therefore I believe this doesn't change a thing. Am I wrong? 

Anyway, here are the relevant specs:

Both the client (ab) and server were running on the same, quite loaded
machine, where 25% of CPU were eaten by xmms :) 

SW:
Perl: version 5.005_03 built for i386-linux
Server: Apache/1.3.10-dev (Unix) mod_perl/1.21_01-dev

HW: Memory: DIMM 256M
CPU:
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 5
model   : 4
model name  : Pentium MMX
stepping: 4
cpu MHz : 200.460259
fdiv_bug: no
hlt_bug : no
sep_bug : no
f00f_bug: yes
coma_bug: no
fpu : yes
fpu_exception   : yes
cpuid level : 1
wp  : yes
flags   : fpu vme de pse tsc msr mce cx8 mmx
bogomips: 399.77

I think I've some HW problems as everything is too slow lately :(

__
Stas Bekman | JAm_pH--Just Another mod_perl Hacker
http://stason.org/  | mod_perl Guide  http://perl.apache.org/guide 
mailto:[EMAIL PROTECTED]  | http://perl.orghttp://stason.org/TULARC/
http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org
--




RE: [RFC] Transitioning from Apache::Registry to Apache handlers

2000-04-14 Thread Chris Nokleberg


 Someone has asked how to move from registry scripts to perl handlers, this
 is my attempt to show in details the process. Comments are welcome.

In my mind, one of the biggest problems in transitioning from
Apache::Registry is the added server configuration complexity. Would it be
possible to add a section on the best way to simplify or eliminate the need
to modify the conf file for each new handler? Perl sections, etc.?

Thanks,
Chris

--
  Chris Nokleberg  +   Internet Sports Network, Inc.
  [EMAIL PROTECTED]   +   http://www.SportsRocket.com/




modperl and MIME::Parser?

2000-04-14 Thread John S. Evans

So I'm trying to work around my problems with Apache::Request by parsing the
request myself.  This way I can work with only a single open file at a time.

But now I have a new problem.  In my content handler, if I add "use
MIME::Parser;" to the top of my file, apache won't start - it seems to hang
during the startup phase.  My module never gets initialized, and apache
never prints "[Fri Apr 14 12:29:14 2000] [notice] Apache/1.3.9 (Unix)
mod_perl/1.21 configured -- resuming normal operations".

I don't even call any functions in the module yet, just "use" it.  If I take
out the "use" statement, apache (and my module) load just fine.

Can you think of anything that would cause the MIME::Parser module to
disagree with modperl?  I'm just about to start reaming through the
MIME::Parser source code looking for stuff that gets initialized at
module-load time.

-jse




Remote URL

2000-04-14 Thread Paul McCumber

I want to build a web page dynamically with content from several other web
sites.  I need to be able to fetch the remote URL's content into variables.
How do I do that?

For starters, I just have a module that just goes and gets a URL and writes
that URL back to the browser.  Can't even get that to work.   I think the
hardest thing for me is that there is just no way to debug it.  Admittedly,
I'm new to this environment but I just getting killed.  Very easy thing to
do in ASP but I want to use Perl and Apache and Linux.

Somebody has to have done this.

Paul




RE: Remote URL

2000-04-14 Thread Jason Bodnar

Take a look at Apache::ProxyStuff on CPAN. It mau already do what you want it
do and if it doesn't it'll give you an idea of how you can do what you want to
do.

On 14-Apr-2000 Paul McCumber wrote:
 I want to build a web page dynamically with content from several other web
 sites.  I need to be able to fetch the remote URL's content into variables.
 How do I do that?
 
 For starters, I just have a module that just goes and gets a URL and writes
 that URL back to the browser.  Can't even get that to work.   I think the
 hardest thing for me is that there is just no way to debug it.  Admittedly,
 I'm new to this environment but I just getting killed.  Very easy thing to
 do in ASP but I want to use Perl and Apache and Linux.
 
 Somebody has to have done this.
 
 Paul

-- 
Jason Bodnar + [EMAIL PROTECTED] + Tivoli Systems

Mr. Scorpio says productivity is up 2% and it's all because of my
motivational techniques, like donuts and the possibility of more
donuts to come.

-- Homer Simpson
   You Only Move Twice




Re: Remote URL

2000-04-14 Thread Ken Y. Clark

On Fri, 14 Apr 2000, Paul McCumber wrote:

 I want to build a web page dynamically with content from several other web
 sites.  I need to be able to fetch the remote URL's content into variables.
 How do I do that?
 
 For starters, I just have a module that just goes and gets a URL and writes
 that URL back to the browser.  Can't even get that to work.   I think the
 hardest thing for me is that there is just no way to debug it.  Admittedly,
 I'm new to this environment but I just getting killed.  Very easy thing to
 do in ASP but I want to use Perl and Apache and Linux.

well, this isn't really mod_perl, just perl.  if you're having trouble
debugging (yes, mod_perl is a bit more of a challenge to debug, having to
restart your server b/w code changes, unless you use StatINC), then i'd
recommend writing your first iteration as a straight CGI script, using
"strict" and all that good stuff.  if it works properly, you could always
run it (mostly) unchanged under Apache::Registry.

for the fetching of remote web sites:  have you tried LWP?  very nice
package.

ky





Re: Remote URL

2000-04-14 Thread Jason Simms

I want to build a web page dynamically with content from several other web 
sites.  I need to be able to fetch the remote URL's content into 
variables. How do I do that?

This really is not that difficult, and yes, lots of people certainly have 
done it.  You have many options open to you, but the easiest (perhaps) would 
be to look into using the LWP::* series of modules.  These modules have 
several methods for retrieving and parsing URL's, etc.  You can return the 
result of an HTTP call and save the result as a variable.  Also, you can use 
other methods to strip out HTML, etc.  And this just touches the surface of 
what you can do.  I would suggest reading "Web Client Programming with 
Perl", as well as all the LWP perldoc pages.

But, if you cannot even get a simple program to work, your problem lies 
deeper than a misunderstanding of the tools available to you already.  
Perhaps if you posted your code in the most simple form in which it is 
failing, we can help.

Jason Simms


__
Get Your Private, Free Email at http://www.hotmail.com




Re: modperl and MIME::Parser?

2000-04-14 Thread Stas Bekman

On Fri, 14 Apr 2000, John S. Evans wrote:

 So I'm trying to work around my problems with Apache::Request by parsing the
 request myself.  This way I can work with only a single open file at a time.
 
 But now I have a new problem.  In my content handler, if I add "use
 MIME::Parser;" to the top of my file, apache won't start - it seems to hang
 during the startup phase.  My module never gets initialized, and apache
 never prints "[Fri Apr 14 12:29:14 2000] [notice] Apache/1.3.9 (Unix)
 mod_perl/1.21 configured -- resuming normal operations".
 
 I don't even call any functions in the module yet, just "use" it.  If I take
 out the "use" statement, apache (and my module) load just fine.
 
 Can you think of anything that would cause the MIME::Parser module to
 disagree with modperl?  I'm just about to start reaming through the
 MIME::Parser source code looking for stuff that gets initialized at
 module-load time.

I've no idea about the cause, but why don't you start the server under
strace (or truss) and see where it hangs. If you don't figure out by
yourself send the trace to the list (the relevant snippet if you know
what's relevant). 

See:
http://perl.apache.org/guide/debug.html#Determination_of_the_reason
http://perl.apache.org/guide/debug.html#Debug_Tracing

__
Stas Bekman | JAm_pH--Just Another mod_perl Hacker
http://stason.org/  | mod_perl Guide  http://perl.apache.org/guide 
mailto:[EMAIL PROTECTED]  | http://perl.orghttp://stason.org/TULARC/
http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org
--




Re: Apache::SSI forces text/html?

2000-04-14 Thread Ken Williams

Okay, then I'll remove the line for the next version, it won't touch
content-type.



[EMAIL PROTECTED] (Dan McCormick) wrote:
It looks like Apache will follow its normal extension-to-MIME-type
mapping, which seems like the right to do.  I just tested it on a .ps
file (using Apache::SSI to include something), and it sent it to me as
application/postscript.

Dan

Ken Williams wrote:
 
 [EMAIL PROTECTED] (Dan McCormick) wrote:
 Hi,
 
 I was just trying to hack a script into showing its HTML output to a
 browser by setting the content type to 'text/plain', but it looks like
 Apache::SSI, which I'm using, always sets the content type to
 'text/html' (line 23 Apache::SSI).
 
 I'll remove it if it won't break anything - will Apache set the type to
 text/html if no other information is given?
 
   ------
   Ken Williams Last Bastion of Euclidity
   [EMAIL PROTECTED]The Math Forum


  ------
  Ken Williams Last Bastion of Euclidity
  [EMAIL PROTECTED]The Math Forum





SOLVED: Segfault with Embperl, Apache::Session (piece of %@#!*)

2000-04-14 Thread Jason Bodnar

Fickle, fickle machines.

The segfault problem with Embperl and Apache::Session can be fixed with about 3
keystrokes in emacs.

When I was getting the segfault error I had:

# BEGIN EMBPERL SESSION HANDLING
PerlSetEnv EMBPERL_SESSION_CLASSES "DBIStore SysVSemaphoreLocker"
PerlSetEnv EMBPERL_SESSION_ARGS "DataSource=dbi:mysql:sessions UserName=root" 
PerlRequire startup.pl

PerlModule Apache::AuthenDBI
PerlModule HTML::Embperl



If you move the PerlRequire below PerlModule HTML::Embperl everything works. Of
course, it makes sense because startup.pl has the line for setting nsems for
Apache::Session::SysVSemaphoreLocker and Embperl loads that module for you so
startup.pl needs to load after Embperl.

The interesting thing is that with perl5.004 I was getting segfaults. After
building perl5.005 and rebuilding all the modules, apache and mod_perl I no
longer got segfaults but got Invalid argument errors from SysVSemaphoreLocker.
Either perl5.005 or the newer versions of Apache::Session or IPC::Semaphore are
a little bit more tolerant to misplaced parameters.

Gerald, if it's not on the wish list already, could you add a request for the
ability to set nsems in EMBPERL_SESSION_ARGS. Or maybe I should just get off my
butt and make a patch.

-- 
Jason Bodnar + [EMAIL PROTECTED] + Tivoli Systems

Homer:  We always have one good kid and one lousy kid.  Why can't both 
our kids be good?

Marge:  We have three kids, Homer.

   Separate Vacations




RE: SOLVED: Segfault with Embperl, Apache::Session (piece of %@#!*)

2000-04-14 Thread Gerald Richter


 Gerald, if it's not on the wish list already, could you add a
 request for the
 ability to set nsems in EMBPERL_SESSION_ARGS. Or maybe I should
 just get off my
 butt and make a patch.


This works already. You can give any arguments to EMBPERL_SESSION_ARGS that
a Store or Locker module accepts. Embperl only pass them thru. e.g.

PerlSetEnv EMBPERL_SESSION_ARGS "DataSource=dbi:mysql:sessions UserName=root
NSems=16"

Gerald


-
Gerald Richterecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:   Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: [EMAIL PROTECTED] Voice:+49 6133 925151
WWW:http://www.ecos.de  Fax:  +49 6133 925152
-




Compiler errors...

2000-04-14 Thread Robert Jenks
Title: Compiler errors...





We are currently using Linux/Apache/mod_perl (and Stat::INC) with good success (thanks to the help of this list) as a replacement for WinNT/IIS/Velocigen. Everything is (now) going good except that we miss one of Velocigen's debugging features. Velocigen would display compiler errors to the browser (after a file-change recompile). 

I'm currently using CGI::Carp qw(fatalsToBrowser), but this only shows runtime errors.


Is there a way to do this? I've thought about using the Apache ErrorDocument config to call a perl script which would display the last few lines of the error_log, but it wouldn't be very elegant.

Any solutions?


Thanks in advance...


--
Robert Jenks [EMAIL PROTECTED]
Physia.com





Re: Compiler errors...

2000-04-14 Thread Ken Y. Clark

On Fri, 14 Apr 2000, Robert Jenks wrote:

 We are currently using Linux/Apache/mod_perl (and Stat::INC) with good
 success (thanks to the help of this list) as a replacement for
 WinNT/IIS/Velocigen.  Everything is (now) going good except that we miss one
 of Velocigen's debugging features.  Velocigen would display compiler errors
 to the browser (after a file-change recompile).  
 
 I'm currently using CGI::Carp qw(fatalsToBrowser), but this only shows
 runtime errors.
 
 Is there a way to do this?  I've thought about using the Apache
 "ErrorDocument" config to call a perl script which would display the last
 few lines of the error_log, but it wouldn't be very elegant.

robert,

i would suggest wrapping all the meat of you code in an eval, and then
checking for errors on exit.  when things go wrong, you handle the error.
when things are fine, you create output, like so:

package Foo::Bar;

use Apache;
use Apache::Constants qw(:common);
use strict;

sub handler {
my $r = shift;
   
eval {
# put anything here that could possibly error out
# like database connections, file reads, etc.
};

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

if ($@) {
$r-print("There was an error: '$@'");
} else {
$r-print('Apache/mod_perl rules!');
}
return OK;
}

1;

hth,

ky




RE: Compiler errors...

2000-04-14 Thread Robert Jenks
Title: RE: Compiler errors...





Thanks Ken! It worked like a charm!


-Robert





Re: cvs commit: modperl-2.0/lib/ModPerl Code.pm

2000-04-14 Thread Bill Moseley

At 11:56 AM 04/14/00 +0300, Stas Bekman wrote:
   sticking to the convention of single quoting constant strings

Why? You lose the interpolation feature when you need it and you get to
the awkward statement like this:

   -print $h_fh "\n#define ",
   +print $h_fh "\n", '#define ',

Orwant and friends in "Algorithms with Perl" page 28 claims the first form
is slower.


Bill Moseley
mailto:[EMAIL PROTECTED]



Re: cvs commit: modperl-2.0/lib/ModPerl Code.pm

2000-04-14 Thread Doug MacEachern

  Orwant and friends in "Algorithms with Perl" page 28 claims the first form
  is slower.

faster to *parse*, not faster to *run*.  stas, your benchmarks don't test
parse time.
 
 It seems that TIMTOWTDI is going to die soon as everybody tells me that I
 should code as shown in "OO Perl" and ""Algorithms with Perl" :( 
 
 The books are cool, but why turning them into bibles? The book authors are
 great, but why rising them into gods? 

bibles?  gods?  i haven't touched either of these books.  i'm using '' vs.
"" because '' is faster for Perl to parse and faster for me to parse.
i'm thinking about string usage more, rather than just slinging them
around without a care.  i'm trying to avoid interpolation, which turns
into concatination, which uses more memory and is slower than using a
list.  if i see a '' string, i don't worry, if i see "", i want to look
close and thing about how expensive it will turn out to be.

there will be exceptions, like "\n", ' define' vs "\ndefine", i do prefer
the later for readability.  in fact, there's plenty of interpolation
happening in those modules, i very much value readability, and the 
"\n", ' define' did make me cringe a bit.  and i will probably change that
one back.

and, your benchmark of those shows "\ndefine" to be faster, because
the string being copied is so tiny, it's less expensive than pushing an
extra item onto the stack.  when generating webpages, we generally don't
deal with such tiny strings, do we?

use Benchmark;

open my $fh, '', '/dev/null';

my($one, $two, $three, $four) = map { $_ x 1000 } 'a'..'d';

timethese(300_000, {
 concat = sub {
 print $fh "$one$two$three$four";
 },
 list = sub {
 print $fh $one, $two, $three, $four;
 },
});

Benchmark: timing 30 iterations of concat, list...
concat: 12 wallclock secs (10.83 usr +  0.67 sys = 11.50 CPU) @
26086.96/s (n=30)
  list:  9 wallclock secs ( 6.75 usr +  0.59 sys =  7.34 CPU) @
40871.93/s (n=30)





Re: cvs commit: modperl-2.0/lib/ModPerl Code.pm

2000-04-14 Thread Stas Bekman

On Fri, 14 Apr 2000, Doug MacEachern wrote:

   Orwant and friends in "Algorithms with Perl" page 28 claims the first form
   is slower.
 
 faster to *parse*, not faster to *run*.  stas, your benchmarks don't test
 parse time.
  
  It seems that TIMTOWTDI is going to die soon as everybody tells me that I
  should code as shown in "OO Perl" and ""Algorithms with Perl" :( 
  
  The books are cool, but why turning them into bibles? The book authors are
  great, but why rising them into gods? 
 
 bibles?  gods?  i haven't touched either of these books.  i'm using '' vs.
 "" because '' is faster for Perl to parse and faster for me to parse.
 i'm thinking about string usage more, rather than just slinging them
 around without a care.  i'm trying to avoid interpolation, which turns
 into concatination, which uses more memory and is slower than using a
 list.  if i see a '' string, i don't worry, if i see "", i want to look
 close and thing about how expensive it will turn out to be.
 
 there will be exceptions, like "\n", ' define' vs "\ndefine", i do prefer
 the later for readability.  in fact, there's plenty of interpolation
 happening in those modules, i very much value readability, and the 
 "\n", ' define' did make me cringe a bit.  and i will probably change that
 one back.
 
 and, your benchmark of those shows "\ndefine" to be faster, because
 the string being copied is so tiny, it's less expensive than pushing an
 extra item onto the stack.  when generating webpages, we generally don't
 deal with such tiny strings, do we?
 
 use Benchmark;
 
 open my $fh, '', '/dev/null';
 
 my($one, $two, $three, $four) = map { $_ x 1000 } 'a'..'d';
 
 timethese(300_000, {
  concat = sub {
  print $fh "$one$two$three$four";
  },
  list = sub {
  print $fh $one, $two, $three, $four;
  },
 });
 
 Benchmark: timing 30 iterations of concat, list...
 concat: 12 wallclock secs (10.83 usr +  0.67 sys = 11.50 CPU) @
 26086.96/s (n=30)
   list:  9 wallclock secs ( 6.75 usr +  0.59 sys =  7.34 CPU) @
 40871.93/s (n=30)

Doug, you are my man :) That's the explanation I was looking for! Thanks a
lot!

P.S. I'm sending a few more benchmarks to the list now :) Apache::Request
rules!!!

__
Stas Bekman | JAm_pH--Just Another mod_perl Hacker
http://stason.org/  | mod_perl Guide  http://perl.apache.org/guide 
mailto:[EMAIL PROTECTED]  | http://perl.orghttp://stason.org/TULARC/
http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org
--




cvs commit: modperl-2.0/lib/Apache .cvsignore

2000-04-14 Thread dougm

dougm   00/04/14 16:29:46

  Added:   lib/Apache .cvsignore
  Log:
  ignore
  
  Revision  ChangesPath
  1.1  modperl-2.0/lib/Apache/.cvsignore
  
  Index: .cvsignore
  ===
  BuildConfig.pm