Hello I'm looking for a solution of this problem: I use Dancer1 I would like to control directory access and return the content as web share the access control part is ok. get '/donwload/**' => sub { # if ( Access control is OK ) { my ($file) = splat; my @file = @{ $file }; my $path= join('/', @file); my $fullpath='/home/media/files/'.$path; my $content_type = mimetype($fullpath); send_file( $fullpath, streaming => 1, filename => $file[-1], content_type => $content_type, system_path => 1); } }; If I open this link in with firefox , http://localhost/download/560297bbc96186eea22e0f31/image/index.html firefox launch a download of index.html. I don't want a download, I want html code directly as apache do. if someone has a idea, how I can do this ? thanks Hugues.
Hi! 2015-09-23 22:35 GMT+03:00 Hugues <hugues@max4mail.com>:
If I open this link in with firefox , http://localhost/download/560297bbc96186eea22e0f31/image/index.html firefox launch a download of index.html.
I don't want a download, I want html code directly as apache do.
if someone has a idea, how I can do this ?
If html-does not show up in bowser, my first tought is to check content_type (it should be text/html). Maybe is involved some other header, like Content-disposition. Check response headers. Wbr, -- Kõike hääd, Gunnar
Hello thanks , content disposition is no good see the return curl -v http://localhost/download/560297bbc96186eea22e0f31/html/index.html * About to connect() to localhost port 80 (#0) * Trying ::1... Connexion refusée * Trying 127.0.0.1... connected * Connected to localhost (127.0.0.1) port 80 (#0)
GET /api/v1/file/down/560297bbc96186eea22e0f31/html/index.html HTTP/1.1 User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.16.2.3 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2 Host: localhost Accept: */*
* HTTP 1.0, assume close after body < HTTP/1.0 200 OK < Content-Length: 1211 < Content-Type: text/html < Last-Modified: Wed, 23 Sep 2015 17:28:44 GMT < Content-Disposition: attachment; filename="index.html" < Set-Cookie: session.test=633577661861829697154487645971091229; path=/; HttpOnly < Set-Cookie: session.test=633577661861829697154487645971091229; path=/; HttpOnly Le 23/09/2015 21:48, WK a écrit :
Hi!
2015-09-23 22:35 GMT+03:00 Hugues <hugues@max4mail.com>:
If I open this link in with firefox , http://localhost/download/560297bbc96186eea22e0f31/image/index.html firefox launch a download of index.html.
I don't want a download, I want html code directly as apache do.
if someone has a idea, how I can do this ? If html-does not show up in bowser, my first tought is to check content_type (it should be text/html). Maybe is involved some other header, like Content-disposition. Check response headers.
Wbr,
Hello There are no Content-disposition for a normal html page ? if I add header "Content-Disposition" => "" ; send_file( $fullpath, streaming => 0, filename => $file[-1], content_type =>"text/html", system_path => 1); I've got 2 Content-Disposition with error in "Multiple Content disposition" < Last-Modified: Wed, 23 Sep 2015 17:28:44 GMT < Content-Disposition: < Content-Disposition: attachment; filename="index.html" do you have a idea ? how to remove Content-Disposition ? Le 23/09/2015 21:48, WK a écrit :
Hi!
2015-09-23 22:35 GMT+03:00 Hugues <hugues@max4mail.com>:
If I open this link in with firefox , http://localhost/download/560297bbc96186eea22e0f31/image/index.html firefox launch a download of index.html.
I don't want a download, I want html code directly as apache do.
if someone has a idea, how I can do this ? If html-does not show up in bowser, my first tought is to check content_type (it should be text/html). Maybe is involved some other header, like Content-disposition. Check response headers.
Wbr,
Hello WK thanks for you help I found the solution in Dancer.pm source code if (exists($options{filename})) { $resp->push_header('Content-Disposition' => "attachment; filename=\"$options{filename}\"" ); just remove filename in params of send_file, and there are no Content-Disposition send_file( $fullpath, streaming => 1, content_type => $content_type, system_path => 1); thanks lot Hugues Le 23/09/2015 21:48, WK a écrit :
Hi!
2015-09-23 22:35 GMT+03:00 Hugues <hugues@max4mail.com>:
If I open this link in with firefox , http://localhost/download/560297bbc96186eea22e0f31/image/index.html firefox launch a download of index.html.
I don't want a download, I want html code directly as apache do.
if someone has a idea, how I can do this ? If html-does not show up in bowser, my first tought is to check content_type (it should be text/html). Maybe is involved some other header, like Content-disposition. Check response headers.
Wbr,
participants (2)
-
Hugues -
WK