You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Rob Lambden <Ro...@itinsideout.com> on 2003/02/04 23:01:36 UTC

Apache::Request incompatible with CGI ?

(Originally posted as Apache::Registry incompatible with CGI? by mistake
- sorry !)

Hi,

I have written a request handler in Perl. I recently changed some code
in this to convert
from using CGI within mod_perl to using Apache::Request. The old code
was ...

  $DB->{ApacheReq} = shift;
  :
  $DB->{Page} = CGI::new(); 
  :

The new code is ...

  :
  $DB->{ApacheReq}= Apache::Request->new(shift);
  :
  $DB->SetupPageArguments();
  :
  sub SetupPageArguments()
  {
  my ($DB, $nLoop, @Query, $Key, $Value);

  $DB=shift;
  @{$DB->{Page}->{'.parameters'}}=$DB->{ApacheReq}->param();
  for($nLoop=0; $nLoop<=$#{$DB->{Page}->{'.parameters'}}; $nLoop++)
  {
 
if(!defined($DB->{ApacheReq}->param($DB->{Page}->{'.parameters'}[$nLoop]
)))
    {
      $DB->{Page}->{$DB->{Page}->{'.parameters'}[$nLoop]}[0]='';
    }
    else
    {
 
@{$DB->{Page}->{$DB->{Page}->{'.parameters'}[$nLoop]}}=$DB->{ApacheReq}-
>param($DB->{Page}->{'.parameters'}[$nLoop]);
    }
  }
}

My handler then referes to the '.parameters' field and the arrays of
values. For most posts 
this works fine. However, when I send a large block of data in with the
request I have found 
that portions of the middle are left out. Putting the old code back
means that the whole of the 
text is seen.
I am using a client program written in C++ to send the requests in. All
requests are sent as a 
multipart message, with each form field having one part within the
message. On the particular 
instance I have been looking at the overall content size for the request
(excluding the header) 
in my application is set to 21555. (I have not set the flag to limit
post size as you can see 
from the above). The end of the request appears as follows (This request
happens to conatin 
Javascript, but the content should be irrelevant as it has not been
processed by anything at 
this stage) ...

:
:
:
function NewProductExtension(Id, ExtensionId, Description, MinRequired,
MaxRequired, Visible, WarnLessThan, WarnGreaterThan, LessThanWarning,
GreaterThanWarning, Width, Units)\n{\n new ProductExtension(Id,
ExtensionId, Description, MinRequired, MaxRequired, Visible,
WarnLessThan, WarnGreaterTha<*********>ion CheckProductExtensions()
{
var nLoop;
var Rc=new String('');

  for(nLoop=0; nLoop<Products.length; nLoop++)
  {
    if(Products[nLoop].ExtensionCount>Products[nLoop].Extensions.length)
    {
      Rc=Rc+(Products[nLoop].ProductId+',');
    }
  }
  Rc=Rc.substr(0, Rc.length-1);
  return(Rc);
}

where <*********> denotes the portion that is missing (about 100 lines
or so)

I also sometimes see spurious data added after the request.

My server is running linux 2.4.18 on a two-way Intel box. I have Apache
1.3.26 / mod_perl 1.27

I downloaded Apache::Request from CPAN and I have version 0.31. My C
compiler is gcc 2.96

I have not been able to run a LAN trace to see what's being sent, but
since it is OK with CGI.pm I 
assume that I am sending what my client says I'm sending.

Unfortunately I do not understand how the C / Perl and XS files all
stitch together so my attempts 
to look at the code have not been fruitful.

I have adopted some code that works neatly under the Apache::Request but
will have to be fudged to 
work with CGI so I am keen to get this working.

Can anyone help ?

Rob Lambden

Re: Apache::Request incompatible with CGI ?

Posted by dorian <do...@foobarsystems.com>.
> I downloaded Apache::Request from CPAN and I have version 0.31. My C
> compiler is gcc 2.96

aiya. libapreq 0.31 is the one that likes to append whatever it is that
one just uploaded to it to its heap until it starves your machine of memory,
if i recall correctly. it was fixed in 0.31_03 i believe but it looks like 
1.1 was released last week. 

.dorian