Hello again
I'm still having troubles delivering my pdf-files ... I'm using the
code-snippets Geoffrey Young gave me, but i need to use an internal
redirect, because i provide the files with better (longer) filenames. I
can't find any tutorials or example-code for it, so I hope you guys can
help me ...
so what I'm actually doing is:
initial request:
- check permissions
- search the filename of the filesystem
- if it is not a static file: generate & deliever file
- otherwise: make an internal redirect to the specific file
handle the internal redirect:
- generating header
- deliver file (if necessary with byterange ...)
this looks approx. like this:
if ($r->is_initial_req) {
if (&static ()) {
$r->internal_redirect (&newfilename);
}
else {
$r->send_header ();
$r->send_fd($fh);
};
}
else {
$s->headers_out->set('Accept-Ranges' => 'bytes');
$r->headers_out->set("Content-Disposition" =>
"inline; filename=$name");
my $size = stat($file)->size;
$r->set_content_length($size);
$r->content_type($contenttypes{$type});
# 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;
}
my $fh = IO::File->new($file);
# handle a range request properly
if (($type eq 'pdf') && $range_request) {
while( my($offset, $length) = $r->each_byterange) {
seek $fh, $offset, 0;
$r->send_fd($fh, $length);
}
}
else {
$r->send_fd($fh);
};
$fh->close();
return DONE;
}
My problem is now, that i know not exactly what i should return if i make
an internal_redirect and what i have to return handling this internal_redirect
accessing a file like this results in the access-log in:
[30/Aug/2001:17:13:13 +0200] "GET
/files/sid00017/AR_1000A-TSS_report-TSS.PDF HTTP/1.1" 200 32768
"https://ida.festbrueder.ch/site/files.pl?siteid=17"; "Mozilla/4.0
(compatible; MSIE 5.01; Windows
[30/Aug/2001:17:13:14 +0200] "GET /files/sid00017/AR_1000A-TSS_report-TSS.PDF
HTTP/1.1" 200 40960 "-" "Mozilla/4.0 (compatible; MSIE 5.01; Windows
NT)"195.141.44.1 - -
[30/Aug/2001:17:13:14 +0200] "GET
/files/sid00017/AR_1000A-TSS_report-TSS.PDF HTTP/1.1" 206 397776 "-"
"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT)"
All three entries comes out of an access to one file ... *?* am i doing
this right?
Il'd be very thankfull if you could help me inhere ...
I'm really in trouble with this, and i won't loose my pleasure using
mod_perl ;-)
Thank you very much in advance!!
Thomas Bach
<><><><>
think karo.. www.bkaro.net