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

@ -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();
};