WebGUI::Session::Http should go away (#11647)

Move logic out of WebGUI::Session::HTTP and into WebGUI::Session::Response /
::Request; deprecate more functions; change references in core to use
$session->response instead; fix tests that broke because of the change but
not one that merely generate the deprecated warning because I want to know
that the proxying of depricated methods is working.  These can be changed later.
This commit is contained in:
Scott Walters 2011-05-11 16:17:54 -04:00
parent 72bac90f93
commit 57d2dbed56
76 changed files with 581 additions and 358 deletions

View file

@ -175,7 +175,7 @@ sub handle {
# A WebGUI::Asset::Template object means we should process it
if ( defined $output && blessed $output && $output->isa( 'WebGUI::Asset::Template' ) ) {
$session->http->sendHeader;
$session->response->sendHeader;
$session->output->print( $output->process );
return;
}
@ -187,7 +187,7 @@ sub handle {
# other non-empty output should be used as the response body
elsif (defined $output && $output ne "") {
# Auto-set the headers
$session->http->sendHeader;
$session->response->sendHeader;
# Use contentHandler's return value as the output
$session->output->print($output);
@ -195,7 +195,7 @@ sub handle {
}
# Keep processing for success codes
elsif ($session->response->status < 200 || $session->response->status > 299) {
$session->http->sendHeader;
$session->response->sendHeader;
return;
}
}

View file

@ -287,7 +287,7 @@ sub displayContent {
return $output if($noStyle);
#Wrap the layout in the user style
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
return $session->style->process($output,$self->getStyleTemplateId);
}

View file

@ -255,7 +255,7 @@ A string that defaults to _function's title.
sub render {
my $self = shift;
my $session = $self->session;
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
my %var;
$var{"application_loop"} = $self->getAdminFunction;
$var{"application.workarea"} = shift;

View file

@ -653,11 +653,11 @@ sub checkView {
my $self = shift;
return $self->session->privilege->noAccess() unless $self->canView;
my $session = $self->session;
my ($conf, $http) = $self->session->quick(qw(config http));
my ($conf, $response) = $self->session->quick(qw(config response));
if ($conf->get("sslEnabled") && $self->get("encryptPage") && ! $self->session->request->secure) {
# getUrl already changes url to https if 'encryptPage'
$http->setRedirect($self->getUrl);
$http->sendHeader;
$response->setRedirect($self->getUrl);
$response->sendHeader;
return "chunked";
}
elsif ($session->isAdminOn && $self->get("state") =~ /^trash/) { # show em trash
@ -665,8 +665,8 @@ sub checkView {
if ($self->session->form->process('revision')) {
$queryFrag .= ";revision=".$self->session->form->process('revision');
}
$http->setRedirect($self->getUrl($queryFrag));
$http->sendHeader;
$response->setRedirect($self->getUrl($queryFrag));
$response->sendHeader;
return "chunked";
}
elsif ($session->isAdminOn && $self->get("state") =~ /^clipboard/) { # show em clipboard
@ -674,8 +674,8 @@ sub checkView {
if ($self->session->form->process('revision')) {
$queryFrag .= ";revision=".$self->session->form->process('revision');
}
$http->setRedirect($self->getUrl($queryFrag));
$http->sendHeader;
$response->setRedirect($self->getUrl($queryFrag));
$response->sendHeader;
return "chunked";
}
elsif ($self->get("state") ne "published") { # tell em it doesn't exist anymore
@ -949,7 +949,7 @@ sub forkWithStatusPage {
proceed => $args->{redirect} || '',
}
);
$session->http->setRedirect( $self->getUrl($pairs) );
$session->response->setRedirect( $self->getUrl($pairs) );
return 'redirect';
} ## end sub forkWithStatusPage
@ -2199,23 +2199,23 @@ sub proceed {
return $session->asset->www_manageAssets;
}
elsif ($proceed eq "viewParent") {
$session->http->setRedirect( $self->getParent->getUrl );
$session->response->setRedirect( $self->getParent->getUrl );
return "redirect";
}
elsif ($proceed eq "editParent") {
$session->http->setRedirect( $self->getParent->getUrl('func=edit') );
$session->response->setRedirect( $self->getParent->getUrl('func=edit') );
return "redirect";
}
elsif ($proceed eq "goBackToPage" && $session->form->process('returnUrl')) {
$session->http->setRedirect($session->form->process("returnUrl"));
$session->response->setRedirect($session->form->process("returnUrl"));
return "redirect";
}
elsif ($proceed ne "") {
$session->http->setRedirect( $self->getUrl( 'func=' . $proceed ) );
$session->response->setRedirect( $self->getUrl( 'func=' . $proceed ) );
return "redirect";
}
$session->http->setRedirect( $self->getUrl );
$session->response->setRedirect( $self->getUrl );
return "redirect";
}
@ -2936,7 +2936,7 @@ sub www_view {
# don't allow viewing of the root asset
if ($self->getId eq "PBasset000000000000001") {
$self->session->http->setRedirect($self->getDefault($self->session)->getUrl);
$self->session->response->setRedirect($self->getDefault($self->session)->getUrl);
return undef;
}

View file

@ -2340,7 +2340,7 @@ ENDJS
### Show the processed template
$session->http->sendHeader;
$session->response->sendHeader;
my $style = $self->getParent->processStyle($self->getSeparator);
my ($head, $foot) = split($self->getSeparator,$style);
$self->session->output->print($head, 1);
@ -2376,8 +2376,8 @@ sub www_view {
return $self->session->privilege->noAccess() unless $self->canView;
my $check = $self->checkView;
return $check if (defined $check);
$self->session->http->setCacheControl($self->getParent->visitorCacheTimeout) if ($self->session->user->isVisitor);
$self->session->http->sendHeader;
$self->session->response->setCacheControl($self->getParent->visitorCacheTimeout) if ($self->session->user->isVisitor);
$self->session->response->sendHeader;
$self->prepareView;
my $style = $self->getParent->processStyle($self->getSeparator);
my ($head, $foot) = split($self->getSeparator,$style);

View file

@ -619,9 +619,9 @@ sub www_view {
return sprintf($i18n->get("file not found"), $self->getUrl());
}
$session->http->setRedirect($self->getFileUrl) unless $session->config->get('enableStreamingUploads');
$session->http->setStreamedFile($self->getStorageLocation->getPath($self->filename));
$session->http->sendHeader;
$session->response->setRedirect($self->getFileUrl) unless $session->config->get('enableStreamingUploads');
$session->response->setStreamedFile($self->getStorageLocation->getPath($self->filename));
$session->response->sendHeader;
return 'chunked';
}

View file

@ -1154,8 +1154,8 @@ sub www_view {
# Add to views
$self->update({ views => $self->views + 1 });
$self->session->http->setLastModified($self->getContentLastModified);
$self->session->http->sendHeader;
$self->session->response->setLastModified($self->getContentLastModified);
$self->session->response->sendHeader;
$self->prepareView;
my $style = $self->processStyle($self->getSeparator);
my ($head, $foot) = split($self->getSeparator,$style);

View file

@ -548,7 +548,7 @@ sub www_download {
my $storage = $self->getStorageLocation;
$self->session->response->content_type( "image/jpeg" );
$self->session->http->setLastModified( $self->getContentLastModified );
$self->session->response->setLastModified( $self->getContentLastModified );
my $resolution = $self->session->form->get("resolution");
if ($resolution) {

View file

@ -270,7 +270,7 @@ sub www_view {
if ($self->session->isAdminOn) {
return $self->session->asset($self->getContainer)->www_view;
}
$self->session->http->setRedirect($self->getFileUrl($self->showPage));
$self->session->response->setRedirect($self->getFileUrl($self->showPage));
return "1";
}

View file

@ -383,7 +383,7 @@ so that this point is automatically shown.
sub www_view {
my $self = shift;
$self->session->http->setRedirect(
$self->session->response->setRedirect(
$self->getParent->getUrl('focusOn=' . $self->getId )
);
return "redirect";

View file

@ -785,10 +785,10 @@ sub www_click {
$self->incrementCounter('clicks');
if ($session->form->process("manufacturer")) {
$session->http->setRedirect( $self->get('manufacturerURL') );
$session->response->setRedirect( $self->get('manufacturerURL') );
}
else {
$session->http->setRedirect( $self->get('productURL') );
$session->response->setRedirect( $self->get('productURL') );
}
return undef;
}

View file

@ -1424,20 +1424,20 @@ Renders self->view based upon current style, subject to timeouts. Returns Privil
=cut
sub www_view {
my $self = shift;
my $currentPost = shift;
return $self->session->privilege->noAccess() unless $self->canView;
my $check = $self->checkView;
return $check if (defined $check);
$self->session->http->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor);
$self->session->http->sendHeader;
$self->prepareView;
my $style = $self->getParent->processStyle($self->getSeparator);
my ($head, $foot) = split($self->getSeparator,$style);
$self->session->output->print($head,1);
$self->session->output->print($self->view($currentPost));
$self->session->output->print($foot,1);
return "chunked";
my $self = shift;
my $currentPost = shift;
return $self->session->privilege->noAccess() unless $self->canView;
my $check = $self->checkView;
return $check if (defined $check);
$self->session->response->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor);
$self->session->response->sendHeader;
$self->prepareView;
my $style = $self->getParent->processStyle($self->getSeparator);
my ($head, $foot) = split($self->getSeparator,$style);
$self->session->output->print($head,1);
$self->session->output->print($self->view($currentPost));
$self->session->output->print($foot,1);
return "chunked";
}

View file

@ -85,7 +85,7 @@ sub exportHtml_view {
my $url = $self->redirectUrl;
WebGUI::Macro::process($self->session, \$url);
return '' if ($url eq $self->url);
$self->session->http->setRedirect($url);
$self->session->response->setRedirect($url);
return $self->session->style->process('', 'PBtmpl0000000000000060');
}
@ -130,7 +130,7 @@ sub www_view {
</ul>',$i18n->get("assetName"));
}
unless ($url eq $self->url) {
$self->session->http->setRedirect($url,$self->redirectType);
$self->session->response->setRedirect($url,$self->redirectType);
return undef;
}
return $i18n->get('self_referential');

View file

@ -1255,8 +1255,8 @@ sub www_view {
$shortcut->purgeCache();
if ($shortcut->isa('WebGUI::Asset::Wobject')) {
$self->session->http->setLastModified($self->getContentLastModified);
$self->session->http->sendHeader;
$self->session->response->setLastModified($self->getContentLastModified);
$self->session->response->sendHeader;
##Tell processStyle not to set the h
my $style = $shortcut->processStyle($shortcut->getSeparator, { noHeadTags => 1 });
my ($head, $foot) = split($shortcut->getSeparator,$style);

View file

@ -647,8 +647,8 @@ sub www_view {
my $self = shift;
my $check = $self->checkView;
return $check if (defined $check);
$self->session->http->setLastModified($self->getContentLastModified);
$self->session->http->sendHeader;
$self->session->response->setLastModified($self->getContentLastModified);
$self->session->response->sendHeader;
$self->prepareView;
my $style = $self->processStyle($self->getSeparator);
my ($head, $foot) = split($self->getSeparator,$style);

View file

@ -584,8 +584,8 @@ sub www_manage {
my $self = shift;
my $check = $self->checkView;
return $check if (defined $check);
$self->session->http->setLastModified($self->getContentLastModified);
$self->session->http->sendHeader;
$self->session->response->setLastModified($self->getContentLastModified);
$self->session->response->sendHeader;
$self->prepareView($self->manageTemplate);
my $style = $self->processStyle($self->getSeparator);
my ($head, $foot) = split($self->getSeparator,$style);

View file

@ -1896,7 +1896,7 @@ Extend the base method to handle caching.
override www_view => sub {
my $self = shift;
$self->session->http->setCacheControl($self->cacheTimeout);
$self->session->response->setCacheControl($self->cacheTimeout);
super();
};

View file

@ -275,7 +275,7 @@ sub www_view {
return $self->session->privilege->insufficient() unless $self->canView;
my $mimeType=$self->mimeType;
$self->session->response->content_type($mimeType || 'text/html');
$self->session->http->setCacheControl($self->cacheTimeout);
$self->session->response->setCacheControl($self->cacheTimeout);
my $output = $self->view(1);
if (!defined $output) {
$output = 'empty';

View file

@ -918,7 +918,7 @@ the Story Archive that contains them.
sub www_view {
my $self = shift;
return $self->session->privilege->noAccess unless $self->canView;
$self->session->http->sendHeader;
$self->session->response->sendHeader;
$self->prepareView;
return $self->getArchive->processStyle($self->view);
}

View file

@ -847,7 +847,7 @@ the user back to the site.
sub www_goBackToPage {
my $self = shift;
$self->session->http->setRedirect($self->session->form->get("returnUrl")) if ($self->session->form->get("returnUrl"));
$self->session->response->setRedirect($self->session->form->get("returnUrl")) if ($self->session->form->get("returnUrl"));
return undef;
}

View file

@ -548,7 +548,7 @@ sub www_purgeRevision {
$asset->purgeRevision;
if ($session->form->process("proceed") eq "manageRevisionsInTag") {
my $working = (defined $self) ? $self : $parent;
$session->http->setRedirect($working->getUrl("op=manageRevisionsInTag"));
$session->response->setRedirect($working->getUrl("op=manageRevisionsInTag"));
return undef;
}
unless (defined $self) {
@ -601,9 +601,9 @@ sub www_view {
return $self->session->privilege->noAccess unless $self->canView;
$self->update({ views => $self->views+1 });
# TODO: This should probably exist, as the CS has one.
# $self->session->http->setCacheControl($self->getWiki->get('visitorCacheTimeout'))
# $self->session->response->setCacheControl($self->getWiki->get('visitorCacheTimeout'))
# if ($self->session->user->isVisitor);
$self->session->http->sendHeader;
$self->session->response->sendHeader;
$self->prepareView;
return $self->getWiki->processStyle($self->view);
}

View file

@ -505,8 +505,8 @@ sub www_view {
my $self = shift;
my $check = $self->checkView;
return $check if (defined $check);
$self->session->http->setLastModified($self->getContentLastModified);
$self->session->http->sendHeader;
$self->session->response->setLastModified($self->getContentLastModified);
$self->session->response->sendHeader;
##Have to dupe this code here because Wobject does not call SUPER.
$self->prepareView;
my $style = $self->processStyle($self->getSeparator, { noHeadTags => 1 });

View file

@ -433,7 +433,7 @@ See WebGUI::Asset::Wobject::www_view() for details.
override www_view => sub {
my $self = shift;
$self->session->http->setCacheControl($self->cacheTimeout);
$self->session->response->setCacheControl($self->cacheTimeout);
super();
};

View file

@ -1776,7 +1776,7 @@ Extend the base method to handle the visitor cache timeout.
sub www_view {
my $self = shift;
my $disableCache = ($self->session->form->process("sortBy") ne "");
$self->session->http->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor && !$disableCache);
$self->session->response->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor && !$disableCache);
return $self->next::method(@_);
}

View file

@ -460,10 +460,10 @@ sub www_view {
if ($self->state eq "published") { # no privileges, make em log in
return $self->session->privilege->noAccess();
} elsif ($self->session->isAdminOn && $self->state =~ /^trash/) { # show em trash
$self->session->http->setRedirect($self->getUrl("func=manageTrash"));
$self->session->response->setRedirect($self->getUrl("func=manageTrash"));
return undef;
} elsif ($self->session->isAdminOn && $self->state =~ /^clipboard/) { # show em clipboard
$self->session->http->setRedirect($self->getUrl("func=manageClipboard"));
$self->session->response->setRedirect($self->getUrl("func=manageClipboard"));
return undef;
} else { # tell em it doesn't exist anymore
$self->session->response->status(410);

View file

@ -1339,7 +1339,7 @@ sub viewForm {
}
$var = $passedVars || $self->getRecordTemplateVars($var, $entry);
if ($self->hasCaptcha) {
$self->session->http->setCacheControl('none');
$self->session->response->setCacheControl('none');
}
return $self->processTemplate($var, undef, $self->{_viewFormTemplate});
}
@ -1889,7 +1889,7 @@ sub www_exportTab {
$session->response->header( 'Content-Disposition' => qq{attachment; filename="}.$self->url.'.tab"');
$session->response->content_type('text/plain');
$session->http->sendHeader;
$session->response->sendHeader;
$session->output->print($tsv->string, 1);
my $entryIter = $self->entryClass->iterateAll($self);

View file

@ -282,7 +282,7 @@ See WebGUI::Asset::Wobject::www_view() for details.
override www_view => sub {
my $self = shift;
$self->session->http->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor);
$self->session->response->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor);
super();
};

View file

@ -837,8 +837,8 @@ sub sendChunkedContent {
my $session = $self->session;
$session->http->setLastModified($self->getContentLastModified);
$session->http->sendHeader;
$session->response->setLastModified($self->getContentLastModified);
$session->response->sendHeader;
my $style = $self->processStyle($self->getSeparator);
my ($head, $foot) = split($self->getSeparator,$style);
$session->output->print($head, 1);

View file

@ -497,7 +497,7 @@ sub www_view {
if ($self->session->response->content_type ne "text/html") {
return $output;
} else {
$self->session->http->sendHeader;
$self->session->response->sendHeader;
my $style = $self->processStyle($self->getSeparator, { noHeadTags => 1 });
my ($head, $foot) = split($self->getSeparator,$style);
$self->session->output->print($head);

View file

@ -396,8 +396,8 @@ override www_view => sub {
my $ad = $adSpace->displayImpression if (defined $adSpace);
$out =~ s/\Q$code/$ad/ges;
}
$session->http->setLastModified($self->getContentLastModified);
$session->http->sendHeader;
$session->response->setLastModified($self->getContentLastModified);
$session->response->sendHeader;
$session->output->print($out, 1);
return "chunked";
}

View file

@ -1080,7 +1080,7 @@ sub www_exportAttributes {
$session->response->header( 'Content-Disposition' => qq{attachment; filename="export_matrix_attributes.csv"});
$session->response->content_type('application/octet-stream');
$self->session->http->sendHeader;
$self->session->response->sendHeader;
return $output;
}

View file

@ -178,7 +178,7 @@ See WebGUI::Asset::Wobject::www_view() for details.
override www_view => sub {
my $self = shift;
$self->session->http->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor);
$self->session->response->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor);
super();
};

View file

@ -128,7 +128,7 @@ See WebGUI::Asset::Wobject::www_view() for details.
override www_view => sub {
my $self = shift;
$self->session->http->setCacheControl($self->cacheTimeout);
$self->session->response->setCacheControl($self->cacheTimeout);
super();
};

View file

@ -504,7 +504,7 @@ Do a redirect to the form parameter returnUrl if it exists.
sub www_goBackToPage {
my $self = shift;
$self->session->http->setRedirect($self->session->form->process("returnUrl")) if ($self->session->form->process("returnUrl"));
$self->session->response->setRedirect($self->session->form->process("returnUrl")) if ($self->session->form->process("returnUrl"));
return undef;
}

View file

@ -704,7 +704,7 @@ sub www_download {
$self->downloadType eq 'csv' ? "application/octet-stream" : $self->downloadMimeType
);
$self->session->http->sendHeader;
$self->session->response->sendHeader;
return $self->download;
@ -722,7 +722,7 @@ See WebGUI::Asset::Wobject::www_view() for details.
override www_view => sub {
my $self = shift;
$self->session->http->setCacheControl($self->cacheTimeout);
$self->session->response->setCacheControl($self->cacheTimeout);
super();
};

View file

@ -390,7 +390,7 @@ See WebGUI::Asset::Wobject::www_view() for details.
override www_view => sub {
my $self = shift;
$self->session->http->setCacheControl($self->cacheTimeout);
$self->session->response->setCacheControl($self->cacheTimeout);
super();
};

View file

@ -356,9 +356,9 @@ sub www_deployPackage {
return undef;
};
if ($session->form->param("proceed") eq "manageAssets") {
$session->http->setRedirect($self->getManagerUrl);
$session->response->setRedirect($self->getManagerUrl);
} else {
$session->http->setRedirect($self->getUrl());
$session->response->setRedirect($self->getUrl());
}
return undef;
}
@ -376,7 +376,7 @@ sub www_exportPackage {
return $self->session->privilege->insufficient() unless ($self->canEdit);
my $storage = $self->exportPackage;
my $filename = $storage->getFiles->[0];
$self->session->http->setRedirect($storage->getUrl($storage->getFiles->[0]));
$self->session->response->setRedirect($storage->getUrl($storage->getFiles->[0]));
return "redirect";
}

View file

@ -615,7 +615,7 @@ sub www_purgeRevision {
$asset->purgeRevision;
if ($session->form->process("proceed") eq "manageRevisionsInTag") {
my $working = (defined $self) ? $self : $parent;
$session->http->setRedirect($working->getUrl("op=manageRevisionsInTag"));
$session->response->setRedirect($working->getUrl("op=manageRevisionsInTag"));
return undef;
}
unless (defined $self) {

View file

@ -966,12 +966,12 @@ sub www_createAccountSave {
return $self->showMessageOnLogin;
}
elsif ($self->session->form->get('returnUrl')) {
$self->session->http->setRedirect( $self->session->form->get('returnUrl') );
$self->session->response->setRedirect( $self->session->form->get('returnUrl') );
$self->session->scratch->delete("redirectAfterLogin");
}
elsif ($self->session->scratch->get("redirectAfterLogin")) {
my $url = $self->session->scratch->delete("redirectAfterLogin");
$self->session->http->setRedirect($url);
$self->session->response->setRedirect($url);
return undef;
}
else {
@ -1178,7 +1178,7 @@ sub www_login {
if ($self->session->setting->get('encryptLogin')) {
my $currentUrl = $self->session->url->page(undef,1);
$currentUrl =~ s/^https:/http:/;
$self->session->http->setRedirect($currentUrl);
$self->session->response->setRedirect($currentUrl);
}
# Run on login
@ -1198,14 +1198,14 @@ sub www_login {
return $self->showMessageOnLogin;
}
elsif ( $self->session->form->get('returnUrl') ) {
$self->session->http->setRedirect( $self->session->form->get('returnUrl') );
$self->session->response->setRedirect( $self->session->form->get('returnUrl') );
$self->session->scratch->delete("redirectAfterLogin");
}
elsif ( my $url = $self->session->scratch->delete("redirectAfterLogin") ) {
$self->session->http->setRedirect($url);
$self->session->response->setRedirect($url);
}
elsif ( $self->session->setting->get("redirectAfterLoginUrl") ) {
$self->session->http->setRedirect($self->session->setting->get("redirectAfterLoginUrl"));
$self->session->response->setRedirect($self->session->setting->get("redirectAfterLoginUrl"));
$self->session->scratch->delete("redirectAfterLogin");
}
@ -1242,7 +1242,7 @@ sub www_logout {
}
# Do not allow caching of the logout page (to ensure the page gets requested)
$self->session->http->setCacheControl( "none" );
$self->session->response->setCacheControl( "none" );
return undef;
}

View file

@ -185,7 +185,7 @@ sub www_login {
->extend_permissions(qw(email))
->uri_as_string;
$session->http->setRedirect($auth_url);
$session->response->setRedirect($auth_url);
return "redirect";
}

View file

@ -187,7 +187,7 @@ sub www_login {
$scratch->set( 'AuthTwitterToken', $nt->request_token );
$scratch->set( 'AuthTwitterTokenSecret', $nt->request_token_secret );
$session->http->setRedirect($auth_url);
$session->response->setRedirect($auth_url);
return "redirect";
}

View file

@ -71,7 +71,7 @@ sub dispatch {
if ($session->user->isVisitor
&& !$session->request->ifModifiedSince($asset->getContentLastModified, $session->setting->get('maxCacheTimeout'))) {
$session->response->status("304");
$session->http->sendHeader;
$session->response->sendHeader;
return "chunked";
}
@ -166,7 +166,7 @@ The content handler for this package.
sub handler {
my ($session) = @_;
my ($log, $http, $asset, $request, $config) = $session->quick(qw(errorHandler http asset request config));
my ($log, $asset, $request, $config) = $session->quick(qw(errorHandler asset request config));
my $output = "";
if (my $perfLog = $log->performanceLogger) { #show performance indicators if required
my $t = [Time::HiRes::gettimeofday()];
@ -177,7 +177,7 @@ sub handler {
$output = dispatch($session, getRequestedAssetUrl($session));
}
my $filename = $http->getStreamedFile();
my $filename = $session->response->getStreamedFile();
if ((defined $filename) && ($config->get("enableStreamingUploads") eq "1")) {
my $ct = guess_media_type($filename);
my $oldContentType = $request->content_type($ct);

View file

@ -47,7 +47,7 @@ The content handler for this package.
sub handler {
my $session = shift;
if ($session->setting->get("specialState") eq "upgrading") {
$session->http->sendHeader;
$session->response->sendHeader;
open my $fh, '<', $session->config->get('maintenancePage');
my $output = do { local $/; <$fh> };
close $fh;

View file

@ -43,7 +43,7 @@ status of.
);
# See WebGUI::Operation::Fork
my $pairs = $process->contentPairs('DoWork');
$session->http->setRedirect($self->getUrl($pairs));
$session->response->setRedirect($self->getUrl($pairs));
return 'redirect';
}

View file

@ -181,7 +181,7 @@ form variable C<classLimiter>. A crumb trail is provided for navigation.
sub www_assetTree {
my $session = shift;
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
my $base = WebGUI::Asset->newByUrl($session) || WebGUI::Asset->getRoot($session);
my @crumb;
my $ancestorIter = $base->getLineageIterator(["self","ancestors"]);

View file

@ -213,7 +213,7 @@ sub www_show {
else {
@assetIds = $session->form->param("attachments");
}
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
$style->setScript($url->extras("/AttachmentsControl/AttachmentsControl.js"));
$style->setCss($url->extras("/AttachmentsControl/AttachmentsControl.css"));
my $uploadControl = '';

View file

@ -213,7 +213,7 @@ Asset picker for the rich editor.
sub www_pageTree {
my $session = shift;
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
$session->style->setCss($session->url->extras('/tinymce-webgui/plugins/wgpagetree/css/pagetree.css'));
$session->style->setRawHeadTags(<<"JS");
<style type="text/css">body { margin: 0 }</style>
@ -270,7 +270,7 @@ Each link display a thumbnail of the image via www_viewThumbnail.
sub www_imageTree {
my $session = shift;
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
$session->style->setCss($session->url->extras('/tinymce-webgui/plugins/wginsertimage/css/insertimage.css'));
$session->style->setRawHeadTags(<<"JS");
<style type="text/css">body { margin: 0 }</style>
@ -349,7 +349,7 @@ URL in the session object is used to determine which Image is used.
sub www_viewThumbnail {
my $session = shift;
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
$session->style->setCss($session->url->extras('/tinymce-webgui/plugins/wginsertimage/css/insertimage.css'));
my $image = WebGUI::Asset->newByUrl($session);
my $i18n = WebGUI::International->new($session);
@ -375,7 +375,7 @@ Returns a form to add a folder using the rich editor. The purpose of this featur
sub www_addFolder {
my $session = shift;
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
my $i18n = WebGUI::International->new($session, 'Operation_FormHelpers');
my $f = WebGUI::HTMLForm->new($session);
$f->hidden(
@ -416,7 +416,7 @@ Creates a directory under the current asset. The filename should be specified in
sub www_addFolderSave {
my $session = shift;
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
# get base url
my $base = WebGUI::Asset->newByUrl($session) || WebGUI::Asset->getRoot($session);
# check if user can edit the current asset
@ -453,7 +453,7 @@ sub www_addFolderSave {
#filename => $filename,
});
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });
$session->http->setRedirect($base->getUrl('op=formHelper;class=HTMLArea;sub=imageTree'));
$session->response->setRedirect($base->getUrl('op=formHelper;class=HTMLArea;sub=imageTree'));
return undef;
}
@ -467,7 +467,7 @@ Returns a form to add an image using the rich editor. The purpose of this featur
sub www_addImage {
my $session = shift;
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
my $i18n = WebGUI::International->new($session, 'Operation_FormHelpers');
my $f = WebGUI::HTMLForm->new($session);
$f->hidden(
@ -508,7 +508,7 @@ Creates an Image asset under the current asset. The filename should be specified
sub www_addImageSave {
my $session = shift;
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
# get base asset
my $base = WebGUI::Asset->newByUrl($session) || WebGUI::Asset->getRoot($session);
@ -539,7 +539,7 @@ sub www_addImageSave {
$child->applyConstraints;
}
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 });
$session->http->setRedirect($base->getUrl('op=formHelper;class=HTMLArea;sub=imageTree'));
$session->response->setRedirect($base->getUrl('op=formHelper;class=HTMLArea;sub=imageTree'));
return undef;
}

View file

@ -56,7 +56,7 @@ sub www_clickAd {
my $id = $session->form->param("id");
return undef unless $id;
my $url = WebGUI::AdSpace->countClick($session, $id);
$session->http->setRedirect($url);
$session->response->setRedirect($url);
return undef;
}

View file

@ -51,7 +51,7 @@ via WebGUI::Session::switchAdminOff()
sub www_switchOffAdmin {
my $session = shift;
return "" unless ($session->user->canUseAdminMode);
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
$session->switchAdminOff();
return "";
}
@ -67,7 +67,7 @@ If the current user is in the Turn On Admin Group, then allow them to turn on Ad
sub www_switchOnAdmin {
my $session = shift;
return "" unless ($session->user->canUseAdminMode);
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
$session->switchAdminOn();
return "";
}

View file

@ -69,7 +69,7 @@ is returned.
sub www_auth {
my $session = shift;
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
my $auth;
($auth) = $session->db->quickArray("select authMethod from users where username=".$session->db->quote($session->form->process("username"))) if($session->form->process("username"));
my $authMethod = getInstance($session,$auth);

View file

@ -270,7 +270,7 @@ Checks to ensure the requestor is who we think it is, and then executes a cron j
sub www_runCronJob {
my $session = shift;
$session->response->content_type("text/plain");
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
unless (Net::CIDR::Lite->new(@{ $session->config->get('spectreSubnets') })->find($session->request->address) || canView($session)) {
$session->log->security("make a Spectre cron job runner request, but we're only allowed to accept requests from ".join(",",@{$session->config->get("spectreSubnets")}).".");
return "error";

View file

@ -348,7 +348,7 @@ sub www_editLDAPLinkSave {
$properties->{ldapLoginTemplate} = $session->form->template("ldapLoginTemplate");
$session->db->setRow("ldapLink","ldapLinkId",$properties);
if($session->form->process("returnUrl")) {
$session->http->setRedirect($session->form->process("returnUrl"));
$session->response->setRedirect($session->form->process("returnUrl"));
return undef;
}
return www_listLDAPLinks($session);

View file

@ -53,7 +53,7 @@ Checks to ensure the requestor is who we think it is, and then returns a JSON st
sub www_spectreGetSiteData {
my $session = shift;
$session->response->content_type("application/json");
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
my %siteData = ();
my $subnets = $session->config->get("spectreSubnets");
if (!defined $subnets) {
@ -117,7 +117,7 @@ sub www_spectreStatus {
my $ac = WebGUI::AdminConsole->new($session, 'spectre');
my $i18n = WebGUI::International->new($session, 'Spectre');
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
my $remote = create_ikc_client(
port=>$session->config->get("spectrePort"),
@ -174,7 +174,7 @@ spectreSubnet, instead of checking the IP address of the spectre process.
sub www_spectreTest {
my $session = shift;
$session->response->content_type("text/plain");
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
my $subnets = $session->config->get("spectreSubnets");
if (!defined $subnets) {

View file

@ -943,7 +943,7 @@ A reference to the current session.
sub www_formUsers {
my $session = shift;
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
return $session->privilege->insufficient() unless $session->user->isInGroup(12);
$session->style->useEmptyStyle("1");
my $output = getUserSearchForm($session,"formUsers",{formId=>$session->form->process("formId")},1);

View file

@ -912,7 +912,7 @@ sub www_rollbackVersionTag {
my $method = $session->form->process("proceed");
$method = $method eq "manageCommittedVersions" ? $method : 'manageVersions';
my $redir = WebGUI::Asset->getDefault($session)->getUrl("op=$method");
$session->http->setRedirect(
$session->response->setRedirect(
$session->url->page(
$process->contentPairs(
'ProgressBar', {

View file

@ -482,7 +482,7 @@ Checks to ensure the requestor is who we think it is, and then executes a workfl
sub www_runWorkflow {
my $session = shift;
$session->response->content_type("text/plain");
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
unless (Net::CIDR::Lite->new(@{ $session->config->get('spectreSubnets')} )->find($session->request->address) || canRunWorkflow($session)) {
$session->log->security("make a Spectre workflow runner request, but we're only allowed to accept requests from ".join(",",@{$session->config->get("spectreSubnets")}).".");
return "error";

View file

@ -90,7 +90,7 @@ sub exportSomething {
$csvData .= WebGUI::Text::joinCSV(@row) . "\n";
}
$storage->addFileFromScalar($filename, $csvData);
$session->http->setRedirect($storage->getUrl($filename));
$session->response->setRedirect($storage->getUrl($filename));
}
#-------------------------------------------------------------------

View file

@ -150,7 +150,7 @@ The url to the icon you want to display.
sub start {
my ($self, $title, $icon) = @_;
$self->session->http->setCacheControl("none");
$self->session->response->setCacheControl("none");
my %var = (
title => $title,
icon => $icon
@ -159,7 +159,7 @@ sub start {
my $output = $self->session->style->process($template->process(\%var).'~~~', "PBtmpl0000000000000137");
my ($head, $foot) = split '~~~', $output;
local $| = 1; # Tell modperl not to buffer the output
$self->session->http->sendHeader;
$self->session->response->sendHeader;
$self->session->output->print($head, 1); #skipMacros
$self->{_foot} = $foot;
return '';

View file

@ -157,7 +157,7 @@ sub _httpBasicLogin {
'WWW-Authenticate' => 'Basic realm="'.$self->session->setting->get('companyName').'"'
);
$self->session->response->status(401);
$self->session->http->sendHeader;
$self->session->response->sendHeader;
return '';
}

View file

@ -571,6 +571,7 @@ sub open {
##Set defaults
$self->{_response} = $request->new_response( 200 );
$self->{_response}->content_type('text/html; charset=UTF-8');
$self->{_response}->session( $self );
# Use the WebGUI::Session::Request object to look up the sessionId from cookies, if it
# wasn't given explicitly

View file

@ -33,6 +33,9 @@ Package WebGUI::Session::Http
This package allows the manipulation of HTTP protocol information.
*** This module is deprecated in favor of L<WebGUI::Session::Request> and
L<WebGUI::Session::Response>.
=head1 SYNOPSIS
use WebGUI::Session::Http;
@ -53,89 +56,6 @@ These methods are available from this package:
=cut
#-------------------------------------------------------------------
=head2 getCacheControl ( )
Returns the cache control setting from this object.
=cut
sub getCacheControl {
my $self = shift;
return $self->{_http}{cacheControl} || 1;
}
#-------------------------------------------------------------------
=head2 getCookies ( )
Retrieves the cookies from the HTTP header and returns a hash reference containing them.
=cut
sub getCookies {
my $self = shift;
_deprecated('Request::cookies');
return $self->session->request->cookies;
}
#-------------------------------------------------------------------
=head2 getLastModified ( )
Returns the stored epoch date when the page as last modified.
=cut
sub getLastModified {
my $self = shift;
return $self->{_http}{lastModified};
}
#-------------------------------------------------------------------
=head2 getNoHeader ( )
Returns whether or not a HTTP header will be printed.
=cut
sub getNoHeader {
my $self = shift;
return $self->{_http}{noHeader};
}
#-------------------------------------------------------------------
=head2 getStreamedFile ( ) {
Returns the location of a file to be streamed thru mod_perl, if one has been set.
=cut
sub getStreamedFile {
my $self = shift;
return $self->{_http}{streamlocation} || undef;
}
#-------------------------------------------------------------------
=head2 isRedirect ( )
Returns a boolean value indicating whether the current page will redirect to some other location.
=cut
sub isRedirect {
my $self = shift;
my $status = $self->session->response->status;
return $status == 302 || $status == 301;
}
#-------------------------------------------------------------------
=head2 new ( session )
@ -156,76 +76,6 @@ sub new {
return $self;
}
#-------------------------------------------------------------------
=head2 sendHeader ( )
Generates and sends HTTP headers for a response.
=cut
sub sendHeader {
my $self = shift;
return undef if ($self->{_http}{noHeader});
return $self->_sendMinimalHeader unless defined $self->session->db(1);
my $session = $self->session;
my ($request, $response, $config) = $session->quick(qw(request response config ));
return undef unless $request;
my $userId = $session->get("userId");
# send webgui session cookie
my $cookieName = $config->getCookieName;
$self->setCookie($cookieName, $session->getId, $config->getCookieTTL, $config->get("cookieDomain")) unless $session->getId eq $request->cookies->{$cookieName};
$self->setNoHeader(1);
my %params;
if (!$self->isRedirect()) {
my $cacheControl = $self->getCacheControl;
my $date = ($userId eq "1") ? HTTP::Date::time2str($self->getLastModified) : HTTP::Date::time2str();
# under these circumstances, don't allow caching
if ($userId ne "1" || $cacheControl eq "none" || $self->session->setting->get("preventProxyCache")) {
$response->header(
"Cache-Control" => "private, max-age=1",
"Pragma" => "no-cache",
"Cache-Control" => "no-cache",
);
}
# in all other cases, set cache, but tell it to ask us every time so we don't mess with recently logged in users
else {
if ( $cacheControl eq "none" ) {
$response->header("Cache-Control" => "private, max-age=1");
}
else {
$response->header(
'Last-Modified' => $date,
'Cache-Control' => "must-revalidate, max-age=" . $cacheControl,
);
}
# do an extra incantation if the HTTP protocol is really old
if ($request->protocol =~ /(\d\.\d)/ && $1 < 1.1) {
my $date = HTTP::Date::time2str(time() + $cacheControl);
$response->header( 'Expires' => $date );
}
}
}
return undef;
}
sub _sendMinimalHeader {
my $self = shift;
my $response = $self->session->response;
$response->content_type('text/html; charset=UTF-8');
$response->header(
'Cache-Control' => 'private',
"Pragma" => "no-cache",
"Cache-Control" => "no-cache",
);
return undef;
}
#-------------------------------------------------------------------
=head2 session ( )
@ -239,6 +89,106 @@ sub session {
return $self->{_session};
}
#-------------------------------------------------------------------
=head2 getCacheControl ( )
Returns the cache control setting from this object.
=cut
sub getCacheControl {
my $self = shift;
return $self->session->response->getCacheControl;
}
#-------------------------------------------------------------------
=head2 getCookies ( )
Retrieves the cookies from the HTTP header and returns a hash reference containing them.
=cut
sub getCookies {
my $self = shift;
_deprecated('Session::Request::cookies');
return $self->session->request->cookies;
}
#-------------------------------------------------------------------
=head2 getLastModified ( )
Returns the stored epoch date when the page as last modified.
=cut
sub getLastModified {
my $self = shift;
return $self->session->response->getLastModified;
}
#-------------------------------------------------------------------
=head2 getNoHeader ( )
Returns whether or not a HTTP header will be printed.
=cut
sub getNoHeader {
my $self = shift;
return $self->session->response->getNoHeader;
}
#-------------------------------------------------------------------
=head2 getStreamedFile ( ) {
Returns the location of a file to be streamed thru mod_perl, if one has been set.
=cut
sub getStreamedFile {
my $self = shift;
_deprecated('Session::Response::getStreamedFile');
return $self->session->response->getStreamedFile;
}
#-------------------------------------------------------------------
=head2 isRedirect ( )
Returns a boolean value indicating whether the current page will redirect to some other location.
=cut
sub isRedirect {
my $self = shift;
_deprecated('Session::Response::isRedirect');
return $self->session->response->isRedirect;
}
#-------------------------------------------------------------------
=head3 sendHeader
Moved to L<WebGUI::Session::Response>.
=cut
sub sendHeader {
my $self = shift;
_deprecated('Session::Response::sendHeader');
$self->session->response->sendHeader(@_);
}
#-------------------------------------------------------------------
=head2 setCacheControl ( timeout )
@ -253,49 +203,20 @@ Either the number of seconds until the cache expires, or the word "none" to disa
sub setCacheControl {
my $self = shift;
my $timeout = shift;
$self->{_http}{cacheControl} = $timeout;
_deprecated('Session::Response::setCacheControl');
$self->session->response->setCacheControl(@_);
}
#-------------------------------------------------------------------
=head2 setCookie ( name, value [ , timeToLive, domain ] )
Sends a cookie to the browser.
=head3 name
The name of the cookie to set. Must be unique from all other cookies from this domain or it will overwrite that cookie.
=head3 value
The value to set.
=head3 timeToLive
The time that the cookie should remain in the browser. Defaults to "+10y" (10 years from now).
This may be "session" to indicate that the cookie is for the current browser session only.
=head3 domain
Explicitly set the domain for this cookie.
=cut
Moved to L<WebGUI::Session::Response>.
sub setCookie {
my $self = shift;
my $name = shift;
my $value = shift;
my $ttl = shift;
my $domain = shift;
$ttl = (defined $ttl ? $ttl : '+10y');
$self->session->response->cookies->{$name} = {
value => $value,
path => '/',
expires => $ttl ne 'session' ? $ttl : undef,
domain => $domain,
};
_deprecated('Session::Request');
$self->session->response->setCookie(@_);
}
@ -311,8 +232,8 @@ The epoch date when the page was last modified.
sub setLastModified {
my $self = shift;
my $epoch = shift;
$self->{_http}{lastModified} = $epoch;
_deprecated('Session::Response::setLastModified');
$self->session->response->setLastModified(@_);
}
#-------------------------------------------------------------------
@ -330,36 +251,22 @@ Any value other than 0 will disable header printing.
sub setNoHeader {
my $self = shift;
$self->{_http}{noHeader} = shift;
_deprecated('Session::Response::setNoHeader');
$self->session->response->setNoHeader(@_);
}
#-------------------------------------------------------------------
=head2 setRedirect ( url, [ type ] )
Sets the necessary information in the HTTP header to redirect to another URL.
=head3 url
The URL to redirect to. To prevent infinite loops, no redirect will be set if
url is the same as the current page, as found through $session->url->page.
=head3 type
Defaults to 302 (temporary redirect), but you can optionally set 301 (permanent redirect).
Moved to L<WebGUI::Session::Response>.
=cut
sub setRedirect {
my $self = shift;
my $url = shift;
my $type = shift || 302;
my @params = $self->session->form->param;
return undef if ($url eq $self->session->url->page() && scalar(@params) < 1); # prevent redirecting to self
$self->session->log->info("Redirecting to $url");
$self->session->response->location($url);
$self->session->response->status($type);
$self->session->style->setMeta({"http-equiv"=>"refresh",content=>"0; URL=".$url});
_deprecated('Session::Response');
$self->session->response->setRedirect(@_);
}
@ -373,7 +280,8 @@ Set a file to be streamed thru mod_perl.
sub setStreamedFile {
my $self = shift;
$self->{_http}{streamlocation} = shift;
_deprecated('Session::Response');
$self->session->response->setStreamedFile(@_);
}

View file

@ -1,7 +1,12 @@
package WebGUI::Session::Response;
use strict;
use warnings;
use parent qw(Plack::Response);
use IO::File::WithPath;
use Plack::Util::Accessor qw(session streaming writer streamer);
=head1 SYNOPSIS
@ -18,6 +23,10 @@ is created.
=cut
#
#
#
=head2 stream
=cut
@ -28,6 +37,10 @@ sub stream {
$self->streaming(1);
}
#
#
#
=head2 stream_write
=cut
@ -41,4 +54,300 @@ sub stream_write {
$self->writer->write(@_);
}
#
#
#
=head2 sendHeader ( )
Generates and sends HTTP headers for a response.
=cut
sub sendHeader {
my $self = shift;
return undef if $self->{_http}{noHeader};
return $self->_sendMinimalHeader unless defined $self->session->db(1);
no warnings 'uninitialized';
my $session = $self->session;
my ($request, $config) = $session->quick(qw(request config ));
return undef unless $request;
my $userId = $session->get("userId");
# send webgui session cookie
my $cookieName = $config->getCookieName;
$self->setCookie($cookieName, $session->getId, $config->getCookieTTL, $config->get("cookieDomain")) unless $session->getId eq $request->cookies->{$cookieName};
$self->setNoHeader(1);
my %params;
if (!$self->isRedirect()) {
my $cacheControl = $self->getCacheControl;
my $date = ($userId eq "1") ? HTTP::Date::time2str($self->getLastModified) : HTTP::Date::time2str();
# under these circumstances, don't allow caching
if ($userId ne "1" || $cacheControl eq "none" || $self->session->setting->get("preventProxyCache")) {
$self->header(
"Cache-Control" => "private, max-age=1",
"Pragma" => "no-cache",
"Cache-Control" => "no-cache",
);
}
# in all other cases, set cache, but tell it to ask us every time so we don't mess with recently logged in users
else {
if ( $cacheControl eq "none" ) {
$self->header("Cache-Control" => "private, max-age=1");
}
else {
$self->header(
'Last-Modified' => $date,
'Cache-Control' => "must-revalidate, max-age=" . $cacheControl,
);
}
# do an extra incantation if the HTTP protocol is really old
if ($request->protocol =~ /(\d\.\d)/ && $1 < 1.1) {
my $date = HTTP::Date::time2str(time() + $cacheControl);
$self->header( 'Expires' => $date );
}
}
}
return undef;
}
sub _sendMinimalHeader {
my $self = shift;
$self->content_type('text/html; charset=UTF-8');
$self->header(
'Cache-Control' => 'private',
"Pragma" => "no-cache",
"Cache-Control" => "no-cache",
);
return undef;
}
#
#
#
=head2 setCookie ( name, value [ , timeToLive, domain ] )
Sends a cookie to the browser.
=head3 name
The name of the cookie to set. Must be unique from all other cookies from this domain or it will overwrite that cookie.
=head3 value
The value to set.
=head3 timeToLive
The time that the cookie should remain in the browser. Defaults to "+10y" (10 years from now).
This may be "session" to indicate that the cookie is for the current browser session only.
=head3 domain
Explicitly set the domain for this cookie.
=cut
sub setCookie {
my $self = shift;
my $name = shift;
my $value = shift;
my $ttl = shift;
my $domain = shift;
$ttl = (defined $ttl ? $ttl : '+10y');
$self->cookies->{$name} = {
value => $value,
path => '/',
expires => $ttl ne 'session' ? $ttl : undef,
domain => $domain,
};
}
#
#
#
=head2 setRedirect ( url, [ type ] )
Sets the necessary information in the HTTP header to redirect to another URL.
=head3 url
The URL to redirect to. To prevent infinite loops, no redirect will be set if
url is the same as the current page, as found through $session->url->page.
=head3 type
Defaults to 302 (temporary redirect), but you can optionally set 301 (permanent redirect).
=cut
sub setRedirect {
my $self = shift;
my $url = shift || '';
my $type = shift || 302;
my @params = $self->session->form->param;
return undef if ($url eq $self->session->url->page() && scalar(@params) < 1); # prevent redirecting to self
$self->session->log->info("Redirecting to $url");
$self->location($url);
$self->status($type);
$self->session->style->setMeta({"http-equiv"=>"refresh",content=>"0; URL=".$url});
}
#
#
#
=head2 getLastModified ( )
Returns the stored epoch date when the page as last modified.
=cut
sub getLastModified {
my $self = shift;
return $self->{_http}{lastModified};
}
#
#
#
=head2 setLastModified ( epoch )
=head3 epoch
The epoch date when the page was last modified.
=cut
sub setLastModified {
my $self = shift;
my $epoch = shift;
$self->{_http}{lastModified} = $epoch;
}
#
#
#
=head2 getNoHeader ( )
Returns whether or not a HTTP header will be printed.
=cut
sub getNoHeader {
my $self = shift;
return $self->{_http}{noHeader};
}
#
#
#
=head2 setNoHeader ( boolean )
Disables the printing of a HTTP header. Useful in situations when content is not
returned to a browser (export to disk for example).
=head3 boolean
Any value other than 0 will disable header printing.
=cut
sub setNoHeader {
my $self = shift;
$self->{_http}{noHeader} = shift;
}
#
#
#
=head2 isRedirect ( )
Returns a boolean value indicating whether the current page will redirect to some other location.
=cut
sub isRedirect {
my $self = shift;
my $status = $self->status;
return $status == 302 || $status == 301;
}
#
#
#
=head2 getStreamedFile ( ) {
Returns the location of a file to be streamed thru mod_perl, if one has been set.
=cut
sub getStreamedFile {
my $self = shift;
return $self->{_http}{streamlocation} || undef;
}
#
#
#
=head2 setStreamedFile ( ) {
Set a file to be streamed thru mod_perl.
=cut
sub setStreamedFile {
my $self = shift;
my $fn = shift;
$self->{_http}{streamlocation} = $fn;
# $self->body( IO::File::WithPath->new( $fn ) ); # let Plack handle the streaming, or let Plack::Middleware::XSendfile punt it; we don't want to send a 302 header and send the file, too; should be one or the other, selectable
}
#
#
#
=head2 setCacheControl ( timeout )
Sets the cache control headers.
=head3 timeout
Either the number of seconds until the cache expires, or the word "none" to disable cache completely for this request.
=cut
sub setCacheControl {
my $self = shift;
my $timeout = shift;
$self->{_http}{cacheControl} = $timeout;
}
#
#
#
=head2 getCacheControl ( )
Returns the cache control setting from this object.
=cut
sub getCacheControl {
my $self = shift;
return $self->{_http}{cacheControl} || 1;
}
1;

View file

@ -242,7 +242,7 @@ if ($self->session->user->isRegistered || $self->session->setting->get("preventP
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate, max-age=0, private" />
<meta http-equiv="Expires" content="0" />
';
$self->session->http->setCacheControl("none");
$self->session->response->setCacheControl("none");
} else {
$var{'head.tags'} .= '<meta http-equiv="Cache-Control" content="must-revalidate" />'
}
@ -559,7 +559,7 @@ The content to be wrappered.
sub userStyle {
my $self = shift;
my $output = shift;
$self->session->http->setCacheControl("none");
$self->session->response->setCacheControl("none");
if (defined $output) {
return $self->process($output,$self->session->setting->get("userFunctionStyleId"));
} else {

View file

@ -288,7 +288,7 @@ is not passed in, it will attempt to get one from the L<page> method, or finally
sub forceSecureConnection {
my $self = shift;
my $url = shift;
my ($conf, $http) = $self->session->quick(qw(config http));
my ($conf, $response) = $self->session->quick(qw(config response));
if ($conf->get("sslEnabled") && ! $self->session->request->secure){
@ -305,7 +305,7 @@ sub forceSecureConnection {
}
if($url =~ /^http/i) {
$url =~ s/^https?/https/i;
$http->setRedirect($url);
$response->setRedirect($url);
return 1;
}
}

View file

@ -668,7 +668,7 @@ sub www_editSave {
return $session->privilege->insufficient() unless $session->user->isAdmin;
$self->processPropertiesFromFormPost;
$session->http->setRedirect($session->url->page('shop=pay;method=manage'));
$session->response->setRedirect($session->url->page('shop=pay;method=manage'));
return undef;
}

View file

@ -350,7 +350,7 @@ sub www_cancelTransaction {
$self->_setPaymentStatus( 0, $form->process('PAYID'), $form->process('STATUS'), 'Cancelled' );
$self->processTransaction( $transaction );
$session->http->setRedirect($self->session->url->getSiteURL.'?shop=cart');
$session->response->setRedirect($self->session->url->getSiteURL.'?shop=cart');
return $session->style->userStyle('Transaction cancelled');
}
@ -373,7 +373,7 @@ sub www_declineTransaction {
$self->_setPaymentStatus( 0, $form->process('PAYID'), $form->process('STATUS'), 'Declined' );
$self->processTransaction( $transaction );
$session->http->setRedirect($self->session->url->getSiteURL.'?shop=cart');
$session->response->setRedirect($self->session->url->getSiteURL.'?shop=cart');
return $session->style->userStyle('Transaction declined');
}
@ -396,7 +396,7 @@ sub www_exceptionTransaction {
$self->_setPaymentStatus( 0, $form->process('PAYID'), $form->process('STATUS'), 'Transaction exception occurred' );
$self->processTransaction( $transaction );
$session->http->setRedirect($self->session->url->getSiteURL.'?shop=cart');
$session->response->setRedirect($self->session->url->getSiteURL.'?shop=cart');
return $session->style->userStyle('A transaction exception occurred.');
}

View file

@ -337,7 +337,7 @@ sub www_sendToPayPal {
}
);
return $session->http->setRedirect($dest);
return $session->response->setRedirect($dest);
} ## end sub www_sendToPayPal
=head1 LIMITATIONS

View file

@ -346,7 +346,7 @@ sub www_editSave {
my $session = $self->session;
return $session->privilege->insufficient() unless $session->user->isAdmin;
$self->processPropertiesFromFormPost;
$session->http->setRedirect($session->url->page('shop=ship;method=manage'));
$session->response->setRedirect($session->url->page('shop=ship;method=manage'));
return undef;
}

View file

@ -437,7 +437,7 @@ sub www_exportTax {
return $session->privilege->insufficient unless $self->canManage;
my $storage = $self->exportTaxData();
$self->session->http->setRedirect($storage->getUrl($storage->getFiles->[0]));
$self->session->response->setRedirect($storage->getUrl($storage->getFiles->[0]));
return "redirect";
}

View file

@ -100,7 +100,7 @@ sub autoCommitWorkingIfEnabled {
}
else {
my $url = $versionTag->autoCommitUrl($options->{returnUrl});
$session->http->setRedirect($url);
$session->response->setRedirect($url);
return 'redirect';
}
}

View file

@ -377,7 +377,7 @@ sub www_cleanup {
my ( $self ) = @_;
$self->cleanup;
$self->session->http->setRedirect( $self->session->url->page );
$self->session->response->setRedirect( $self->session->url->page );
return "redirect";
}

View file

@ -242,7 +242,7 @@ sub www_chooseContent {
my ($self) = @_;
my $session = $self->session;
my $form = $session->form;
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
my $i18n = WebGUI::International->new( $session, "WebGUI" );
my $output = '<h1>' . $i18n->get('Initial Pages') . '</h1>';

View file

@ -57,7 +57,7 @@ sub wrapStyle {
my ( $self, $output ) = @_;
my $session = $self->session;
my $form = $session->form;
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
my $i18n = WebGUI::International->new( $session, "WebGUI" );
my $page = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
@ -142,7 +142,7 @@ sub www_adminAccount {
my ( $self ) = @_;
my $session = $self->session;
my $form = $session->form;
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
my $i18n = WebGUI::International->new( $session, "WebGUI" );
my $legend = $i18n->get('admin account');
@ -246,7 +246,7 @@ sub www_companyInformation {
my ( $self ) = @_;
my $session = $self->session;
my $form = $session->form;
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
my $i18n = WebGUI::International->new( $session, "WebGUI" );
my $output = '<h1>' . $i18n->get('company information') . '</h1>';
@ -306,7 +306,7 @@ sub www_siteStats {
my ( $self ) = @_;
my $session = $self->session;
my $form = $session->form;
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
my $i18n = WebGUI::International->new( $session, "WebGUI" );
my $enableForm = $self->getForm;
@ -390,7 +390,7 @@ sub www_cleanup {
my ( $self ) = @_;
my $session = $self->session;
my $form = $session->form;
$session->http->setCacheControl("none");
$session->response->setCacheControl("none");
my $i18n = WebGUI::International->new( $session, "WebGUI" );
$self->cleanup;

View file

@ -170,6 +170,7 @@ checkModule('Starman', '0.2010', 2);
checkModule('App::Cmd', '0.311' );
checkModule('Devel::StackTrace', '1.27' );
checkModule('Devel::StackTrace::WithLexicals', '0.03' );
checkModule('IO::File::WithPath', );
failAndExit("Required modules are missing, running no more checks.") if $missingModule;

View file

@ -8,6 +8,11 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
# this test file is now slightly badly named since the functions in
# WebGUI::Session::HTTML have all been migrated to
# WebGUI::Session::Request and ::Response. still, these tests need
# to continue to pass.
use strict;
use WebGUI::Test;

View file

@ -195,7 +195,7 @@ $session->setting->set('userFunctionStyleId', $templates->{user}->getId);
is($style->userStyle('userStyle'), 'USER PRINTABLE STYLE TEMPLATE:userStyle',
'userStyle returns templated output according to userFunctionStyleId in settings');
is($session->http->{_http}{cacheControl}, 'none', 'userStyle(via process): HTTP cacheControl set to none to prevent proxying');
is($session->http->getCacheControl, 'none', 'userStyle(via process): HTTP cacheControl set to none to prevent proxying');
is($style->userStyle('userStyle'), 'USER PRINTABLE STYLE TEMPLATE:userStyle',
'userStyle returns templated output according to userFunctionStyleId in settings');
@ -306,8 +306,7 @@ $head =~ s/(^HEAD=.+$)/$1/s;
cmp_bag(\@metas, $expectedMetas, 'process:default meta tags with no caching head tags, preventProxyCache setting');
$session->setting->set('preventProxyCache', $origPreventProxyCache);
##No accessor
is($session->http->{_http}{cacheControl}, 'none', 'process: HTTP cacheControl set to none to prevent proxying');
is($session->http->getCacheControl, 'none', 'process: HTTP cacheControl set to none to prevent proxying');
####################################################
#