You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Aldo Letellier <al...@bigfootinteractive.com> on 2001/03/27 03:53:36 UTC

downloading a file keeps header info

Using the following code ( EPL 1.3.1 ) :

  .....

  my $fh = new FileHandle( $fdat{filename}, 'r');

  $req_rec->content_type( 'binary/octet-stream' );
  $req_rec->header_out( 'Content-Disposition', "inline;
filename=$fdat{filename};" );
  $req_rec->send_http_header;

  $req_rec->send_fd( $fh );

  close $lfh;
  exit;

  ....

Generates a file with the header information at the end:

145	0831	Y	paula.mitchell@wcom.com	PAAC	1999-08-05	D	DAVENPORT	QQQ	OBCORR
146	0831	Y	paula.mitchell@wcom.com	PAAC	1999-08-26	D	DAVENPORT	QQQ	OBCORR
147	0831	Y	paula.mitchell@wcom.com	PAAC	1999-08-26	D	DAVENPORT	QQQ	OBCORR
HTTP/1.1 200 OK

Date: Tue, 27 Mar 2001 02:56:03 GMT

Server: Apache/1.3.14 (Unix) mod_perl/1.24_01

Content-Disposition: inline; filename=anyfile.txt.log;

Keep-Alive: timeout=15, max=98

Connection: Keep-Alive, Keep-Alive

Transfer-Encoding: chunked, chunked

Content-Type: binary/octet-stream

....

Any help would be greatly appreciated.

Aldo Letellier
Development
Bigfoot Interactive
(646) 227-7410
aletellier@bigfootinteractive.com


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: downloading a file keeps header info

Posted by Gerald Richter <ri...@ecos.de>.

> Using the following code ( EPL 1.3.1 ) :
>
>   .....
>
>   my $fh = new FileHandle( $fdat{filename}, 'r');
>
>   $req_rec->content_type( 'binary/octet-stream' );
>   $req_rec->header_out( 'Content-Disposition', "inline;
> filename=$fdat{filename};" );
>   $req_rec->send_http_header;
>
>   $req_rec->send_fd( $fh );
>
>   close $lfh;
>   exit;
>
>   ....
>
> Generates a file with the header information at the end:
>

Embperl outputs the it's http headers after the processing of the page, but
the send_fd is outputed when it occurs, so it's output comes before the
headers Embperl sends.

Since you send your own headers via send_http_header, you can simply disable
Embperl hhtp header sending by putting a

$optSendHttpHeader = 0 ;

inside the page, then it should work

Gerald

-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org