Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: getting sometimes empty cgi form with post

by almut (Canon)
on Mar 07, 2010 at 16:30 UTC ( #827249=note: print w/replies, xml ) Need Help??


in reply to getting sometimes empty cgi form with post

Don't know what the problem is... so just two suggestions that might help to narrow down on the issue:

  • Check if you can actually read the raw query string from STDIN (before instantiating the CGI object), like this

    if ($ENV{REQUEST_METHOD} eq 'POST') { my $n = read STDIN, my $query, $ENV{CONTENT_LENGTH}; warn $! unless defined $n; # (-> check error_log) # ... check $query }

    (just for debugging purposes, of course — handling query strings yourself is generally considered a no no :)

  • Try CGI::Simple instead of CGI.pm.  It's more or less a drop-in replacement, as long as you stick to the OO style usage.

Those tests might help to figure out whether it's maybe an obscure bug with the CGI module (not entirely impossible), or if it's that the socket (or the pipe from apache to the CGI process) is being closed prematurely for whatever reason, or some such.

Replies are listed 'Best First'.
Re^2: getting sometimes empty cgi form with post
by david2008 (Scribe) on Mar 08, 2010 at 08:49 UTC
    Hi Almut, Thanks for your reply.
    It really helped me a lot.

    What is interesting that when the problem occurs i read 0 bytes and when i switched to cgi::simple it gave the following error with the cgi_error function. "500 Bad read on POST! wanted 135, got 0 at ...".

    Now i have just to find out why this happens :-).
    Thanks, David
      Now i have just to find out why this happens

      You could try strace (facetiously aka "Almut's Golden Hammer" at the place I work... — yes, I do tend to slightly overuse it, but it has definitely helped me numerous times to solve problems within minutes, that other people before had messed around with for hours or days ;)

      This might help to debug how/if the query string is handled apache-internally, and where exactly the error occurs that leads to it being dropped. At least if the problem is replicable enough that you won't have to wait thousands of requests for it to occur. To ease debugging, you might want to start up apache in single process mode (option -X). Also, don't forget to trace forked processes (the CGI script) as well (option -f).

        Thanks.
        I found an interesting issue that when changing the method to get, the problem nearly disappears.
        Maybe this fact could help to narrow down the problem.
        Thanks.

        I tried wireshark already and also httpfox on the client side. I see the request going out from the client. The problem is the server

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://827249]
help
Chatterbox?
[Eily]: The best example of that is the TGV, they couldn't decide who would get it so it's in the middle of nowhere halfway between the two
[LanX]: Eily: that rings a bell
[erix]: interesting difference, I suppose they use different data/routes (and shorter seems better, no?)
[LanX]: Montabaur station
[erix]: (I used http://afstandmete n.nl/ )
LanX The stations of Limburg Süd and Montabaur, which are approximately 20 km apart, ...
[LanX]: teh route I get from gmaps is 1662 km long and is crossing the Swiss Alps (mounting 2400 m) ... I wouldn't try this in December...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (12)
As of 2017-12-13 15:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (369 votes). Check out past polls.

    Notices?