in reply to Mod CGI problems with POST

The problem is that you're creating two CGI objects:

my $q = new CGI; ... q = new CGI;

Only the first one can read the POST body from STDIN. When the second one tries to read it, the stream is gone, and you've overwritten the original object, so the data is gone too.

Replies are listed 'Best First'.
Re^2: Mod CGI problems with POST
by cormanaz (Deacon) on May 31, 2007 at 01:20 UTC
    Good catch, but I removed the second one and the problem persists.

      Oh, right. I overlooked HTTP::Daemon. The problem now is that CGI expects to read from STDIN, but you have another filehandle from which you want to read. I sent Lincoln a patch a long, long time ago to pass in a filehandle from which CGI should read, but I don't know if he ever applied it.

      I remember doing something similar with CGI::Simple instead.

        Do you remember what that filehandle is? Also, it's not clear from the docus how you pass a filehandle to CGI or CGI::Simple if you know what it is. Or is that what your patch was for?

        Anyway I suppose if I knew the filehandle I could just read and parse it manually and skip CGI.

        UPDATE: I take it back: CGI::Simple Docs say "If you provide a file handle to the new() method, it will read parameters from the file (or STDIN, or whatever)." But I still need to know the filehandle.