Remove getStatus and setStatus in Session::Http, and replace them with status, from $session->status.

This commit is contained in:
Colin Kuskie 2010-11-21 21:11:41 -08:00
parent b830bd8e71
commit e5adc07a05
27 changed files with 88 additions and 129 deletions

View file

@ -42,7 +42,6 @@ This package allows the manipulation of HTTP protocol information.
$http->sendHeader();
$mimetype = $http->getMimeType();
$code = $http->getStatus();
$boolean = $http->isRedirect();
$http->setCookie($name,$value);
@ -138,22 +137,6 @@ sub getRedirectLocation {
}
#-------------------------------------------------------------------
=head2 getStatus ( ) {
Returns the current HTTP status code. If no code has been set,
the code returned will be 200.
=cut
sub getStatus {
my $self = shift;
my $status = $self->{_http}{status} || "200";
return $status;
}
#-------------------------------------------------------------------
=head2 getStreamedFile ( ) {
@ -212,7 +195,7 @@ Returns a boolean value indicating whether the current page will redirect to som
sub isRedirect {
my $self = shift;
my $status = $self->getStatus;
my $status = $self->session->response->status;
return $status == 302 || $status == 301;
}
@ -264,7 +247,6 @@ sub sendHeader {
my %params;
if ($self->isRedirect()) {
$response->header(Location => $self->getRedirectLocation);
$response->status($self->getStatus);
} else {
$response->content_type($self->getMimeType);
my $cacheControl = $self->getCacheControl;
@ -297,7 +279,6 @@ sub sendHeader {
if ($self->getFilename) {
$response->header( 'Content-Disposition' => qq{attachment; filename="}.$self->getFilename().'"');
}
$response->status($self->getStatus());
}
return undef;
}
@ -311,7 +292,6 @@ sub _sendMinimalHeader {
"Pragma" => "no-cache",
"Cache-Control" => "no-cache",
);
$response->status($self->getStatus());
return undef;
}
@ -507,7 +487,7 @@ sub setRedirect {
return undef if ($url eq $self->session->url->page() && scalar(@params) < 1); # prevent redirecting to self
$self->session->log->info("Redirecting to $url");
$self->setRedirectLocation($url);
$self->setStatus($type);
$self->session->response->status($type);
$self->session->style->setMeta({"http-equiv"=>"refresh",content=>"0; URL=".$url});
}
@ -527,23 +507,6 @@ sub setRedirectLocation {
#-------------------------------------------------------------------
=head2 setStatus ( code )
Sets the HTTP status code.
=head3 code
An HTTP status code. It is a 3 digit status number.
=cut
sub setStatus {
my $self = shift;
$self->{_http}{status} = shift;
}
#-------------------------------------------------------------------
=head2 setStreamedFile ( ) {
Set a file to be streamed thru mod_perl.

View file

@ -60,7 +60,7 @@ Returns a message stating that this functionality can only be used by administra
sub adminOnly {
my $self = shift;
my $i18n = WebGUI::International->new($self->session);
$self->session->http->setStatus(401);
$self->session->response->status(401);
my $output = '<h1>'.$i18n->get(35).'</h1>';
$output .= $i18n->get(36);
return $self->session->style->userStyle($output);
@ -78,7 +78,7 @@ sub insufficient {
my $self = shift;
my $noStyle = shift;
my $i18n = WebGUI::International->new($self->session);
$self->session->http->setStatus(401);
$self->session->response->status(401);
my $output = '<h1>'.$i18n->get(37).'</h1>';
if ($noStyle) {
$self->session->style->useEmptyStyle(1);
@ -103,7 +103,7 @@ sub locked {
my $self = shift;
my $noStyle = shift;
my $i18n = WebGUI::International->new($self->session);
$self->session->http->setStatus(401);
$self->session->response->status(401);
my $output = '<h1>'.$i18n->get(37).'</h1>';
if ($noStyle) {
$self->session->style->useEmptyStyle(1);
@ -148,7 +148,7 @@ Returns a message stating that the user does not have the privileges necessary t
sub noAccess {
my $self = shift;
$self->session->http->setStatus(401);
$self->session->response->status(401);
if ($self->session->user->isVisitor) {
return WebGUI::Operation::Auth::www_auth($self->session, "init");
} else {
@ -171,7 +171,7 @@ Returns a message stating that the user they requested information about is no l
sub notMember {
my $self = shift;
my $i18n = WebGUI::International->new($self->session);
$self->session->http->setStatus(400);
$self->session->response->status(400);
my ($output);
$output = '<h1>'.$i18n->get(345).'</h1>';
$output .= $i18n->get(346);
@ -203,7 +203,7 @@ Returns a message stating that the user made a request to delete something that
sub vitalComponent {
my $self = shift;
my $i18n = WebGUI::International->new($self->session);
$self->session->http->setStatus(403);
$self->session->response->status(403);
my ($output);
$output = '<h1>'.$i18n->get(40).'</h1>';
$output .= $i18n->get(41);