Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Blank HTTP POST request, if script has another module in it.

by msinfo (Sexton)
on Feb 16, 2014 at 16:48 UTC ( #1075097=perlquestion: print w/ replies, xml ) Need Help??
msinfo has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I am not able to get form variables (using POST request), when my called script (validate.pl) has below lines in it.

# how do i use relative name path use lib 'D:\\Websiste\\One\cgi-bin'; use myModule;

myModule has general HTML content generating sub routines in it.

I am not able to understand, how inclusion of above module affects reading of POST data.

Also, if I put code of validate.pl in myModule, it again show blank POST data.

If I remove, above lines, or put validate.pl code out of myModule, it behaves normally.

Regards,

Comment on Blank HTTP POST request, if script has another module in it.
Download Code
Re: Blank HTTP POST request, if script has another module in it.
by moritz (Cardinal) on Feb 16, 2014 at 17:28 UTC
Re: Blank HTTP POST request, if script has another module in it.
by ww (Bishop) on Feb 16, 2014 at 17:44 UTC

    Here's a WAG-load of possible issues, because you haven't given us (well, me anyway, to be sure I understand your problem (more on this, below).

    • Is myModule stored in "D:\Website\One\cgi-bin\" or stored in your site lib or similar?

      Is "Websiste" a typo?
      Why are the first two path elements preceded by a double back-shash whereas the third element has only a single backslash?
      And what happens if you add a trailing backslash(after "cgi-bin")?

    • Are you relying on myModule to process the params received from a conventional cgi-script? If not, what is doing the processing?
    • Probably irrelevant, but you are showing us a Win32 location which begs that I ask -- Apache? IIS? something else?
    • Are you getting any kind of error messages or warnings, with any of your variations?
      And what does your log (server log) have that might help id the problem? If so, we'll offer much better help if you quote them, verbatim.

    Re shortage of detail about your problem, numerous FAQS on how to ask a question explain what kind of info we need (including that noted above). Please read On asking for help, How do I post a question effectively? and I know what I mean. Why don't you?.

    Come, let us reason together: Spirit of the Monastery
      Hi Monks,

      Per error log, I have problem with myModule.pm

      # code of myModule use strict; use warnings; use diagnostics; package myModule; # sub routine one for generating HTML content # sub routine two for generating HTML content # sub routine third for database content # some of its code # database disconnection $dbh->disconnect; 1;

      This is apache error log

      This is apache error log:[Sun Feb 16 23:16:59 2014] [error] [client 12 +7.0.0.1] [Sun Feb 16 23:16:59 2014] validate.pl: DBI::db=HASH(0x164d9 +fc)->disconnect invalidates 1 active statement handle (either destroy + statement handles or call finish on them before disconnecting) at D: +\\websites\\One\\cgi-bin/Epanvel.pm line 466., referer: http://localh +ost/cgi-bin/validate.pl

      myModule is stored in D:\\websites\\One\\cgi-bin (D:\websites\One\cgi-bin). Dynamically using package myModule through use command.

      Yes, Webssite was a typo, but my intention was to present problem, in general way

      No, errors, but just blank POST request data.

      myModule may or may not have function to process, HTTP requests.

      Regards

        ... myModule may or may not have function to process, HTTP requests.

        Great, good luck with that :)

Re: Blank HTTP POST request, if script has another module in it. (CGI.pm)
by Anonymous Monk on Feb 16, 2014 at 20:00 UTC
    Its simple, myModule has code in it which does more than define general HTML content generating sub routines in it it reads all the POST data and makes it unavailable to your main program

    One way this could happen is using  my $q = CGI->new; instead of  my $q = CGI->new( { } );

    First version will consume POST data the second one won't

      Oops! I replied, to your first post, without reading, this one.

      Testing, what you have said, and would communicate back results. Thanks for giving pointer.

      Hi Anonymous Monk,

      You said

      my $q = CGI->new; instead of my $q = CGI->new( { } );
      and
      . . . reads all the POST data and makes it unavailable to your main pr +ogram

      Yes both, cases were true. I changed them and now everything is working fine. Just to confirm whether I am following good coding practice or not, below are my few doubts on same line.

      1. myModule has following code in its new sub routine, does it has any flaws:
        sub new { bless {}, shift }
      2. How do I use relative name scheme? (instead, of using : use lib 'D:\\Websiste\\One\cgi-bin';) I tried earlier, but it failed. Normal CGI scripts and myModule are in same directory.
      3. In myModule, I was using my $session = CGI::Session->load or die CGI::Session->errstr; at global scope to check sessions, before generating HTML contents. Now after your suggestion, I moved same code in each sub routine. But this duplicates code, and I have to write it in, every sub routine. Is there any work around for same. Or all session handling code should be put into different sub routine.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1075097]
Approved by philipbailey
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-07-30 12:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (231 votes), past polls