kostis has asked for the wisdom of the Perl Monks concerning the following question:

Yo fellow mod_perlers.
I've ran across a weird problem.


I'm writing a light replacement to CGI... when the request is a multipart POST I think you're supposed to get the data from the client by calling $r->read($buffer,$size) right? (Where $r is an Apache->request)

The problem is that in the last read when the $size is larger than what is leftover, $r rather than putting the last chunk of data in the $buffer just returns it empty. :-(

Therefore the only way I've gotten the thing to work properly has been to specify a $size of 1 byte. (not exactly efficient but I was just fooling around to get closer to a solution)

Does anyone know what's going wrong?
Shouldn't read behave the way I expect it?

I'm using mod_perl-1.26

Thanks, Kostis

Replies are listed 'Best First'.
Re: mod_perl headache
by Juerd (Abbot) on Jun 13, 2002 at 20:57 UTC

    calling $r->read($buffer,$size) right? (Where $r is an Apache->request)

    with $size being $r->header_in('Content-Length'). You can slurp the entire body by using $r->contents in scalar context.

    - Yes, I reinvent wheels.
    - Spam: Visit eurotraQ.
    

Re: mod_perl headache
by Kanji (Parson) on Jun 13, 2002 at 22:08 UTC
    I'm writing a light replacement to CGI...

    Not sure how "lite" you want to get, but have you taken a look at Apache::Request (alt.)?

        --k.


Re: mod_perl headache
by BigJoe (Curate) on Jun 14, 2002 at 12:28 UTC
    Take a Look at CGI::Lite

    If you really wanted to enhance it or strip it down it would probably be an easier job to re-use old code for what you need.

    --BigJoe

    Learn patience, you must.
    Young PerlMonk, craves Not these things.
    Use the source Luke.