From d30faec429417478db8b643f82ba5f82f57d172a Mon Sep 17 00:00:00 2001 From: tetragon Date: Sat, 22 Sep 2007 17:48:38 +0000 Subject: Adding Content-Disposition for items with output filenames git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1646 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/Template.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/LedgerSMB/Template.pm b/LedgerSMB/Template.pm index e0979881..31b98a3c 100755 --- a/LedgerSMB/Template.pm +++ b/LedgerSMB/Template.pm @@ -217,12 +217,18 @@ sub _http_output { my $self = shift; my $data = shift; $data ||= $self->{output}; - my $FH; + my $format = "LedgerSMB::Template::$self->{format}"; + my $disposition = "\n"; + my $name = $format->can('postprocess')->($self); + if ($name) { + $name =~ s#^.*/##; + $disposition .= qq|Content-Disposition: attachment; filename="$name"|; + } if ($self->{mimetype} =~ /^text/) { - print "Content-Type: $self->{mimetype}; charset=utf-8\n\n"; + print "Content-Type: $self->{mimetype}; charset=utf-8$disposition\n\n"; } else { - print "Content-Type: $self->{mimetype}\n\n"; + print "Content-Type: $self->{mimetype}$disposition\n\n"; } binmode STDOUT, ':bytes'; print $data; -- cgit v1.2.3