Skip to content

Commit

Permalink
Send filename header if applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
pudge committed Dec 9, 2003
1 parent 0f02a6a commit 6b8fb25
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Slash/XML/XML.pm
Expand Up @@ -71,6 +71,13 @@ Boolean for whether to print (false) or return (true) the
processed template data. Default is to print output via
Apache, with full HTML headers.
=item filename
A name for the generated filename Apache sends out. "Unsafe"
chars are replaced, and ".xml" is appended if there is no "."
in the name already. "foo bar" becomes "foo_bar.xml" and
"foo bar.rss" becomes "foo_bar.rss".
=back
=back
Expand Down Expand Up @@ -111,8 +118,13 @@ sub xmlDisplay {
return $content;
} else {
my $r = Apache->request;
$r->header_out('Cache-Control', 'private');
$r->content_type('text/xml');
$r->header_out('Cache-Control', 'private');
if ($opt->{filename}) {
$opt->{filename} =~ s/[^\w.-]/_/;
$opt->{filename} .= '.xml' unless $opt->{filename} =~ /\./;
$r->header_out('Content-Disposition', "filename=$opt->{filename}");
}
$r->status(200);
$r->send_http_header;
return 1 if $r->header_only;
Expand Down

0 comments on commit 6b8fb25

Please sign in to comment.