Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Unable to read data... in CGI.pm

Quote Reply
Unable to read data... in CGI.pm
Alex, GT staff, programming experts,

I see such errors daily in my error logs:
Quote:
GT::CGI::MultiPart (3826): Unable to read data from server.
Still have 166658 bytes to read, but got 0. Data in buffer is: at path_to/MultiPart.pm line 139.

I use GT::CGI and Links modules in my custom application for upload & input management. I do NOT run under mod_perl.
I use the GT library from LSQL v3.0.3, where module versions are: GT::CGI version is v1.144, GT::CGI::MultiPart v1.5, Links v1.197.

I thought, the way I used GT::CGI and Links modules is wrong, so I checked again, and removed all things, which could cause interferences. But nothing. It continues to produce such errors.


I do load the libraries in CGI mode (NO mod_perl, NO persistent environment), in following order:
Quote:
use GT::CGI;
use GT::Session::File; # must be loaded in conf_system.cfg, because session dir is set here
use GT::Template;
use GT::File::Tools qw(rmkdir move);
use GT::Date qw/date_set_format format_date date_transform date_get/;
use CGI qw/:standard/;
$CGI::POST_MAX= 1024 * 5000; # max 5 Mb posts allowed to avoid Denial of Service Attacks
use CGI::Cookie;

use Links qw/$IN $CFG/;
Links::init($db_lib_path);


  • Did I something wrong with load order?
  • Is there a compatibility conflict between GT::CGI and CGI.pm when loading both?
  • I will try to move the Links load right after GT::CGI load, hoping that it will fix that problem.


    I would appreciate any ideas, suggestions, regarding this problem.

    Thanks!

    Best regards,
    Webmaster33


    Paid Support
    from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
    Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
  • Quote Reply
    Re: [webmaster33] Unable to read data... in CGI.pm In reply to
    Hi,

    The problem happens because of the reason you cited: there is a problem attempting to use CGI and GT::CGI. Specifically, each of them makes an attempt to read from STDIN, which is where the body (i.e. data) of a POST request comes from - but after either one of these reads this data, the data is gone, meaning the other module cannot get at it. In theory, GET requests should be accessible by both modules at once due to the way GET data is passed, but POST data cannot be.

    If you are using CGI for the purposes of CGI::Session, after a brief read through the documentation it appears CGI::Session should be able to use a GT::CGI object as GT::CGI's parameter interface is mostly the same as that of CGI.pm; CGI::Session appears to only need the param() and cookie() methods, both of which are compatible between GT::CGI and CGI.

    Jason Rhinelander
    Gossamer Threads
    jason@gossamer-threads.com
    Quote Reply
    Re: [Jagerman] Unable to read data... in CGI.pm In reply to
    Well, that's why I moved
    use GT::CGI;
    before
    use CGI qw/:standard/;

    I theory that load order change is enough, as GT::CGI reads the STDIN first, so gets the POST input. And upload _works_ in most cases. There are just RARE cases, where I get that strange error. Unfortunately until that moment, I was not able to track down, what circumstances leads to the error. I was not even able to reproduce that upload error manually.

    I used CGI mainly for upload tasks, but due to some compatibility problems, I had to move to GT::CGI usage. I preferred CGI over GT::CGI, as it provided more info methods about uploaded file.
    I use GT::Session::File for session tasks, and only CGI::Cookie is related to the CGI module. I could move to GT::CGI cookie handling, that's just a matter of decision and some free time.

    I don't remember at the moment (I'm now busy with my studies, and doing just bugfix on my online site), if there is any core CGI usage left in the code, but I think I can take out the CGI usage. Until the time I can check it in details, I will try to move the Links load before CGI load, hoping that this will solve compatibility problems.


    BTW: do you know that array input results are reversed in the input read process?
    This should be fixed, IMHO.

    Best regards,
    Webmaster33


    Paid Support
    from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
    Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...