Remove setFilename, getFilename from Session::Http, and use Plack::Response methods instead.

This commit is contained in:
Colin Kuskie 2010-11-22 08:06:25 -08:00
parent fd8f03a186
commit 8b6bbdb9f7
9 changed files with 28 additions and 77 deletions

View file

@ -1816,8 +1816,8 @@ sub www_ical {
# Set mime of text/icalendar
#$self->session->response->content_type("text/plain");
$self->session->http->setFilename("feed.ics","text/calendar");
$self->session->response->header( 'Content-Disposition' => qq{attachment; filename="feed.ics"});
$self->session->response->content_type("text/calendar");
return $ical;
}

View file

@ -1883,7 +1883,8 @@ sub www_exportTab {
@exportFields,
);
$session->http->setFilename($self->url.".tab","text/plain");
$session->response->header( 'Content-Disposition' => qq{attachment; filename="}.$self->url.'.tab"');
$session->response->content_type('text/plain');
$session->http->sendHeader;
$session->output->print($tsv->string, 1);

View file

@ -1258,7 +1258,8 @@ sub www_exportEvents {
my $out = $session->output;
# set http header
$self->session->http->setFilename($self->getTitle.".csv", 'application/excel');
$session->response->header( 'Content-Disposition' => qq{attachment; filename="}.$self->getTitle().'.csv"' );
$session->response->content_type('application/excel');
# add file header
my @header = ();

View file

@ -1078,8 +1078,8 @@ sub www_exportAttributes {
$output .= "\n".WebGUI::Text::joinCSV($attribute->{name},$attribute->{description},$attribute->{category});
}
my $fileName = "export_matrix_attributes.csv";
$self->session->http->setFilename($fileName,"application/octet-stream");
$session->response->header( 'Content-Disposition' => qq{attachment; filename="export_matrix_attributes.csv"});
$session->response->content_type('application/octet-stream');
$self->session->http->sendHeader;
return $output;
}

View file

@ -699,12 +699,10 @@ sub www_download {
unless $self->session->user->isInGroup($self->downloadUserGroup);
# Set filename and mimetype
if ($self->downloadType eq "csv") {
$self->session->http->setFilename($self->downloadFilename,"application/octet-stream");
}
else {
$self->session->http->setFilename($self->downloadFilename, $self->downloadMimeType);
}
$self->session->response->header( 'Content-Disposition' => qq{attachment; filename="}.$self->downloadFilename().'"');
$self->session->response->content_type(
$self->downloadType eq 'csv' ? "application/octet-stream" : $self->downloadMimeType
);
$self->session->http->sendHeader;

View file

@ -2411,7 +2411,8 @@ sub export {
$self->clearTempReportTable;
my $filename = $self->session->url->escape( $self->title . "_$opts{name}.$format" );
$self->session->http->setFilename($filename,"text/$format");
$self->session->response->header( 'Content-Disposition' => qq{attachment; filename="}.$filename.'"');
$self->session->response->content_type("text/$format");
return $content;
}
@ -2542,7 +2543,8 @@ END_HTML
my $output = join "\n", @lines;
my $filename = $self->session->url->escape( $self->title . "_structure.csv" );
$self->session->http->setFilename($filename,"text/csv");
$self->session->response->header( 'Content-Disposition' => qq{attachment; filename="}.$filename.'"');
$self->session->response->content_type("text/csv");
return $output;
}
@ -2667,7 +2669,8 @@ sub www_downloadDefaultQuestionTypes{
if !$self->session->user->isInGroup( $self->groupToViewReports );
my $content = to_json($self->getSurveyJSON->{multipleChoiceTypes});
$self->session->http->setFilename('WebGUI-Survey-DefaultQuestionTypes.json', "application/json");
$self->session->response->header( 'Content-Disposition' => qq{attachment; filename="WebGUI-Survey-DefaultQuestionTypes.json"});
$self->session->response->content_type("application/json");
return $content;
}