mkirank has asked for the wisdom of the Perl Monks concerning the following question:

Hi, After authentication i have to download a exe (i open the exe and print the same)onto the client browser this is the code i have used but the exe does not work on the client ...what are the headers to be sent before
print "Content-Disposition: attachment; filename=\"Setup.exe\" \n\n"; print"Content-type: application/octet-stream\n\n"; open FH, "setup.exe" or die (print"Error in saving $!"); while (<FH>) { print $_; } close FH;

Replies are listed 'Best First'.
Re: Download an exe
by Aragorn (Curate) on Feb 19, 2003 at 13:07 UTC
    Remove one of the \n characters in the Content-Disposition header. The \n\n marks the end of the headers.

    See this part of the HTTP/1.1 specification for more information.

    Arjen

    Update: Although this works, all the occurrences of \n should be replaced with \r\n (Carriage Return, Newline) to adhere completely to the standard.

      changed the \n to \r\n and it works :-) .. Thanks
Re: Download an exe
by Thelonius (Priest) on Feb 19, 2003 at 14:12 UTC
    Besides aragorn's correction, you probably also need to binmode STDOUT before the first print and binmode FH just after opening it.