Remove setFilename, getFilename from Session::Http, and use Plack::Response methods instead.
This commit is contained in:
parent
fd8f03a186
commit
8b6bbdb9f7
9 changed files with 28 additions and 77 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 = ();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ This package allows the manipulation of HTTP protocol information.
|
|||
$boolean = $http->isRedirect();
|
||||
|
||||
$http->setCookie($name,$value);
|
||||
$http->setFilename($filename,$mimetype);
|
||||
$http->setNoHeader($bool);
|
||||
$http->setRedirect($url);
|
||||
|
||||
|
|
@ -260,9 +259,6 @@ sub sendHeader {
|
|||
$response->header( 'Expires' => $date );
|
||||
}
|
||||
}
|
||||
if ($self->getFilename) {
|
||||
$response->header( 'Content-Disposition' => qq{attachment; filename="}.$self->getFilename().'"');
|
||||
}
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
|
@ -353,46 +349,6 @@ sub setCookie {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 setFilename ( filename [, mimetype] )
|
||||
|
||||
Override the default filename for the document, which is usually the page url.
|
||||
|
||||
=head3 filename
|
||||
|
||||
The filename to set.
|
||||
|
||||
=head3 mimetype
|
||||
|
||||
The mimetype for this file. Defaults to "application/octet-stream".
|
||||
|
||||
=cut
|
||||
|
||||
sub setFilename {
|
||||
my $self = shift;
|
||||
$self->{_http}{filename} = shift;
|
||||
my $mimetype = shift || "application/octet-stream";
|
||||
$self->session->response->content_type($mimetype);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getFilename ( )
|
||||
|
||||
Returns the default filename for the document.
|
||||
|
||||
=cut
|
||||
|
||||
sub getFilename {
|
||||
my $self = shift;
|
||||
return $self->{_http}{filename};
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 setLastModified ( epoch )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue