Skip to content

Instantly share code, notes, and snippets.

@mvickers
Created February 8, 2011 00:24
Show Gist options
  • Save mvickers/815588 to your computer and use it in GitHub Desktop.
Save mvickers/815588 to your computer and use it in GitHub Desktop.
package content_disposition;
use Dancer ':syntax';
our $VERSION = '0.1';
# SHELL> curl --head http://localhost:3000
# HTTP/1.0 200 OK
# Content-Type: text/html; charset=UTF-8
# Content-Disposition: attachment; filename=test.html
# X-Powered-By: Perl Dancer 1.2000
get '/' => sub {
header "Content-Disposition" => "attachment; filename=test.html";
send_file('404.html');
};
# SHELL> curl --head http://localhost:3000/attachment
# HTTP/1.0 200 OK
# Content-Type: text/html; charset=UTF-8
# X-Powered-By: Perl Dancer 1.2000
get '/attachment' => sub {
my $response = send_file('404.html');
$response->header("Content-Disposition","attachment; filename=test.html");
return $response;
};
true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment