Loading ...
Sorry, an error occurred while loading the content.

Binary files corrupted when fetched through Connection Manager

Expand Messages
  • Joe
    Hi, I m curious about an issue I noticed while playing with the Connection Manager: I can retrieve text files just fine, but, for some reason, binary files get
    Message 1 of 1 , Apr 2, 2006
    • 0 Attachment
      Hi,

      I'm curious about an issue I noticed while playing with the Connection
      Manager: I can retrieve text files just fine, but, for some reason,
      binary files get corrupted along the way.

      I'm using version 0.9.0 of the connection library with Firefox 1.5.0.1
      on Debian Linux.

      Here's an example:

      <html> <head>
      <title>xytest</title>

      <script src = "http://barillari.org/~jdb/hari/yahoo/build/YAHOO.js" ></script>
      <script src = "http://barillari.org/~jdb/hari/yahoo/build/connection.js" ></script>
      <script src = "http://barillari.org/~jdb/md5.js" ></script>

      <script language="javascript">
      function handleSuccess(o) {
      document.write(hex_md5(o.responseText));
      document.close();
      }

      function handleFailure(o){
      document.write('fail');
      }

      var callback =
      {
      success: handleSuccess ,
      failure: handleFailure,
      scope: this
      }

      var cObj = YAHOO.util.Connect.asyncRequest('GET', url ,callback,null);

      </script>

      </head>
      <body></body> </html>

      I'm using a md5 hash library from http://pajhome.org.uk/crypt/md5 to
      compare the files fetched through the connection manager with the files on the disk.

      If _url_ points to a text file, the md5sum of the fetched file matches
      the md5sum of the local file.

      http://barillari.org/robots.txt
      Fetched: hash a1579af276a7303213fd32cb6d64f0d9, size 652
      On disk: hash a1579af276a7303213fd32cb6d64f0d9, size 652

      But if _url_ points to a binary file (I tried it with a png image),
      the result is wrong. And it's not just a bug in the md5 library -- the
      *sizes* of the files don't match.

      http://barillari.org/images/thesis-colons.png
      Fetched: hash a7b3be6c4687831f4867497fb3f1010d, size 1374
      On disk: hash 6d0953c65f7d2aeb6a4829860ba8a34e, size 1468

      All of these URLs are live, if you'd like to try this for yourself.
      http://barillari.org/~jdb/ytest/yahoo/test-png.html gives the results for the png,
      http://barillari.org/~jdb/ytest/yahoo/test-txt.html gives the results for the text file.

      Any insight into the problem would be much appreciated.

      Thanks in advance!

      Joe Barillari
    Your message has been successfully submitted and would be delivered to recipients shortly.