You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by John Hawthorne <ha...@cs.ubc.ca> on 1997/11/21 21:56:46 UTC

mod_negotiation/1452: Failure of binary file downloads

>Number:         1452
>Category:       mod_negotiation
>Synopsis:       Failure of binary file downloads
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    apache
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Fri Nov 21 14:10:00 PST 1997
>Last-Modified:
>Originator:     hawthorn@cs.ubc.ca
>Organization:
apache
>Release:        1.3b2
>Environment:
WinNT, Netscape Navigator Gold 3.01
>Description:
I am using the following perl (5.0) code to cause a file to be downloaded
via a CGI script:

    print "Content-Type: application/unknown\n";
    print "Content-Disposition: attachment; filename=$file\n\n";

    open(DOWNLOAD, $file);
    while($bytes = <DOWNLOAD>) {
        print STDOUT $bytes;
    }
    close DOWNLOAD;
  
I have also tried using read() and sysread()/syswrite() versions of the code.
1. Text files lose a character for each CRLF.
2. Binary files abort/fail/finish when they encounter ^Z (ascii 26).
>How-To-Repeat:
Download any file using similar code.  
>Fix:
1. Text files: set DOWNLOAD to binary mode transfer and STDOUT to ascii mode transfer.
   i.e. use "binmode DOWNLOAD;" after the open() command.
2. Binary files: nothing works..
>Audit-Trail:
>Unformatted:
[In order for any reply to be added to the PR database, ]
[you need to include <ap...@Apache.Org> in the Cc line ]
[and leave the subject line UNCHANGED.  This is not done]
[automatically because of the potential for mail loops. ]