File uploads using Apache:;request in mod_perl2

2004-01-16 Thread Pete Smith
Hi,

I am new to this list, but I have tried looking through the docs at CPAN and
googling for people with similar problems to no avail.

We have upgraded our server to apache2 + mod_perl2. I used to have a routine
that took a file upload from a multipart form and handed it as a stream to
Imager and Image::Size like so:


my $image_upload = $r->upload('image');
my $file_handle = $image_upload->fh();

read ($file_handle, my $full_image_data, (stat($file_handle))[7]);

my $imager = Imager->new();

$imager->open(data => $full_image_data, type => 'jpeg');
my ($width) = imgsize(\$full_image_data);


I now know that I could pass the file handle to Imager and Image::Size
instead of turning into a scalar stream, but that isn't the problem.

I have discovered that Apache::Request for mod_perl2 has changed the fh
method to bb, which apparently returns an APR::Brigade (object I presume)
instead of a file handle. 

I have looked for documentation for APR::Brigade, but can find none. I have
no idea what it is!

Could somebody please point me in the right direction as to how I can
achieve the above in mod_perl2?

Thanks,
Pete


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Re: File uploads using Apache:;request in mod_perl2

2004-01-16 Thread Stas Bekman
Pete Smith wrote:
Hi,

I am new to this list, but I have tried looking through the docs at CPAN and
googling for people with similar problems to no avail.
We have upgraded our server to apache2 + mod_perl2. I used to have a routine
that took a file upload from a multipart form and handed it as a stream to
Imager and Image::Size like so:
[...]
I have discovered that Apache::Request for mod_perl2 has changed the fh
method to bb, which apparently returns an APR::Brigade (object I presume)
instead of a file handle. 
no, no, you have confused something. You need a new version of Apache::Request 
which is still in beta. Please take a look at: http://httpd.apache.org/apreq/
Also please notice that it has its own mailing list if you have any questions.

I guess we should add a note to the compat doc:
http://perl.apache.org/docs/2.0/user/porting/compat.html
Alternatively you could use a slower CGI.pm for uploads till libapreq2 is 
released.

__
Stas BekmanJAm_pH --> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


RE: File uploads using Apache:;request in mod_perl2

2004-01-16 Thread Pete Smith
> no, no, you have confused something. You need a new version of
> Apache::Request
> which is still in beta. Please take a look at:
> http://httpd.apache.org/apreq/
> Also please notice that it has its own mailing list if you have any
> questions.

Thanks for your help. I've installed it, and Apache seems to load it in OK
as a module. However my code still complains:

Can't locate object method "fh" via package "Apache::Upload"

I'm still not completely au fait with mod_perl, so please forgive my
ignorance, but I cannot find source or documentation for Apache::Upload. I
presume it's some sort of sub class of Apache::Request, which I believe
libapreq2-2.02 installs (I used the Makefile.PL way of configuring).

Thanks,
Pete


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



libapreq2 and FreeBSD

2004-01-16 Thread Martin Nilsson
I'm trying to install libapreq2-2.02-dev on FreeBSD 4.9 with Perl 5.6.1 
and Apache 2.048 mod_perl2-1.99r12 all installed from ports.

Things that needs to be changed:
Build with gmake - not the FreeBSD make!
src/Makefile - Add -L/usr/local/lib to the following line so expat lib 
is found:
LIBS =  /usr/local/lib/apache2/libapr-0.la -lm -lcrypt 
/usr/local/lib/apache2/libaprutil-0.la -lexpat

glue/Makefile - change invocations of make to gmake

Add the ppport.h file found here:
http://marc.theaimsgroup.com/?l=apreq-dev&m=107104807218621&w=2
Add the dAX patch found here:
http://marc.theaimsgroup.com/?l=apreq-dev&m=107110581723271&w=2
Now the package builds and installs but the server tests fail.
I'll make some real programming tests with it tonight.
The following files have been installed, does this look reasonable?

platon# pkg_info -L bsdpan-libapreq2-0.10
Information for bsdpan-libapreq2-0.10:
Files:
///usr/local/lib/perl5/5.6.1/man/man3/Apache::Cookie.3
///usr/local/lib/perl5/5.6.1/man/man3/Apache::Request.3
///usr/local/lib/perl5/site_perl/5.6.1/mach/Apache2/Apache/Cookie.pm
///usr/local/lib/perl5/site_perl/5.6.1/mach/Apache2/Apache/Cookie.pod
///usr/local/lib/perl5/site_perl/5.6.1/mach/Apache2/Apache/Request.pm
///usr/local/lib/perl5/site_perl/5.6.1/mach/Apache2/Apache/Request.pod
///usr/local/lib/perl5/site_perl/5.6.1/mach/Apache2/auto/Apache/Cookie/Cookie.bs
///usr/local/lib/perl5/site_perl/5.6.1/mach/Apache2/auto/Apache/Cookie/Cookie.so
///usr/local/lib/perl5/site_perl/5.6.1/mach/Apache2/auto/Apache/Request/Request.bs
///usr/local/lib/perl5/site_perl/5.6.1/mach/Apache2/auto/Apache/Request/Request.so
///usr/local/lib/perl5/site_perl/5.6.1/mach/auto/libapreq2/.packlist
Thanks for any help making this work!

/Martin

--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


[Fwd: NTLM Authentcation]

2004-01-16 Thread Shannon Eric Peevey


 Original Message 
Subject:NTLM Authentcation
Date:   Thu, 15 Jan 2004 20:14:51 +
From:   Darryl L Miles <[EMAIL PROTECTED]>
Organization:   E-Smart Integrations Ltd
To: [EMAIL PROTECTED]


Hi,

Sorry to trouble you but you're name has cropped up in many modperl 
forums I've been researching for a solution to my problem, and I also 
note you're listed as the author of Apache::AuthenNTLM on CPAN but not 
in the documentation.

I have a problem in IE6 connects to Apache, apache returns a 401.  that 
my Win2000 machine received

smbclient is able to connect to an authenticated share on the same 
server from the same Linux host using the same credentials I'm trying 
from the browser.

I have also confirmed with TCPDUMP that a connection is being made from 
the Linux host to Win2000.  But I suspect Win2000 is sending back a 
response meaning its not willing to hand out a "nonce" value to start 
the authentication process off.

There is nothing in the documentation that indicates I have to configure 
the Win2000 server in any special way to allow permissions for my 
Linux/Apache host to verify credentials.

The current output:

[2058] AuthenNTLM: Config Domain = office.domain.com  pdc = 172.16.48.3
bdc =
[2058] AuthenNTLM: Config Domain = domain  pdc = 172.16.48.3  bdc =
[2058] AuthenNTLM: Config Default Domain = office.domain.com
[2058] AuthenNTLM: Config Fallback Domain =
[2058] AuthenNTLM: Config AuthType = ntlm AuthName = /
[2058] AuthenNTLM: Config Auth NTLM = 1 Auth Basic = 0
[2058] AuthenNTLM: Config NTLMAuthoritative = on  BasicAuthoritative = on
[2058] AuthenNTLM: Config Semaphore key = 23754 timeout = 2
[2058] AuthenNTLM: Authorization Header 
[Thu Jan 15 19:34:52 2004] [error] access to /login_ntlm/process/ failed for
,
reason: Bad/Missing NTLM/Basic Authorization Header for /login_ntlm/process/
[2059] AuthenNTLM: Config Domain = office.domain.com  pdc = 172.16.48.3
bdc =
[2059] AuthenNTLM: Config Domain = domain  pdc = 172.16.48.3  bdc =
[2059] AuthenNTLM: Config Default Domain = office.domain.com
[2059] AuthenNTLM: Config Fallback Domain =
[2059] AuthenNTLM: Config AuthType = ntlm AuthName = /
[2059] AuthenNTLM: Config Auth NTLM = 1 Auth Basic = 0
[2059] AuthenNTLM: Config NTLMAuthoritative = on  BasicAuthoritative = on
[2059] AuthenNTLM: Config Semaphore key = 23754 timeout = 2
[2059] AuthenNTLM: Authorization Header NTLM
[2059] AuthenNTLM: protocol=NTLMSSP, type=1,
flags1=7(NEGOTIATE_UNICODE,NEGOTIAT
E_OEM,REQUEST_TARGET), flags2=178(NEGOTIATE_ALWAYS_SIGN,NEGOTIATE_NTLM),
domain
length=11, domain offset=35, host length=3, host offset=32, host=SAM,
domain=DOMAIN
[2059] AuthenNTLM: Connect to pdc = 172.16.48.3 bdc =  domain = domain
[2059] AuthenNTLM: enter lock
[Thu Jan 15 19:34:52 2004] [error] access to /login_ntlm/process/ failed 
for ,
reason: Connect to SMB Server faild (pdc = 172.16.48.3 bdc =  domain =
domain error = -11/0) for /login_ntlm/process/
[2059] AuthenNTLM: leave lock
[Thu Jan 15 19:34:52 2004] [error] access to /login_ntlm/process/ failed 
for ,
reason: Cannot get nonce



Typo "faild"

domain error = -11/0: means nothing to me



TCPDUMP proof of Apache/Linux trying to authenticate with Win2000:

20:07:52.594266 arp who-has 172.16.48.3 tell 172.16.48.4
20:07:52.594369 arp reply 172.16.48.3 is-at 0:5:5d:6a:ac:5e
20:07:52.594382 172.16.48.4.37850 > 172.16.48.3.netbios-ssn: S 
4239341864:4239341864(0) win 5840  (DF)
20:07:52.594489 172.16.48.3.netbios-ssn > 172.16.48.4.37850: S 
4062526081:4062526081(0) ack 4239341865 win 64240  (DF)
20:07:52.594510 172.16.48.4.37850 > 172.16.48.3.netbios-ssn: . ack 1 win 
5840  (DF)
20:07:52.594606 172.16.48.4.37850 > 172.16.48.3.netbios-ssn: P 1:73(72) 
ack 1 win 5840 NBT Packet (DF)
20:07:52.595567 172.16.48.3.netbios-ssn > 172.16.48.4.37850: FP 1:6(5) 
ack 73 win 64168 NBT Packet (DF)
20:07:52.595943 172.16.48.4.32775 > 172.16.48.3.domain:  26938+ A? . 
(17) (DF)
20:07:52.596129 172.16.48.3.domain > 172.16.48.4.32775:  26938 ServFail 
0/0/0 (17)
20:07:52.634290 172.16.48.4.37850 > 172.16.48.3.netbios-ssn: . ack 7 win 
5840  (DF)
20:07:52.664060 172.16.48.4.37850 > 172.16.48.3.netbios-ssn: F 73:73(0) 
ack 7 win 5840  (DF)
20:07:52.664169 172.16.48.3.netbios-ssn > 172.16.48.4.37850: . ack 74 
win 64168  (DF)

I also note that Apache tries to do a DNS lookup for "." and that fails.

My .htaccess file:

PerlAuthenHandler Apache::AuthenNTLM
AuthType ntlm
#,basic
AuthName "/"
require valid-user
#domain pdcbdc
PerlAddVar ntdomain "office.domain.com 172.16.48.3"
PerlAddVar ntdomain "domain 172.16.48.3"
PerlSetVar defaultdomain office.domain.com
PerlSetVar ntlmdebug 1


Just a suggestion is maybe worth confirming the version number of 
Apache::AuthenNTLM maybe it higher debug level, as I've installed 
version 0.23 before and have installed your 2.04 over the top and 
restarted the HTTP servers.  Now I'm not sure if its 2.04 I'm actually 
running.

Your help or pointers woul

Re: Modperl 2.0 Not finding correct *.conf

2004-01-16 Thread steve larson
Hello,
 here is the requested information.
Thanks for the support, :)
Steve Larson
[EMAIL PROTECTED]


-8<-- Start Bug Report
8<--
1. Problem Description:
 
I can explain the reason I was using the apr-config
file, due to the several which exist:

[EMAIL PROTECTED] root]# find / -name apr-config
/usr/local/bin/apr-config
/usr/local/apr/bin/apr-config
/usr/local/source/httpd-2.0.48/srclib/apr/apr-config
[EMAIL PROTECTED] root]# ls -al /usr/local/bin/apr-config
lrwxrwxrwx1 root root   29 Jan  4
11:20 /usr/local/bin/apr-config ->
/usr/local/apr/bin/apr-config
[EMAIL PROTECTED] root]#
[EMAIL PROTECTED] root]# ls -al
/usr/local/apr/bin/apr-config
-rwxr-xr-x1 root root 9001 Dec  6
20:17 /usr/local/apr/bin/apr-config
[EMAIL PROTECTED] root]# ls -al
/usr/local/source/httpd-2.0.48/srclib/apr/apr-config
-rwxr-xr-x1 root root 9006 Jan 12
15:57
/usr/local/source/httpd-2.0.48/srclib/apr/apr-config
[EMAIL PROTECTED] root]#

This may have been the mistake on my part using the
latest apr-config.
 
2. Used Components and their Configuration:
 
*** mod_perl version 1.9912
 
*** using lib/Apache/BuildConfig.pm
*** Makefile.PL options:
  MP_APR_CONFIG   =>
/usr/local/source/apache2/srclib/apr/apr-config
  MP_APXS =>
/usr/local/apache2/httpd/prefork/bin/apxs
  MP_AP_PREFIX=> /usr/local/source/apache2
  MP_CCOPTS   => -DMP_IOBUFSIZE=16384
  MP_COMPAT_1X=> 1
  MP_DEBUG=> 1
  MP_GENERATE_XS  => 1
  MP_INST_APACHE2 => 1
  MP_LIBNAME  => mod_perl
  MP_TRACE=> 1
  MP_USE_DSO  => 1
  MP_USE_STATIC   => 1
  
 
 
*** /usr/local/apache2/httpd/prefork/bin/ps -V
Server version: Apache/2.0.48
Server built:   Jan 14 2004 13:14:36
Server's Module Magic Number: 20020903:4
Architecture:   32-bit
Server compiled with
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_PROC_PTHREAD_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D HTTPD_ROOT="/usr/local/apache2/httpd/prefork"
 -D
SUEXEC_BIN="/usr/local/apache2/httpd/prefork/bin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/ps.conf"
 
 
*** /usr/bin/perl -V
Summary of my perl5 (revision 5.0 version 8 subversion
0) configuration:
  Platform:
osname=linux, osvers=2.4.21-1.1931.2.382.entsmp,
archname=i386-linux-thread-multi
uname='linux str'
config_args='-des -Doptimize=-O2 -g -pipe
-march=i386 -mcpu=i686 -Dmyhostname=localhost
[EMAIL PROTECTED] -Dcc=gcc -Dcf_by=Red Hat,
Inc. -Dinstallprefix=/usr -Dprefix=/usr
-Darchname=i386-linux -Dvendorprefix=/usr
-Dsiteprefix=/usr -Dotherlibdirs=/usr/lib/perl5/5.8.0
-Duseshrplib -Dusethreads -Duseithreads
-Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db
-Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm
-Duseperlio -Dinstallusrbinperl -Ubincompat5005
-Uversiononly -Dpager=/usr/bin/less -isr'
hint=recommended, useposix=true,
d_sigaction=define
usethreads=define use5005threads=undef'
 useithreads=define usemultiplicity=
useperlio= d_sfio=undef uselargefiles=define
usesocks=undef
use64bitint=undef use64bitall=un uselongdouble=
usemymalloc=, bincompat5005=undef
  Compiler:
cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE
-DTHREADS_HAVE_PIDS -DDEBUGGING -fno-strict-aliasing
-I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
optimize='',
cppflags='-D_REENTRANT -D_GNU_SOURCE
-DTHREADS_HAVE_PIDS -DDEBUGGING -fno-strict-aliasing
-I/usr/local/include -I/usr/include/gdbm'
ccversion='', gccversion='3.2.2 20030222 (Red Hat
Linux 3.2.2-5)', gccosandvers=''
gccversion='3.2.2 200302'
intsize=r, longsize=r, ptrsize=5, doublesize=8,
byteorder=1234
d_longlong=define, longlongsize=8,
d_longdbl=define, longdblsize=12
ivtype='long'
k', ivsize=4'
ivtype='l, nvtype='double'
o_nonbl', nvsize=, Off_t='', lseeksize=8
alignbytes=4, prototype=define
  Linker and Libraries:
ld='gcc'
l', ldflags =' -L/u'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lpthread -lc
-lcrypt -lutil
perllibs=
libc=/lib/libc-2.3.2.so, so=so, useshrplib=true,
libperl=libper
gnulibc_version='2.3.2'
  Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so', d_dlsymun=undef,
ccdlflags='-rdynamic
-Wl,-rpath,/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE'
cccdlflags='-fPIC'
ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5',
lddlflags='s Unicode/Normalize
XS/A'
 
 
Characteristics of this binary (from libperl):
  Compile-time options: DEBUGGING MULTIPLICITY
USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT

Re: File uploads using Apache:;request in mod_perl2

2004-01-16 Thread Joe Schaefer
"Pete Smith" <[EMAIL PROTECTED]> writes:

[...]

> my $image_upload = $r->upload('image');
> my $file_handle = $image_upload->fh();
> 
> read ($file_handle, my $full_image_data, (stat($file_handle))[7]);
> 
> my $imager = Imager->new();
> 
> $imager->open(data => $full_image_data, type => 'jpeg');
> my ($width) = imgsize(\$full_image_data);
> 
> 
> I now know that I could pass the file handle to Imager and Image::Size
> instead of turning into a scalar stream, but that isn't the problem.
> 
> I have discovered that Apache::Request for mod_perl2 has changed the
> fh method to bb, which apparently returns an APR::Brigade (object I
> presume) instead of a file handle. 
> 
> I have looked for documentation for APR::Brigade, but can find none. I
> have no idea what it is!

APR::Brigade is, well, the perl glue for libaprutil's apr_brigade_t C struct.  
Along with buckets, they are used throughout the filter api, both in
apache2 and mp2 (collectively referred to as "bucket brigades").

> Could somebody please point me in the right direction as to how I can
> achieve the above in mod_perl2?

In your mp1 code, you are simply slurping the upload into
$full_image_data; with apreq2 you can do that with a bucket 
brigade via

  my $bb = $req->upload('image')->bb;
  my $full_image_data = "";

  while (my $b = $bb->first) {
 $b->read(my $buffer);
 $full_image_data .= $buffer;
 $b->remove;
  }

I'm sure there are better ways to use the brigade API
though.  The C API for brigades has a "flatten" function- 
does anyone know if mp2 has glue for that yet?

-- 
Joe Schaefer


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Re: libapreq2 and FreeBSD

2004-01-16 Thread Joe Schaefer
Martin Nilsson <[EMAIL PROTECTED]> writes:

> I'm trying to install libapreq2-2.02-dev on FreeBSD 4.9 with Perl
> 5.6.1 and Apache 2.048 mod_perl2-1.99r12 all installed from ports.

Wonderful!  Thanks alot!

[...]

> Files:
> ///usr/local/lib/perl5/5.6.1/man/man3/Apache::Cookie.3
> ///usr/local/lib/perl5/5.6.1/man/man3/Apache::Request.3

[...]

> ///usr/local/lib/perl5/site_perl/5.6.1/mach/auto/libapreq2/.packlist
> 
> Thanks for any help making this work!

The perl glue looks ok to me.  Where did mod_apreq.so 
and libapreq2.so wind up going? mod_apreq should be in
apache2's module directory, and libapreq2 should be
alongside libaprutil.

-- 
Joe Schaefer


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Re: File uploads using Apache:;request in mod_perl2

2004-01-16 Thread Clayton Cottingham
i just figured something like this out on perlmonks.org:
http://www.perlmonks.org/index.pl?node_id=320770


On Fri, 2004-01-16 at 11:02, Joe Schaefer wrote:
> "Pete Smith" <[EMAIL PROTECTED]> writes:
> 
> [...]
> 
> > my $image_upload = $r->upload('image');
> > my $file_handle = $image_upload->fh();
> > 
> > read ($file_handle, my $full_image_data, (stat($file_handle))[7]);
> > 
> > my $imager = Imager->new();
> > 
> > $imager->open(data => $full_image_data, type => 'jpeg');
> > my ($width) = imgsize(\$full_image_data);
> > 
> > 
> > I now know that I could pass the file handle to Imager and Image::Size
> > instead of turning into a scalar stream, but that isn't the problem.
> > 
> > I have discovered that Apache::Request for mod_perl2 has changed the
> > fh method to bb, which apparently returns an APR::Brigade (object I
> > presume) instead of a file handle. 
> > 
> > I have looked for documentation for APR::Brigade, but can find none. I
> > have no idea what it is!
> 
> APR::Brigade is, well, the perl glue for libaprutil's apr_brigade_t C struct.  
> Along with buckets, they are used throughout the filter api, both in
> apache2 and mp2 (collectively referred to as "bucket brigades").
> 
> > Could somebody please point me in the right direction as to how I can
> > achieve the above in mod_perl2?
> 
> In your mp1 code, you are simply slurping the upload into
> $full_image_data; with apreq2 you can do that with a bucket 
> brigade via
> 
>   my $bb = $req->upload('image')->bb;
>   my $full_image_data = "";
> 
>   while (my $b = $bb->first) {
>  $b->read(my $buffer);
>  $full_image_data .= $buffer;
>  $b->remove;
>   }
> 
> I'm sure there are better ways to use the brigade API
> though.  The C API for brigades has a "flatten" function- 
> does anyone know if mp2 has glue for that yet?
> 
> -- 
> Joe Schaefer
-- 
Clayton Cottingham - WinterMarket Networks
Virtual Reality Programming, Design & Evangelist
Phone:(604) 875-1213
Cell: (604) 506-7230
Vancouver, B.C. Canada
[EMAIL PROTECTED]
http://www.wintermarket.net
IM's icq:154964789 hotmail:[EMAIL PROTECTED]
yahoo:[EMAIL PROTECTED]


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Re: File uploads using Apache:;request in mod_perl2

2004-01-16 Thread Geoffrey Young

> In your mp1 code, you are simply slurping the upload into
> $full_image_data; with apreq2 you can do that with a bucket 
> brigade via
> 
>   my $bb = $req->upload('image')->bb;
>   my $full_image_data = "";
> 
>   while (my $b = $bb->first) {
>  $b->read(my $buffer);
>  $full_image_data .= $buffer;
>  $b->remove;
>   }
> 
> I'm sure there are better ways to use the brigade API
> though. 

that's pretty much the only way I've seen it used, but stas might have other
examples up his sleeve.

I did think that $b->remove() was still problematic though

> The C API for brigades has a "flatten" function- 
> does anyone know if mp2 has glue for that yet?

apr_brigade_flatten and apr_brigade_pflatten are currently not open, though
they are marked as "unclassified" which I take to mean that doug never
decided whether to make them available or not.

I'm not as familiar with brigades as I should be, but does it save you the
iteration process or is it just a substitute for reading to a buffer?

--Geoff


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



perl sections howto?

2004-01-16 Thread gerard uolaquetalestem

(I have sent this mail from another address and it has not be received, so i re-send 
again)

Once i have installed the last windows version of modperl2, i try to transcript some
apache code of my httpd.conf into perl sections.

I have this block in my httpd.conf (i post two times)

---

SetHandler perl-script
PerlResponseHandler Blogum::UserLog
Allow from all
PerlOptions +ParseHeaders

---

SetHandler perl-script
PerlResponseHandler Blogum::UserLog
Allow from all
PerlOptions +ParseHeaders

---

and what i try now is this:
PerlModule Apache2
PerlModule Apache::PerlSections #(necessary? i've tried without)
PerlModule Apache::Status #(necessary? i've tried without)
---

$Location{'.*log$'} = {
SetHandler => "perl-script",
PerlResponseHandler => "Blogum::UserLog",
PerlOptions => "+ParseHeaders",
Allow => "from all",
};

---

$Location{'.*log$'} = {
SetHandler => "perl-script",
PerlResponseHandler => "Blogum::UserLog",>
PerlOptions => "+ParseHeaders",
Allow => "from all",
};

---

Server starts with no problem, but the usual function (interpret /log/ url) fails, it
simply put "that page does not exist".

What am i doing wrong??

Thanks.

Server:

Apache/2.0.48 (Win32) mod_perl/1.99_13-dev Perl/v5.8.2 Server at localhost Port 80


>apache.exe -V
Server version: Apache/2.0.48
Server built: Oct 29 2003 09:37:51
Server's Module Magic Number: 20020903:4
Architecture: 32-bit
Server compiled with
-D APACHE_MPM_DIR="server/mpm/winnt"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D HTTPD_ROOT="/apache"
-D SUEXEC_BIN="/apache/bin/suexec"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error.log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"

>perl -V
Summary of my perl5 (revision 5 version 8 subversion 2) configuration:
Platform:
osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
uname=''
config_args='undef'
hint=recommended, useposix=true, d_sigaction=undef
usethreads=undef use5005threads=undef useithreads=define usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cl', ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -
DNO_STRICT -DHAVE_DES_FCRYPT -DNO_HASH_SEED -DPERL_IMPLICIT_CONTEXT -DPERL_IMPL
ICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX',
optimize='-MD -Zi -DNDEBUG -O1',
cppflags='-DWIN32'
ccversion='', gccversion='', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf
-libpath:"F:\tools\Perl\lib\CORE" -machine:x86'
libpth=C:\PROGRA~1\MICROS~3\VC98\lib
libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32
lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsoc
k32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib
perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comd
lg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib
wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib
libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
gnulibc_version='undef'
Dynamic Linking:
dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf -
libpath:"F:\tools\Perl\lib\CORE" -machine:x86'


Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_
CONTEXT PERL_IMPLICIT_SYS
Locally applied patches:
ActivePerl Build 808
21846 Configure gets d_u32align wrong
21739 [perl #24493] install.html not working
21737 Ooops. left an XXX comment in, and worse still it's a // comment
21735 utf8 keys now work for tied hashes
21734 Accessing unicode keys in tie hashes via hv_exists was broken
21733 ext/threads/t/problem.t
21732 Config::myconfig() fails under ithreads
21728 Update perlhist with 5.6.2
21723 Include 'SCCS' in the list of dir names ignored by installperl
21718 Empty subroutine as object method segfaults in 5.8.2 (sometimes)
21714 Fix bug #24380: assigning list with duplicated ke

Re: File uploads using Apache:;request in mod_perl2

2004-01-16 Thread Joe Schaefer
Geoffrey Young <[EMAIL PROTECTED]> writes:

[...]

> I'm not as familiar with brigades as I should be, but does
> it save you the iteration process or is it just a substitute for
> reading to a buffer? 

It'd save you the iteration process (it's an APR::Brigade method,
not APR::Bucket), but would not destroy the buckets within the 
brigade (hmm, does APR::Brigade have a DESTROY method?).  

The advantage here is you'd be able to accomplish this
in one or two lines of perl, ie.

  my $upload_data = $req->upload('file')->bb->flatten;


-- 
Joe Schaefer


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Re: File uploads using Apache:;request in mod_perl2

2004-01-16 Thread Geoffrey Young


Joe Schaefer wrote:
> Geoffrey Young <[EMAIL PROTECTED]> writes:
> 
> [...]
> 
> 
>>I'm not as familiar with brigades as I should be, but does
>>it save you the iteration process or is it just a substitute for
>>reading to a buffer? 
> 
> 
> It'd save you the iteration process (it's an APR::Brigade method,
> not APR::Bucket), but would not destroy the buckets within the 
> brigade (hmm, does APR::Brigade have a DESTROY method?).  
> 
> The advantage here is you'd be able to accomplish this
> in one or two lines of perl, ie.
> 
>   my $upload_data = $req->upload('file')->bb->flatten;

oooh, nice.  I can definitely see that being a useful idiom.

let's see about opening it up.

--Geoff


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Re: File uploads using Apache:;request in mod_perl2

2004-01-16 Thread Joe Schaefer
Geoffrey Young <[EMAIL PROTECTED]> writes:

> Joe Schaefer wrote:
> >   my $upload_data = $req->upload('file')->bb->flatten;
> 
> oooh, nice.  I can definitely see that being a useful idiom.

Not sure if it'd be better for flatten to take $upload_data as 
an argument and return a status code instead, but I'll happily
leave that decision for the implementer :-).

-- 
Joe Schaefer


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Includes in mod_perl

2004-01-16 Thread Hemond, Steve
Hi ppl,

I've started programming with Perl some months ago and I want to switch
to mod_perl for my website (my older website is an asp website).

I readed the tutorials on perl.apache.org but I am still very confused
and don't know how to start my new website with mod_perl.

Actually :
1. I have only one website running on my Apache webserver (in /htdocs/)
2. I would like to use a templating system so I could write plain html
code and include dynamic content between special tags.
3. I would like my webpages to have the same header and footer.

What do you suggest me to do :

1. How to modify httpd.conf so mod_perl would be the handler for my only
website (my main problem, actually)
2. Can I have all my webpages have the .pl extension and reside in the
same directory (/htdocs/) so I could get rid of a /cgi-bin/
subdirectory?

Your ideas and basic explanations of mod_perl will be very appreciated.

Thanks in advance,

Best regards,

Steve Hemond
Programmeur Analyste / Analyst Programmer
Smurfit-Stone, Ressources Forestieres
La Tuque, P.Q.
Tel.: (819) 676-8100 X2833
[EMAIL PROTECTED] 


--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Re: Different results using mod_proxy or mod_rewrite vs direct server - followup

2004-01-16 Thread Rafael Caceres
On Mon, 2004-01-12 at 17:55, Stas Bekman wrote:
> Rafael Caceres wrote:
> > I'm setting up a HTTP/HTPPS reverse proxy server with apache on my DMZ.
> > The proxy will access an internal server (insidelan.server.com) to
> > provide content to outside users.
> > I've attempted using mod_proxy:
> > 
> >   ServerName insidelan.server.com
> >   ProxyPass / http://insidelan.server.com/
> >   ProxyPassReverse / http://insidelan.server.com/
> > 
> > 
> > and using mod_rewrite:
> > 
> >   ServerName insidelan.server.com
> >   RewriteRule /(.*)$ http://insidelan.server.com/$1 [P]
> > 
> 
> Don't you miss:
> 
>ProxyPassReverse / http://insidelan.server.com/
> 
> in the mod_rewrite case if you want it to be equivalent to the mod_proxy vhost 
> setup? [P] does only the 'ProxyPass / http://insidelan.server.com/' part.
> 
You're right. Fact is we exercised the HTTPS part only when using the
login windows, which inmediately redirected to /index using HTTP.

Is there a way to make sure that people coming through the DMZ can only
see a subset of the site (say, an /extranet branch)?

> > Everything seems to work fine (including the HTTPS proxy, cookies, etc.,
> > etc.), except that I'm getting:
> > Proxy Error
> > The proxy server received an invalid response from an upstream server
> > The proxy server could not handle the requet GET /perl/program.pl
> > Reason: Document contains no data
> > 
> > The very same URL: http://insidelan.server.com/perl/program.pl (that
> > runs under Apache::Registry) works just fine when used from inside the
> > LAN (that is, directly).
> > 
> > I also copied program.pl to the cgi-bin directory (to run it as a
> > standard CGI), and called the resulting URL:
> > http://insidelan.server.com/cgi-bin/program.pl and what comes up is the
> > text of the generated HTML page.
> > Strangely enough, some other perl scripts (in cgi-bin or perl) work fine
> > through the proxy.
> > 
> 
> What's the global difference between working and non-working scripts (e.g. are 
> all non-working are processing GET requests?).
> 
I found that the difference could be attributed to /cgi-bin having
PerlSendHeader Off and /perl having PerlSendHeader On. 
The scripts using Template Toolkit (and not having an print
$query->header (or similar) did not show up when viewed through the
proxy.
The quick fix was adding the print $query-header to scripts using
Template Toolkit. What still puzzles me, is that they work when viewed
directly and through a standard Squid proxy, and what to do if I ever
need to set cookies that can depend on template work.

Rafael Caceres



-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Re: Includes in mod_perl

2004-01-16 Thread petersm
Hemond, Steve <[EMAIL PROTECTED]> wrote

> Actually :
> 1. I have only one website running on my Apache webserver (in /htdocs/)

Maybe if you show us the relevant portions of your httpd.conf file we could
point you in the right direction since this is were most of that is set up.

> 2. I would like to use a templating system so I could write plain html
> code and include dynamic content between special tags.
> 3. I would like my webpages to have the same header and footer.

I really enjoy HTML::Template. I use it for both mod_perl and plain old cgi
scripts and it works wonderfully. I especially like it since even the custom
tags that it uses to fill in dynamic content look and behave like HTML.

Michael Peters
Venzia


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



RE : Includes in mod_perl

2004-01-16 Thread Hemond, Steve
Here are snippets of my httpd.conf file :
-
...
LoadModule perl_module modules/mod_perl.so
...
DocumentRoot "/usr/local/apache2/htdocs"
...

Options Indexes +Includes +ExecCGI
AllowOverride None
Order allow,deny
Allow from all

...
AddHandler cgi-script .cgi .pl
...
ScriptAlias /cgi-bin/ "/usr/local/apache2/htdocs/cgi-bin/"
...

AllowOverride None
Options None
Order allow,deny
Allow from all

...

Does that help a bit?

Thanks again,

Regards,

Steve Hemond
Programmeur Analyste / Analyst Programmer
Smurfit-Stone, Ressources Forestières
La Tuque, P.Q.
Tel.: (819) 676-8100 X2833
[EMAIL PROTECTED] 



 > -Original Message-
 > From: petersm [mailto:[EMAIL PROTECTED] 
 > Sent: Friday, January 16, 2004 4:20 PM
 > To: Hemond,Steve; [EMAIL PROTECTED]
 > Subject: Re: Includes in mod_perl
 > 
 > 
 > Hemond, Steve <[EMAIL PROTECTED]> wrote
 > 
 > > Actually :
 > > 1. I have only one website running on my Apache webserver (in 
 > > /htdocs/)
 > 
 > Maybe if you show us the relevant portions of your 
 > httpd.conf file we could point you in the right direction 
 > since this is were most of that is set up.
 > 
 > > 2. I would like to use a templating system so I could 
 > write plain html 
 > > code and include dynamic content between special tags. 3. 
 > I would like 
 > > my webpages to have the same header and footer.
 > 
 > I really enjoy HTML::Template. I use it for both mod_perl 
 > and plain old cgi scripts and it works wonderfully. I 
 > especially like it since even the custom tags that it uses 
 > to fill in dynamic content look and behave like HTML.
 > 
 > Michael Peters
 > Venzia
 > 

--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Re: RE : Includes in mod_perl

2004-01-16 Thread petersm
"Hemond, Steve" <[EMAIL PROTECTED]> wrote
> Here are snippets of my httpd.conf file :
> -
> ...
> LoadModule perl_module modules/mod_perl.so
> ...
> DocumentRoot "/usr/local/apache2/htdocs"
> ...
> 
> Options Indexes +Includes +ExecCGI
> AllowOverride None
> Order allow,deny
> Allow from all
> 
> ...
> AddHandler cgi-script .cgi .pl
> ...
> ScriptAlias /cgi-bin/ "/usr/local/apache2/htdocs/cgi-bin/"
> ...
> 
> AllowOverride None
> Options None
> Order allow,deny
> Allow from all
> 
Try adding this line
'AddHandler perl-script .cgi .pl'
inside of your  tags. After you do that, what do you get
when you put a test .cgi or .pl file into the /usr/local/apache2/htdocs/ dir
and try and run it.

Michael Peters
Venzia


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Bandwidth limiting (per client or global)?

2004-01-16 Thread Dave Rolsky
I looked for a flexible bandwidth limiting solution that would let me
apply limits to a location, vhost, the whole server, and on either a
per-client or global basis.

I couldn't find one, but I may have missed something obvious.  I know that
neither mod_throttle or mod_bandwidth are flexible enough to do what I
want.  Does anyone know of one?


-dave

/*===
House Absolute Consulting
www.houseabsolute.com
===*/

-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Re: File uploads using Apache:;request in mod_perl2

2004-01-16 Thread Stas Bekman
Joe Schaefer wrote:
Geoffrey Young <[EMAIL PROTECTED]> writes:

[...]


I'm not as familiar with brigades as I should be, but does
it save you the iteration process or is it just a substitute for
reading to a buffer? 


It'd save you the iteration process (it's an APR::Brigade method,
not APR::Bucket), but would not destroy the buckets within the 
brigade (hmm, does APR::Brigade have a DESTROY method?).  

The advantage here is you'd be able to accomplish this
in one or two lines of perl, ie.
  my $upload_data = $req->upload('file')->bb->flatten;
It doesn't sound like a good idea. Users ain't need to mess with bucket 
brigades, unless they really want to. If the upload is always going through 
the temp file, why making things complex for the users?

In any case it's the best to hide the internals behind an API, so you can do:

my $upload_data = $req->upload('file')->slurp;

and inside slurp you have the C API to do anything you need. How does that sound?



__
Stas BekmanJAm_pH --> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: Modperl 2.0 Not finding correct *.conf

2004-01-16 Thread Stas Bekman
steve larson wrote:

I can explain the reason I was using the apr-config
file, due to the several which exist:
[...]

*** Makefile.PL options:
  MP_APR_CONFIG   =>
/usr/local/source/apache2/srclib/apr/apr-config
  MP_APXS =>
/usr/local/apache2/httpd/prefork/bin/apxs
  MP_AP_PREFIX=> /usr/local/source/apache2
This is your problem. You shouldn't use MP_APR_CONFIG and MP_APXS along with 
MP_AP_PREFIX. Besides your MP_APR_CONFIG is wrong, it still points to the 
source directory.

Do you mind trying the modperl-2.0 cvs? I've added a check that people won't 
do that mistake. See the instructions here:
http://perl.apache.org/download/source.html#Development_mod_perl_2_0_Source_Distribution

Please rebuild using the following arguments (removed MP_APR_CONFIG and 
MP_AP_PREFIX args):

  MP_APXS =>
/usr/local/apache2/httpd/prefork/bin/apxs
  MP_DEBUG=> 1
  MP_INST_APACHE2 => 1
  MP_TRACE=> 1
then try again 'make test'. If you still have failures please report including 
a complete bug report, so I can see what arguments you have used this time. 
Thanks.

__
Stas BekmanJAm_pH --> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: libapreq2 and FreeBSD

2004-01-16 Thread Stas Bekman
Martin Nilsson wrote:
I'm trying to install libapreq2-2.02-dev on FreeBSD 4.9 with Perl 5.6.1 
and Apache 2.048 mod_perl2-1.99r12 all installed from ports.

Things that needs to be changed:
Build with gmake - not the FreeBSD make!
src/Makefile - Add -L/usr/local/lib to the following line so expat lib 
is found:
LIBS =  /usr/local/lib/apache2/libapr-0.la -lm -lcrypt 
/usr/local/lib/apache2/libaprutil-0.la -lexpat

glue/Makefile - change invocations of make to gmake

Add the ppport.h file found here:
http://marc.theaimsgroup.com/?l=apreq-dev&m=107104807218621&w=2
Add the dAX patch found here:
http://marc.theaimsgroup.com/?l=apreq-dev&m=107110581723271&w=2
No need to add dAX. Just get the latest ppport.h generated by perl5.8.3. We 
have already added dAX there.

__
Stas BekmanJAm_pH --> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: perl sections howto?

2004-01-16 Thread Stas Bekman
gerard uolaquetalestem wrote:
(I have sent this mail from another address and it has not be received, so i re-send again)

Once i have installed the last windows version of modperl2, i try to transcript some
apache code of my httpd.conf into perl sections.
I have this block in my httpd.conf (i post two times)

---

[...]
$Location{'.*log$'} = {
You've lost '~' here. Use

$LocationMatch{'.*log$'} = {

instead. I'm not sure whether:

$Location{'~ .*log$'} = {

will work, give it a try.

and what i try now is this:
PerlModule Apache2
PerlModule Apache::PerlSections #(necessary? i've tried without)
You shouldn't need to. It loads automatically. Why do you get an error of not 
being able to find Apache::PerlSections?

PerlModule Apache::Status #(necessary? i've tried without)
Only if you need it. Please read the module manpage.

__
Stas BekmanJAm_pH --> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: RE : Includes in mod_perl

2004-01-16 Thread Stas Bekman
petersm wrote:
[...]
Try adding this line
'AddHandler perl-script .cgi .pl'
inside of your  tags. After you do that, what do you get
when you put a test .cgi or .pl file into the /usr/local/apache2/htdocs/ dir
and try and run it.
How is it going to work without PerlHandler?

Steve, I supposed you've got lost in the sea of docs. Please start with:
http://perl.apache.org/docs/1.0/guide/getwet.html
Next it's the best to get one of the books here:
http://perl.apache.org/docs/offsite/books.html
You probably are better off starting with the cookbook an as you get more 
experienced continue onto the other two books.

__
Stas BekmanJAm_pH --> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: File uploads using Apache:;request in mod_perl2

2004-01-16 Thread Joe Schaefer
Stas Bekman <[EMAIL PROTECTED]> writes:


[...]

> It doesn't sound like a good idea. Users ain't need to mess with
> bucket brigades, unless they really want to. If the upload is always
> going through the temp file, why making things complex for the users?

Exactly because it is NOT always going through a temp file.  
Just look further upthread- this particular user doesn't
even *want* a temp file, just the data.  Why should he need
to make all those "open/read/write/close file" system calls 
if he doesn't need them?

> In any case it's the best to hide the internals behind an API,
> so you can do:  
>
> my $upload_data = $req->upload('file')->slurp;
> 
> and inside slurp you have the C API to do anything you need. How
> does that sound? 

That's a possibility, but I fail to see its advantage over
APR::Brigade exposing flatten().  It is part of the C API
after all, eh?  Why shouldn't perl programmers have access
to it?

-- 
Joe Schaefer


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Re: File uploads using Apache:;request in mod_perl2

2004-01-16 Thread Stas Bekman
Joe Schaefer wrote:
Stas Bekman <[EMAIL PROTECTED]> writes:

[...]


It doesn't sound like a good idea. Users ain't need to mess with
bucket brigades, unless they really want to. If the upload is always
going through the temp file, why making things complex for the users?


Exactly because it is NOT always going through a temp file.  
Just look further upthread- this particular user doesn't
even *want* a temp file, just the data.  Why should he need
to make all those "open/read/write/close file" system calls 
if he doesn't need them?
No reason to.

In any case it's the best to hide the internals behind an API,
so you can do:  

my $upload_data = $req->upload('file')->slurp;

and inside slurp you have the C API to do anything you need. How
does that sound? 


That's a possibility, but I fail to see its advantage over
APR::Brigade exposing flatten().  It is part of the C API
after all, eh?  Why shouldn't perl programmers have access
to it?
I'm not against adding the perl glue for APR::Brigade::flatten, quite on the 
opposite I'm all for it. All I was saying is that users don't need to know 
about the existance of APR::Brigade at all. Not only because it's an 
unnecessary information to 99.9% of users out there, but also because if 
tomorrow you decide to change the internal implementation you will be now 
stuck with dependancy on that flatten call. Hiding the details behind the 
scenes sounds like the right thing to me, but you know that already ;)

BTW, please remember that if and when you add slurp it should make the slurped 
data tainted under -T/-t. Thanks Joe.

__
Stas BekmanJAm_pH --> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: File uploads using Apache:;request in mod_perl2

2004-01-16 Thread Stas Bekman
Joe Schaefer wrote:
[...]
I'm not against adding the perl glue for APR::Brigade::flatten, quite
on the opposite I'm all for it. All I was saying is that users don't
need to know about the existance of APR::Brigade at all. Not only
because it's an unnecessary information to 99.9% of users out there,
but also because if tomorrow you decide to change the internal
implementation you will be now stuck with dependancy on that flatten
call. 


My viewpoint on brigades has changed over the last year- they're
so much more flexible than filehandles are. I now see upload->bb()
as an abstraction of upload->fh(). 
You need the filehandle only if you use the temp file. In which case bbs are 
irrelevant. If you use slurp then there is are no filehandles. I think these 
are orthogonal.

Since libapreq2 is a pure apr 
application, I don't think the brigade APIs are ever coming out of 
apreq2.  Increasing the apr-dependence doesn't seem harmful to me.
Yes, but reread this para. It took you quite time to grok bbs and appreciate 
them. It's good to appreciate and know how they work when you need more 
flexibility, better performance in certain cases and you don't just want to 
have this upload script working.

BTW, please remember that if and when you add slurp it should make
the slurped data tainted under -T/-t. Thanks Joe.


+1. Should we mark normal params tainted as well?
CGI.pm uses normal read() to gets its data, which means that all data it 
returns via params is tainted. (but please double check). So I think the 
answer is yes.

I'm not sure whether mp1's and mp2's read return the data tainted. Can someone 
give it a test? I think mp2 doesn't and it should, something to look at.

__
Stas BekmanJAm_pH --> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: File uploads using Apache:;request in mod_perl2

2004-01-16 Thread Joe Schaefer
Stas Bekman <[EMAIL PROTECTED]> writes:

[...]

> You need the filehandle only if you use the temp file. In which case
> bbs are irrelevant. If you use slurp then there is are no
> filehandles. I think these are orthogonal.

Agreed- my earlier +1 was for both adding a slurp() method and 
marking the output as tainted.

-- 
Joe Schaefer


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Re: File uploads using Apache:;request in mod_perl2

2004-01-16 Thread Stas Bekman
Joe Schaefer wrote:
Stas Bekman <[EMAIL PROTECTED]> writes:

[...]


You need the filehandle only if you use the temp file. In which case
bbs are irrelevant. If you use slurp then there is are no
filehandles. I think these are orthogonal.


Agreed- my earlier +1 was for both adding a slurp() method and 
marking the output as tainted.
Understood.

So since we are designing a new interface. Would it make sense to have slurp() 
accept an optional argument limiting the size of the data it's going to slurp? 
I mean the MAX_POST_DATA (or whatever it is) limit is all good, but since for 
big data we mainly use temp files MAX_POST_DATA, we may want to say

  upload->slurp(2**14) or die "the input is too big";

actually, I'm having another idea on slurp. Since it smells too read()-like. 
One could have an APREQ::PerlIO layer and having upload return that filehandle 
opened through that layer (like APR::PerlIO or Apache::PerlIO do). Now you 
could transparently do temp files or inmemory uploads, giving the user the 
good old read() API. You can even support seek/tell to make things fancier. Of 
course this will require perl 5.8 compiled with perlio.

If you have that in place, you need no slurp. You do 'local $/ + read' and you 
get slurp. Or may be it's too much work when implementing slurp should be a 
few lines of C code ;)

__
Stas BekmanJAm_pH --> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html