Nginx-ru mailing list archive (nginx-ru@sysoev.ru)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re[2]: perl и header_out
> Нужно так:
> $r->variable("limit_rate", "16k");
> $r->header_out("Content-Disposition", "attachment; filename=\"file.txt\"");
> $r->send_http_header("application/octet-stream; charset=cp1251");
> $r->internal_redirect("/dl/file.tx");
> return OK;
Сделал, спасибо!
Но проблемма ниже(хедеры в теле файла) не решилась.
location /dl {
limit_conn one 2;
root /home/denis/;
internal;
}
sub dl {
my $r = shift;
$r->header_out("Content-Disposition", "attachment; filename=\"file.txt\"");
$r->send_http_header("application/octet-stream; charset=cp1251");
$r->internal_redirect("/dl/file.txt");
return OK;
}
>> На выходе получаем:
$ wget -S http://xxx
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Server: nginx/0.5.33
Date: Sun, 09 Dec 2007 22:02:16 GMT
Content-Type: application/octet-stream; charset=cp1251
Connection: close
Content-Disposition: attachment; filename="file.txt"
Length: unspecified [application/octet-stream]
[ <=>
] 4,123,842 --.--K/s
00:02:16 (74.70 MB/s) - `file.txt' saved [4123842]
>> А потом
$ cat file.txt
HTTP/1.1 200 OK
Server: nginx/0.5.33
Date: Sun, 09 Dec 2007 22:02:16 GMT
Content-Type: application/octet-stream; charset=cp1251
Content-Length: 4123542
Last-Modified: Thu, 08 Nov 2007 02:02:10 GMT
Connection: close
Content-Disposition: attachment; filename="file.txt"
Accept-Ranges: bytes
---file_content_here--
|