> -----Original Message-----
> From: Thomas Bach [mailto:[EMAIL PROTECTED]]
> Sent: Monday, August 27, 2001 8:45 AM
> To: [EMAIL PROTECTED]
> Subject: open downloaded file
> 
> 
> hi list
> 
> i've a handler which controlls access to dowonloadable files. 
> The proble i 
> have is now, that IE (project designed only for this browser) 
> prints one or 
> twoo times the same "File download"-window where you can 
> choose between 
> open or save if you choose open. If you choose save all is going well.
> 
> i had to force a download, because of some pdf-problems (on 
> some systems, 
> the acrobat reader-plugin doesn't print the content - in the 
> server-logs 
> was all ok.) 

I've noticed on my version of MSIE that it does not handle PDFs in any form
without an Accept-Ranges header.  I tried looking for bug reports, but I
couldn't find any, so I figured it was just me...

> so that's why there's 'application/octet-stream' and 
> "Content-Disposition" => "attachment;"

try
  $r->headers_out->set("Content-Disposition" =>
                       "inline; filename=$filename");

really, for the If-Modified-Since header and byteserving in general you
ought to use the supplied mod_perl methods $r->meets_conditions and
$r->set_byterange/each_byterange...

try something like this instead for static files...

  # set the the headers
  $r->headers_out->set('Accept-Ranges' => 'bytes');
  $r->headers_out->set("Content-Disposition" =>
                       "inline; filename=$filename");
  $r->set_content_length(-s $r->finfo);

  # set the MIME type based on the document extension
  $r->content_type(MIME::Types::by_suffix($filename)->[0]);

  # determine if the request is a range request
  my $range_request = $r->set_byterange;

  # yea or nea
  if ((my $status = $r->meets_conditions) == OK) {
    $r->send_http_header;
  }
  else {
    return $status;
  }

  # handle a range request properly
  if ($range_request) {
    while( my($offset, $length) = $r->each_byterange) {
      seek $fh, $offset, 0;
      $r->send_fd($fh, $length);
    }
  }
  else {
    $r->send_fd($fh);
  }

HTH

--Geoff
 

Reply via email to