Menu

$bRead is always less than $len

2004-05-28
2013-03-27
  • markpmcdowell

    markpmcdowell - 2004-05-28

    On my system, Windows NT 4.0, ActivePerl 5.8 and Lotus Domino Go 4.62 using client Windows XP and browser IE 6.0 the value for $bRead is always less then $len or $ENV{'CONTENT_LENGTH'} with the result that the perl script never exits the loop
    while ($bRead < $len && read (STDIN ,$buffer, 4096)
    any ideas anyone ?

     
    • Centrex

      Centrex - 2004-06-04

      CONTENT_LENGTH is the size of all the form data.  This value should be greater than the sum of all the files.

      Comment line 235 of progress.cgi (unlink "$user_dir/postdata";), then after you upload a file with mega upload, go to the directory where the postdata file is stored.  If you view this in a text editor you will notice it has all the form fields and their data, including the file's data.

      If you delete all the content headers and their data except for one of the files you upload, then save the postdata file to a new file, you'll notice that it is the same size as the file you uploaded.

      The only way I can figure out to calculate the correct content length is to have a javascript function run through all the form elements and count how much data is in them and also count the size of the content headers for them.  You then pass this value along with the other variables in the postIt() form.

      Then when you get the CONTENT_LENGTH in the PERL script, you subtract the value of CONTENT_LENGTH from the javascript function's content length.

      Anyone up to writing this js function?

      -Tom

       
    • Centrex

      Centrex - 2004-06-04

      Since my post, I have created the javascript code to figure out the size of the extra information in the headers to be subtracted.  The code isn;t complete, as I cannot figure out how to caculate the content header seperators so there may be a difference of 20 or so bytes.

      a content header looks like this:
      -----------------------------7d412412a0518

      The random bit at the end varries in length and that is where the size difference comes from.

      I hope this helps.

      You may download the javascript function at: http://www.unifiedent.com/form_size.js

       
    • raditha dissanayake

      The content_length header is supposed to be different from the total file size and that difference has absolutely no   relevence to the behaviour of megaupload.

      The script is measuring the total bytes recieved vs the size specified in the content_length header.

       
      • Centrex

        Centrex - 2004-06-04

        Well, I was having the same problem as markpmcdowell.  10% of the uploads would read 101% and the window would not close.  Also the total size was different from the file size and this code fixed my problem it now works 100% of the time and I tested about 45 uploads.

         
    • raditha dissanayake

      Hi
      alright i will look into it, sorry if my previous mail sounded snappish.

       
    • blackcat99

      blackcat99 - 2005-02-09

      This change to the while loops seems to work:

      .... top is the same ...

      while ( $bRead < $len ) {

        if($bRead + 4096 < $len ) {
          read(STDIN, $LINE, 4096);
        }
        else { read(STDIN, $LINE, $len-$bRead); }

      .... rest is the same ...

       

Log in to post a comment.