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

After upgrading to Apache2 with modperl2 I have found that a CGI script I have used without any trouble for years intermittently loses the POST data.

The sometimes takes 10 minutes of using the script to get the anomaly, I say anomaly as there is no error messages in the Web server log and the perl script executes without error simply outputting the login screen as no POST data gets through, refreshing the browser once or twice will result in the POST data making it to the script as it should have done in the first place.

After allot of googling there seems to be a quite few 'missing POST data' results, some are related to older CGI.pm modules, however I have the very latest CGI.pm 3.20 , installed to try and fix the problem with no luck, other results vaguely mentioned CGI.pm and modperl2 not playing nicely like this article

http://aspn.activestate.com/ASPN/Mail/Message/modperl/1871810

which says "something is funky with the way that CGI.pm is initialising itself under mod_perl" which isnt much help.

There seems to be no answer or fix for this. I run Debian Stable, Apache 2, Modperl2 (not 1.99*) and the script is CGI not mod_perl

Hopefully one of the wise monks can help me out otherwise I am going to have to downgrade my server and/or rewite allot of code.

Replies are listed 'Best First'.
Re: Intermittent empty POST
by shmem (Chancellor) on Jul 16, 2006 at 11:06 UTC
    The article behind the URL you posted mentions Apache::Request as a solution. Tried that one? I'm not familiar with mod_perl, but I suspect the CGI object not being properly initialized along with Connection: keepalive. I'd try setting the Connection: close header in your CGI script.

    Another debugging aid would be sniffing on the network level with a tool like ethereal to see what's really getting transmitted. Can't help more in debugging since you didn't post code...

    You might want to try fastcgi and CGI::Fast, which I definitely prefer over mod_perl, because the latter meddles too much with apache's internals, and fastcgi provides for a clean separation between apache and perl.

    Hope that helps,
    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      mod_perl doesn't meddle with the apache internals, it hooks into the apache internals

      'meddle' has a negative connotation. it makes it sound like mp needs to do meddle with apache to get things done, when mod_perl was designed to let people script apache in perl,

      in any event, chances are you're missing post data, because of some sort of variable declaration issue. since mp is persistant, vars you create in one server request will still hang around on the next response -- unless you properly scope and delcare them

      first thing with mod_perl is to make sure you have no issues with use strict and use warnings
      Thanks for the suggestions, I will try that, I managed to duplicate the error an ubuntu machine I develop on so can test out your suggestion. I never posted code as there are no errors showing so I have no idea what if any of my code is at fault - the error also only started happening since upgrading to Apache2/mod_perl2. I rewrote the mod_perl portions of code to be cgi and removed mod_perl2 and all works well. I will post a followup here when I get to the bottom of it.
Re: Intermittent empty POST
by Anonymous Monk on Jul 17, 2006 at 15:27 UTC
    We had a similar (though not the exact) problem and it turned out to be related to the combination of the browser itself, and the data inside a TEXTAREA field (basically an odd browser bug). In fact, sometimes the SUBMIT button would not even work for some odd reason. So the problem could be on the client, rather than the server (though it does sound like you've narrowed it down to the server). Have you tried analyzing the HTTP conversation? Or using a non-brower (command-line utility) to do the POST-ing repeatedly?

      thanks for the posts, I did resolve the problem by removing mod_perl2, which is a shame as I was starting to get into mod_perl.

      The problem was not with a mod_perl script but a cgi script so there should not be any problem with variable declaration, I only had 1 mod_perl script which worked fine.

      The problem was definately not a browser problem I reproduced the error on 3 platforms and several browsers.

      Since having no more errors since removing mod_perl2 I am leaning towards the "funkyness between CGI.pm and mod_perl" theory from the link in my original post.

      I can reproduce the error on my devlopment machine so will try to figure it out once I have some spare time.