cvs commit: modperl-2.0/lib/Apache Status.pm

2003-01-25 Thread stas
stas2003/01/25 05:26:11

  Added:   lib/Apache Status.pm
  Log:
  started porting Apache::Status to 2.0:
  - adjust style
  - use mod_perl 2.0 api (trying to get away from using compat.pm)
  - adjust the 'registry scripts' logic to work with the new registry cache
  (present scripts by the handler they are compiled in)
  
  Revision  ChangesPath
  1.1  modperl-2.0/lib/Apache/Status.pm
  
  Index: Status.pm
  ===
  package Apache::Status;
  
  use strict;
  #use warnings; #XXX FATAL = 'all'; 
  no warnings; # 'redefine';
  
  # XXX: something is wrong with bleadperl, it warns about redefine
  # warnings, when no warnings 'redefine' is set (test with 5.8.0). even
  # when used with 'no warnings' it still barks on redefinining the
  # constants
  
  
  
  # XXX
  # use mod_perl 2.0;
  
  use Apache::RequestRec ();
  use Apache::RequestUtil ();
  use Apache::ServerUtil ();
  
  $Apache::Status::VERSION = '3.00'; # mod_perl 2.0
  
  use constant IS_WIN32 = ($^O eq MSWin32);
  my $Is_Win32 = ($^O eq MSWin32);
  
  my %is_installed = ();
  {
  local $SIG{__DIE__};
  %is_installed = map {
$_, (eval(require $_) || 0);
  } qw (Data::Dumper Devel::Symdump B Apache::Request 
  Apache::Peek Apache::Symbol);
  }
  
  our $newQ;
  
  if ($is_installed{Apache::Request}) {
  $newQ ||= sub { Apache::Request-new(@_) };
  }
  else {
  $is_installed{CGI} = eval(require CGI) || 0;
  $newQ ||= sub { CGI-new; };
  }
  
  my $CPAN_base = http://cpan.org/modules/by-module/;;
  
  my $install_symdump = EOF;
  Please install the a href=$CPAN_base/Devel/Devel::Symdump/a module.
  EOF
  
  my %status = (
  script= PerlRequire'd Files,
  inc   = Loaded Modules,
  rgysubs   = Compiled Registry Scripts,
  'symdump' = Symbol Table Dump,
  inh_tree  = Inheritance Tree,
  isa_tree  = ISA Tree,  
  env   = Environment,
  sig   = Signal Handlers,
  myconfig  = Perl Configuration,
  hooks = Enabled mod_perl Hooks,
  );
  
  delete $status{'hooks'} if $mod_perl::VERSION = 1.9901;
  delete $status{'sig'} if IS_WIN32;
  
  # XXX: needs porting
  if ($Apache::Server::SaveConfig) {
  $status{section_config} = Perl Section Configuration;
  }
  
  sub menu_item {
  my($self, $key, $val, $sub) = @_;
  $status{$key} = $val;
  no strict;
  *{status_${key}} = $sub if $sub and ref $sub eq 'CODE';
  }
  
  sub handler {
  my($r) = @_;
  Apache-request($r); #for Apache::CGI
  my $qs = $r-args || ;
  my $sub = status_$qs;
  no strict 'refs';
  
  if ($qs =~ s/^(noh_\w+).*/$1/) {
return {$qs}($r, $newQ-($r));
  }
  
  header($r);
  if (defined $sub) {
$r-print(@{ {$sub}($r, $newQ-($r)) });
  }
  elsif ($qs and %{$qs.::}) {
$r-print(symdump($r, $newQ-($r), $qs));
  }
  else {
my $uri = $r-uri;
$r-print(
map { qq[a href=$uri?$_$status{$_}/abr\n] } keys %status
  );
  }
  $r-print(/body/html);
  
  1;
  }
  
  sub header {
  my $r = shift;
  my $start = scalar localtime $^T;
  my $srv = Apache::get_server_version();
  $r-content_type(text/html);
  my $v = $^V ? sprintf v%vd, $^V : $];
  $r-print(EOF);
  html
  headtitleApache::Status/title/head
  body
  Embedded Perl version b$v/b for b$srv/b process b$$/b, 
  br running since $starthr
  EOF
  
  }
  
  sub symdump {
  my($r, $q, $package) = @_;
  
  return $install_symdump unless $is_installed{Devel::Symdump};
  
  my $meth = new;
  $meth = rnew if lc($r-dir_config(StatusRdump)) eq on;
  my $sob = Devel::Symdump-$meth($package);
  return $sob-Apache::Status::as_HTML($package, $r, $q);
  }
  
  sub status_symdump {
  my($r, $q) = @_;
  [symdump($r, $q, 'main')];
  }
  
  sub status_section_config {
  my($r, $q) = @_;
  require Apache::PerlSections;
  [pre, Apache::PerlSections-dump, /pre];
  }
  
  sub status_hooks {
  my($r, $q) = @_;
  # XXX: hooks list access doesn't exist yet in 2.0
  require mod_perl;
  require mod_perl_hooks;
  my @retval = qw(table);
  my @list = mod_perl::hooks();
  for my $hook (sort @list) {
my $on_off = 
  mod_perl::hook($hook) ? bEnabled/b : iDisabled/i;
push @retval, trtd$hook/tdtd$on_off/td/tr\n;
  }
  push @retval, qw(/table);
  \@retval;
  }
  
  sub status_inc {
  my($r, $q) = @_;
  
  my $uri = $r-uri;
  my @retval = (
  table border=1,
  tr, 
  (map tdb$_/b/td, qw(Package Version Modified File)),
  /tr\n
  );
  
  foreach my $file (sort keys %INC) {
local $^W = 0;
next if $file =~ m:^/:;
next unless $file =~ m:\.pm:;
next unless $INC{$file}; #e.g. fake Apache/TieHandle.pm
  
no strict 'refs';
(my $module = $file) =~ 

MP2 and Databases

2003-01-25 Thread Philip M. Gollucci
What is the status of DBI, Apache::DBI and mod_perl-1.99_09-dev, 
 and Apache 2.1.0-dev ?

I saw Ask released .89 a few weeks ago to CPAN.  I just installed it, but 
I'm getting errors when trying to load it in the startup.pl


[Sat Jan 25 03:15:26 2003] [error] Can't locate Apache.pm in @INC (@INC 
contains: 
/home/philip/Developement/install/perl/lib/site_perl/5.9.0/i386-freebsd/Apache2 
/home/philip/Developement/install/perl/lib/5.9.0/i386-freebsd 
/home/philip/Developement/install/perl/lib/5.9.0 
/home/philip/Developement/install/perl/lib/site_perl/5.9.0/i386-freebsd 
/home/philip/Developement/install/perl/lib/site_perl/5.9.0 
/home/philip/Developement/install/perl/lib/site_perl .) at 
/home/philip/Developement/install/perl/lib/site_perl/5.9.0/i386-freebsd/Apache/DBI.pm 
line 3.
BEGIN failed--compilation aborted at 
/home/philip/Developement/install/perl/lib/site_perl/5.9.0/i386-freebsd/Apache/DBI.pm 
line 3.
Compilation failed in require at 
/home/philip/Developement/install/apache2-prefork/conf/startup.pl line 26.
BEGIN failed--compilation aborted at 
/home/philip/Developement/install/apache2-prefork/conf/startup.pl line 26.
Compilation failed in require at (eval 1) line 1.

[Sat Jan 25 03:15:26 2003] [error] Can't load Perl file: 
/home/philip/Developement/install/apache2-prefork/conf/startup.pl for s

-- 
END 
-- 
Philip M. Gollucci [EMAIL PROTECTED] 301.474.9294 301.646.3011 (cell) 

Science, Discovery,  the Universe (UMCP) 
Webmaster  Webship Teacher 
URL: http://www.sdu.umd.edu 

eJournalPress 
Database/PERL Programmer  System Admin 
URL : http://www.ejournalpress.com 

Resume : http://p6m7g8.net/Resume 





Re: [MP2] Perl_Tstack_sp_ptr

2003-01-25 Thread Stas Bekman
Xiaodong Shen wrote:

Thanks for the reply.

Several things to clear:

1. I have successfully passed the make  make test  make install 
phase.

2. I have moved into Server configuration phase and was doing the 
mod_perl rocks thingy, where the error happens.

3. Before seeing your reply, I already found a solution: I renamed 
Const.so to Const.so.bak (there are several other xxx.so mod_perl 
complains about, I removed them as well). It works, mod_perl did rock.

4. However this put me into a bigger misery, I can't explain why!!!

After reading the thread, I delved into my setting and found:

- my perl installation doesn't have libperl.so (libperl.a only).

Meaning that you perl is compiled without shared library support.


- my httpd is DSO enabled.
- my mod_perl is mod_perl.so (mod_perl.a is not used).


Currently mod_perl builds itself as static and dynamic, no matter what you 
choose, so at the later point you can simply link the static archive.

- my mod_perl.so is not linked against ibperl.so.


So it must have the perl library linked in. do you have that symbol that was 
reported missing in mod_perl.so? (hint: use 'nm')

So I assume that httpd loads mod_perl.so, which loads other xxx.so, such 
as Const.so, but when does mod_perl load libperl.so (from the thread I 
assume those undefined symbols would be resolved by libperl.so)? before 
laoding Const.so? but why did it not complain about no libperl.so on my 
system?

see above.

I suppose that we have a problem here of installing dynamic .so objects, when 
the static build is used and perl trying to load them. But it's also possible 
that you've the leftovers from an older install as you suggest below.

Now I start to have some ideas, it must have to do with my Perl 
installation, which contains some leftovers that should have been 
cleaned up before I made numerous rebuilds,  everytime Perl uses a 
package it looks for *.so by going through @INC, lots of library files 
with same names.

I will let you after I clean up my perl.

Have you installed mod_perl using the shared libperl.so before into the same 
directory?

__
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



[ MP2] startup problem with XML::LibXML

2003-01-25 Thread pascal barbedor




PROBLEM :
APACHE SEGFAULT WITH XML::LibXML on 
WIN32

I use all in one perl + apache + modperl2 RK 
binaries
but I replace c:\perl\bin\perl58.dll with 
perl58.dll obtained after separately(and succesfully) compiling perl with vc6 
DEBUG so that I get symbols in 
perl58.dll
so the call stack gives line number in source (see 
below)
everything works normally as far as I tried 
prepared scripts in RK distribution, but my test.pm makes an APACHE 
SEGFAULT
when used from startup.pl.

mytest.pm program
---
package mytest;
use warnings;
use XML::LibXML();
use strict;
our 
$test=XML::LibXML-new-parse_string("?xml version='1.0' 
encoding='iso-8859-1' ?doc/doc");
print $test-toString();
1;
-
perl mytest.pm output ok
USE from a regular CGI WORKS
USE from a registry CGI works
USE from a modperl handler (mason) 
works

!!! use test(); from startup.pl output ok BUT 
produces just after apache segfault


thanks 
pascal



REPORT output
SERVER_SOFTWARE: Apache/2.0.43 (Win32) 
mod_perl/1.99_08-dev Perl/v5.8.0 WINXP

windbg output

(590.7b4): Access violation - code c005 (first 
chance)


call stack

perl58!Perl_sv_dup(interpreter* my_perl = 01732e54 
, sv* sstr = 00060006 , clone_params* param = 0006fdf8 )+0xf (CONV: cdecl) 
[..\sv.c @ 9020]
perl58!Perl_sv_dup(interpreter* my_perl = 01732e54 
, sv* sstr = 0006f750 , clone_params* param = 0006fdf8 )+0x1252 (CONV: cdecl) 
[..\sv.c @ 9262]
perl58!Perl_sv_dup(interpreter* my_perl = 01732e54 
, sv* sstr = 0095f00c , clone_params* param = 0006fdf8 )+0xeac (CONV: cdecl) 
[..\sv.c @ 9203]
perl58!Perl_sv_dup(interpreter* my_perl = 01732e54 
, sv* sstr = 00946ae0 , clone_params* param = 0006fdf8 )+0xe3b (CONV: cdecl) 
[..\sv.c @ 9199]
perl58!Perl_sv_dup(interpreter* my_perl = 01732e54 
, sv* sstr = 00946af8 , clone_params* param = 0006fdf8 )+0xe3b (CONV: cdecl) 
[..\sv.c @ 9199]
perl58!Perl_sv_dup(interpreter* my_perl = 01732e54 
, sv* sstr = 00946abc , clone_params* param = 0006fdf8 )+0x14a2 (CONV: cdecl) 
[..\sv.c @ 9283]
perl58!Perl_gp_dup(interpreter* my_perl = 01732e54 
, gp* gp = 009549c4 , clone_params* param = 0006fdf8 )+0x213 (CONV: cdecl) 
[..\sv.c @ 8698]
perl58!Perl_sv_dup(interpreter* my_perl = 01732e54 
, sv* sstr = 0095110c , clone_params* param = 0006fdf8 )+0x8e6 (CONV: cdecl) 
[..\sv.c @ 9142]
perl58!Perl_he_dup(interpreter* my_perl = 01732e54 
, he* e = 0093e3ac , char shared = 0x1 '', clone_params* param = 0006fdf8 
)+0x18e (CONV: cdecl) [..\hv.c @ 118]
perl58!Perl_sv_dup(interpreter* my_perl = 01732e54 
, sv* sstr = 0089ed58 , clone_params* param = 0006fdf8 )+0x10d4 (CONV: cdecl) 
[..\sv.c @ 9233]
perl58!Perl_sv_dup(interpreter* my_perl = 01732e54 
, sv* sstr = 0091fc58 , clone_params* param = 0006fdf8 )+0x88b (CONV: cdecl) 
[..\sv.c @ 9140]
perl58!Perl_sv_dup(interpreter* my_perl = 01732e54 
, sv* sstr = 0091fb64 , clone_params* param = 0006fdf8 )+0xe3b (CONV: cdecl) 
[..\sv.c @ 9199]
perl58!Perl_sv_dup(interpreter* my_perl = 01732e54 
, sv* sstr = 0091fbb0 , clone_params* param = 0006fdf8 )+0xe3b (CONV: cdecl) 
[..\sv.c @ 9199]
perl58!Perl_sv_dup(interpreter* my_perl = 01732e54 
, sv* sstr = 0091fb58 , clone_params* param = 0006fdf8 )+0x14a2 (CONV: cdecl) 
[..\sv.c @ 9283]
perl58!Perl_gp_dup(interpreter* my_perl = 01732e54 
, gp* gp = 009281a4 , clone_params* param = 0006fdf8 )+0x213 (CONV: cdecl) 
[..\sv.c @ 8698]
perl58!Perl_sv_dup(interpreter* my_perl = 01732e54 
, sv* sstr = 0091fbc8 , clone_params* param = 0006fdf8 )+0x8e6 (CONV: cdecl) 
[..\sv.c @ 9142]
perl58!Perl_sv_dup(interpreter* my_perl = 01732e54 
, sv* sstr = 0089a620 , clone_params* param = 0006fdf8 )+0xe3b (CONV: cdecl) 
[..\sv.c @ 9199]
perl58!Perl_sv_dup(interpreter* my_perl = 01732e54 
, sv* sstr = 0089a6a4 , clone_params* param = 0006fdf8 )+0xe3b (CONV: cdecl) 
[..\sv.c @ 9199]
perl58!Perl_sv_dup(interpreter* my_perl = 01732e54 
, sv* sstr = 0089a62c , clone_params* param = 0006fdf8 )+0x14a2 (CONV: cdecl) 
[..\sv.c @ 9283]
perl58!Perl_gp_dup(interpreter* my_perl = 01732e54 
, gp* gp = 009872f4 , clone_params* param = 0006fdf8 )+0x213 (CONV: cdecl) 
[..\sv.c @ 8698]



vc6 debug output

unhandled exception in apache.exe (mscvrt.dll) 
access violation c005 


call stack 

MSVCRT! 77c42fc4()
Perl_savepvn(interpreter * 0x016172cc, const char * 
0x008b846c, long 23281824) line 926 + 17 bytes
Perl_mg_dup(interpreter * 0x016172cc, magic * 
0x01629f80, clone_params * 0x0006fdf8) line 8755 + 32 bytes
Perl_sv_dup(interpreter * 0x016172cc, sv * 
0x0006f750, clone_params * 0x0006fdf8) line 9261 + 22 bytes
Perl_sv_dup(interpreter * 0x016172cc, sv * 
0x0094920c, clone_params * 0x0006fdf8) line 9203 + 34 bytes
Perl_sv_dup(interpreter * 0x016172cc, sv * 
0x00933630, clone_params * 0x0006fdf8) line 9199 + 34 bytes
Perl_sv_dup(interpreter * 0x016172cc, sv * 
0x00933648, clone_params * 0x0006fdf8) line 9199 + 34 bytes
Perl_sv_dup(interpreter * 0x016172cc, sv * 
0x0093360c, clone_params * 0x0006fdf8) line 9283 + 22 bytes

Re: PerlSwitches -M and @INC

2003-01-25 Thread Stas Bekman
Dr. Helmut Zeilinger wrote:

I tried:

  PerlOptions +Parent
#  PerlOptions +Clone


  PerlModule  Apache2
  PerlModule Apache::compat
  PerlSwitches -Mlib=/et/www/envirotex/lib

The result is a Segmentation fault without any further messages on the 
screen and in the error_log file.

I can't reproduce it. Please send in the backtrace from the core file and the 
rest of the details. See:
http://perl.apache.org/docs/2.0/user/help/help.html#Reporting_Problems

When I try:

#   PerlOptions +Parent
  PerlOptions +Clone


  PerlModule  Apache2
  PerlModule Apache::compat
  PerlSwitches -Mlib=/et/www/envirotex/lib


If you use the +Clone, it already inherits everything from the parent, 
including @INC. So you don't need the last 3 lines. It works just fine for me 
with 'PerlOptions +Clone'.

Perhaps you can send in your httpd.conf after you have reduced it to the very 
minimum (including the minimal startup.pl that still reproduces the problem)

the result is:

[Thu Jan 23 09:12:19 2003] [error] Can't locate 
Emma/AuthCookieHandler.pm in @INC (@INC contains: 
/usr/lib/perl5/site_perl/5.8.0/i686-linux-thread-multi/Apache2 
/usr/lib/perl5/5.8.0/i686-linux-thread-multi /usr/lib/perl5/5.8.0 
/usr/lib/perl5/site_perl/5.8.0/i686-linux-thread-multi 
/usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl/5.6.1 
/usr/lib/perl5/site_perl .) at (eval 5) line 3.

[Thu Jan 23 09:12:19 2003] [error] Can't load Perl module 
Emma::AuthCookieHandler for server www.et:0, exiting...

The Module Emma::AuthCookieHandler is in the path 
/et/www/envirotex/lib. As i see from the message above the additional 
lib path is missing from the @INC Array.


__
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




Perl interface to the Apache server API

2003-01-25 Thread Paul Dyer
Hi,

Does anyone know if this interface has been abandoned in verion 2.0??   
At perl.apache.org/docs/1.0/api/index.html, there is documentation for 
the 1.0 API.  Not only is the documentation missing in 2.0, but it 
appears to not have be included??

Please let me know what is expected of 2.0 as it relates to the Perl 
interface.

Thanks,

Paul



data loss when using $r-get_client_block mod_perl 1.99_08

2003-01-25 Thread Udo Rader
hi,

I see that the new version of mod_perl has $r-read fixed now to read
exactly the given bytes.

$r-get_client_block however is still buggy. If for example I do the
following:

CUT
my $len = $r-headers_in-{'content-length'};
print reported length is $lenbr;

my $buf;
$r-get_client_block( $buf, $len );
print read length is: .length($buf).br;
CUT

... then I get extremely different values for the reported and the read
length.

This does _not_ happen on small amounts of data, I think the threshold is
somewhere near 7K of data pending to be read.

The example works perfect, if I use $r-read instead, so I am quite happy
with 1.99_08 ;-)

udo



do as temp solution for require problem ?

2003-01-25 Thread [EMAIL PROTECTED]
Hi,

I think mod_perl is wonderful but unfortunately enough the require 
function does not work as it does in CGI.
Is using the function do the only workaround  as temporary solution 
till this problem is fixed in a/the next mod_perl version?

Cheers,

Bart



Re: Perl interface to the Apache server API

2003-01-25 Thread Leon Brocard
Paul Dyer sent the following bits through the ether:

 Does anyone know if this interface has been abandoned in verion 2.0??   

You appear to have completely ignored the Apache 2 part of the website:
http://perl.apache.org/docs/2.0/

Leon
-- 
Leon Brocard.http://www.astray.com/
scribot.http://www.scribot.com/

... Wayne Campbell: Exsqueeze me? A baking-powder?



Re: [ MP2] startup problem with XML::LibXML

2003-01-25 Thread pascal barbedor
it is version 1.54

pascal


- Original Message - 
From: Matt Sergeant [EMAIL PROTECTED]
To: pascal barbedor [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Saturday, January 25, 2003 8:00 PM
Subject: Re: [ MP2] startup problem with XML::LibXML


On Saturday, Jan 25, 2003, at 09:49 Europe/London, pascal barbedor 
wrote:

 
 PROBLEM :
 APACHE SEGFAULT WITH XML::LibXML on WIN32

What version of XML::LibXML? Try version 1.52, not 1.53 which is very 
buggy.

Matt.





Mod_Perl and Cpanel....

2003-01-25 Thread Richard



our machines all run Cpanel, does anyone have any 
experience running Cpanel WITH mod_perl installed, and it 
run well?

I have heard that Cpanel and mod_perl will conflict 
with each other.
So I don't want to install mod_perl without being 
sure it will not crash our servers.

I'd appreciate some foresight on this.

Thanks,
Richard.



Re: [OT] MLDBM size limit?? :'(

2003-01-25 Thread Stas Bekman
Jim Morrison wrote:

Guys,

Sorry this is a little off topic...  Is there a size limit on DBM's? (Or
Linux files for that matter.. )

I've thrown some details of my box/code below..

Thing is I'm getting a write error and it seems to always happen when
the DBM gets to 2.0Gb .. (you may think I'm mad for trying to make 2G
DBM's - but they don't usually get more than a couple of 100k - it's
just a big site.. Honest ;-)


You need to have Perl built with largefiles support to work with files larger 
than 2GB. Do:
./Configure -Duselargefiles [...]  make install
(check if you don't have it already via 'perl -V|grep uselargefiles')
and afterwards you need to rebuild mod_perl so it'll pick the new compile 
flags. You may need to have Apache compiled with largefiles support as well, 
which normally happens automatically if your fs/os supports it. Or it can be 
forced with:
% CFLAGS=D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 ./configure [...]

__
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



Re: do as temp solution for require problem ?

2003-01-25 Thread Stas Bekman
[EMAIL PROTECTED] wrote:

Hi,

I think mod_perl is wonderful but unfortunately enough the require 
function does not work as it does in CGI.
Is using the function do the only workaround  as temporary solution 
till this problem is fixed in a/the next mod_perl version?

Have you read:
http://perl.apache.org/docs/1.0/guide/porting.html#Name_collisions_with_Modules_and_libs
?

If you are referring to a different problem, what mod_perl version are you 
talking about?

__
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



Re: data loss when using $r-get_client_block mod_perl 1.99_08

2003-01-25 Thread Stas Bekman
Udo Rader wrote:

hi,

I see that the new version of mod_perl has $r-read fixed now to read
exactly the given bytes.

$r-get_client_block however is still buggy. If for example I do the
following:

CUT
my $len = $r-headers_in-{'content-length'};
print reported length is $lenbr;

my $buf;
$r-get_client_block( $buf, $len );
print read length is: .length($buf).br;
CUT

... then I get extremely different values for the reported and the read
length.

This does _not_ happen on small amounts of data, I think the threshold is
somewhere near 7K of data pending to be read.

The example works perfect, if I use $r-read instead, so I am quite happy
with 1.99_08 ;-)


Because get_client_block must be called in a loop. That's how Apache 
implements it:

/* get_client_block is called in a loop to get the request message body.
 * This is quite simple if the client includes a content-length
 * (the normal case), but gets messy if the body is chunked. Note that
 * r-remaining is used to maintain state across calls and that
 * r-read_length is the total number of bytes given to the caller
 * across all invocations.  It is messy because we have to be careful not
 * to read past the data provided by the client, since these reads block.
 * Returns 0 on End-of-body, -1 on error or premature chunk end.
 *
 */

Here is an example we use in the test suite to read the the request body:

sub ModPerl::Test::read_post {
my $r = shift;

$r-setup_client_block;

return undef unless $r-should_client_block;

my $data = '';
my $buf;
while (my $read_len = $r-get_client_block($buf, IOBUFSIZE)) {
if ($read_len == -1) {
die some error while reading with get_client_block;
}
$data .= $buf;
}

return $data;
}


__
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