Remove getStatus and setStatus in Session::Http, and replace them with status, from $session->status.
This commit is contained in:
parent
b830bd8e71
commit
e5adc07a05
27 changed files with 88 additions and 129 deletions
|
|
@ -619,7 +619,7 @@ sub checkView {
|
|||
return "chunked";
|
||||
}
|
||||
elsif ($self->get("state") ne "published") { # tell em it doesn't exist anymore
|
||||
$http->setStatus(410);
|
||||
$session->response->status(410);
|
||||
my $notFound = WebGUI::Asset->getNotFound($self->session);
|
||||
$self->session->asset($notFound);
|
||||
return $notFound->www_view;
|
||||
|
|
|
|||
|
|
@ -615,7 +615,7 @@ sub www_view {
|
|||
# Check to make sure it's not in the trash or some other weird place
|
||||
if ($self->state ne "published") {
|
||||
my $i18n = WebGUI::International->new($session,'Asset_File');
|
||||
$session->http->setStatus(404);
|
||||
$session->response->status(404);
|
||||
return sprintf($i18n->get("file not found"), $self->getUrl());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -466,7 +466,7 @@ sub www_view {
|
|||
$self->session->http->setRedirect($self->getUrl("func=manageClipboard"));
|
||||
return undef;
|
||||
} else { # tell em it doesn't exist anymore
|
||||
$self->session->http->setStatus(410);
|
||||
$self->session->response->status(410);
|
||||
return WebGUI::Asset->getNotFound($self->session)->www_view;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1624,7 +1624,7 @@ sub www_deleteThingDataViaAjax {
|
|||
$session->http->setMimeType("application/json");
|
||||
|
||||
unless ($thingId && $thingDataId) {
|
||||
$session->http->setStatus(400);
|
||||
$session->response->status(400);
|
||||
return JSON->new->encode({message => "Can't get thing data without a thingId and a thingDataId."});
|
||||
}
|
||||
|
||||
|
|
@ -1639,7 +1639,7 @@ sub www_deleteThingDataViaAjax {
|
|||
return JSON->new->encode({message => "Data with thingDataId $thingDataId was deleted."});
|
||||
}
|
||||
else {
|
||||
$session->http->setStatus(404);
|
||||
$session->response->status(404);
|
||||
return JSON->new->encode({message => "The thingId you specified can not be found."});
|
||||
}
|
||||
}
|
||||
|
|
@ -2583,7 +2583,7 @@ sub www_editThingDataSaveViaAjax {
|
|||
my $i18n = WebGUI::International->new($self->session, "Asset_Thingy");
|
||||
|
||||
unless ($thingId && $thingDataId) {
|
||||
$session->http->setStatus(400);
|
||||
$session->response->status(400);
|
||||
return JSON->new->encode({message => "Can't get thing data without a thingId and a thingDataId."});
|
||||
}
|
||||
|
||||
|
|
@ -2593,22 +2593,22 @@ sub www_editThingDataSaveViaAjax {
|
|||
,$thingProperties);
|
||||
|
||||
if($thingDataId eq 'new' && $self->hasEnteredMaxPerUser($thingId)){
|
||||
$session->http->setStatus(400);
|
||||
$session->response->status(400);
|
||||
return JSON->new->encode({message => $i18n->get("has entered max per user message")});
|
||||
}
|
||||
|
||||
my ($newThingDataId,$errors) = $self->editThingDataSave($thingId,$thingDataId);
|
||||
|
||||
if (@{ $errors }) {
|
||||
$session->http->setStatus(400);
|
||||
$session->response->status(400);
|
||||
return JSON->new->encode($errors);
|
||||
}
|
||||
$session->http->setStatus("200");
|
||||
$session->response->status("200");
|
||||
return '{}';
|
||||
}
|
||||
else {
|
||||
$session->log->warn("thingId ".$thingProperties->{thingId}." not found in thingProperties");
|
||||
$session->http->setStatus(404);
|
||||
$session->response->status(404);
|
||||
return JSON->new->encode({message => "The thingId you requested can not be found."});
|
||||
}
|
||||
}
|
||||
|
|
@ -2707,7 +2707,7 @@ sub www_getThingViaAjax {
|
|||
$session->http->setMimeType("application/json");
|
||||
|
||||
unless ($thingId) {
|
||||
$session->http->setStatus(400);
|
||||
$session->response->status(400);
|
||||
return JSON->new->encode({message => "Can't return thing properties without a thingId."});
|
||||
}
|
||||
|
||||
|
|
@ -2729,7 +2729,7 @@ sub www_getThingViaAjax {
|
|||
return JSON->new->encode($thingProperties);
|
||||
}
|
||||
else {
|
||||
$session->http->setStatus(404);
|
||||
$session->response->status(404);
|
||||
return JSON->new->encode({message => "The thingId you requested can not be found."});
|
||||
}
|
||||
}
|
||||
|
|
@ -2763,7 +2763,7 @@ sub www_getThingsViaAjax {
|
|||
return JSON->new->encode(\@visibleThings);
|
||||
}
|
||||
else {
|
||||
$session->http->setStatus(404);
|
||||
$session->response->status(404);
|
||||
return JSON->new->encode({message => "No visible Things were found in this Thingy."});
|
||||
}
|
||||
}
|
||||
|
|
@ -3123,7 +3123,7 @@ sub www_searchViaAjax {
|
|||
my $i18n = WebGUI::International->new($self->session,"Asset_Thingy");
|
||||
|
||||
unless ($thingId) {
|
||||
$session->http->setStatus(400);
|
||||
$session->response->status(400);
|
||||
return JSON->new->encode({message => "Can't perform search without a thingId."});
|
||||
}
|
||||
|
||||
|
|
@ -3138,7 +3138,7 @@ sub www_searchViaAjax {
|
|||
return JSON->new->encode($var);
|
||||
}
|
||||
else {
|
||||
$session->http->setStatus(404);
|
||||
$session->response->status(404);
|
||||
return JSON->new->encode({message => "The thingId you requested can not be found."});
|
||||
}
|
||||
}
|
||||
|
|
@ -3557,7 +3557,7 @@ sub www_viewThingDataViaAjax {
|
|||
$session->http->setMimeType("application/json");
|
||||
|
||||
unless ($thingId && $thingDataId) {
|
||||
$session->http->setStatus(400);
|
||||
$session->response->status(400);
|
||||
return JSON->new->encode({message => "Can't get thing data without a thingId and a thingDataId."});
|
||||
}
|
||||
|
||||
|
|
@ -3572,12 +3572,12 @@ sub www_viewThingDataViaAjax {
|
|||
return JSON->new->encode($output);
|
||||
}
|
||||
else{
|
||||
$session->http->setStatus(404);
|
||||
$session->response->status(404);
|
||||
return JSON->new->encode({message => "The thingDataId you requested can not be found."});
|
||||
}
|
||||
}
|
||||
else {
|
||||
$session->http->setStatus(404);
|
||||
$session->response->status(404);
|
||||
return JSON->new->encode({message => "The thingId you requested can not be found."});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ sub addChild {
|
|||
my $temp = WebGUI::Asset->newByPropertyHashRef($session, $properties) || croak "Couldn't create a new $properties->{className} asset!";
|
||||
my $newAsset = $temp->addRevision($properties, $now, $options);
|
||||
$self->updateHistory("added child ".$id);
|
||||
$session->http->setStatus(201);
|
||||
$session->response->status(201);
|
||||
return $newAsset;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -975,7 +975,7 @@ sub www_createAccountSave {
|
|||
return undef;
|
||||
}
|
||||
else {
|
||||
$self->session->http->setStatus(201);
|
||||
$self->session->response->status(201);
|
||||
}
|
||||
|
||||
return undef;
|
||||
|
|
|
|||
|
|
@ -786,7 +786,7 @@ sub www_displayLogin {
|
|||
sub www_login {
|
||||
my $self = shift;
|
||||
if(!$self->authenticate($self->session->form->process("username"),$self->session->form->process("identifier"))){
|
||||
$self->session->http->setStatus(401);
|
||||
$self->session->response->status(401);
|
||||
$self->session->log->security("login to account ".$self->session->form->process("username")." with invalid information.");
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
return $self->www_displayLogin("<h1>".$i18n->get(70)."</h1>".$self->error);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ sub dispatch {
|
|||
# display from cache if page hasn't been modified.
|
||||
if ($session->user->isVisitor
|
||||
&& !$session->http->ifModifiedSince($asset->getContentLastModified, $session->setting->get('maxCacheTimeout'))) {
|
||||
$session->http->setStatus("304","Content Not Modified");
|
||||
$session->response->status("304");
|
||||
$session->http->sendHeader;
|
||||
return "chunked";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ The content handler for this package.
|
|||
|
||||
sub handler {
|
||||
my ($session) = @_;
|
||||
$session->http->setStatus(404);
|
||||
$session->response->status(404);
|
||||
my $output = "";
|
||||
my $notFound = WebGUI::Asset->getNotFound($session);
|
||||
if (defined $notFound) {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ The content handler for this package.
|
|||
sub handler {
|
||||
my ($session) = @_;
|
||||
if ($session->request->env->{"HTTP_X_MOZ"} eq "prefetch") { # browser prefetch is a bad thing
|
||||
$session->http->setStatus(403);
|
||||
$session->response->status(403);
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -354,7 +354,7 @@ sub www_ajaxCreateUser {
|
|||
# Verify access
|
||||
if ( !canAdd($session) || !canUseService($session) ) {
|
||||
# We need an automatic way to send a request for an http basic auth
|
||||
$session->http->setStatus(401);
|
||||
$session->response->status(401);
|
||||
return createServiceResponse( $outputFormat, {
|
||||
error => "WebGUI::Error::Unauthorized",
|
||||
message => "",
|
||||
|
|
@ -441,7 +441,7 @@ sub www_ajaxDeleteUser {
|
|||
# Verify access
|
||||
if ( !canEdit($session) || !canUseService($session) ) {
|
||||
# We need an automatic way to send a request for an http basic auth
|
||||
$session->http->setStatus(401);
|
||||
$session->response->status(401);
|
||||
return createServiceResponse( $outputFormat, {
|
||||
error => "WebGUI::Error::Unauthorized",
|
||||
message => "",
|
||||
|
|
@ -458,7 +458,7 @@ sub www_ajaxDeleteUser {
|
|||
} );
|
||||
}
|
||||
elsif ( $userId eq "1" || $userId eq "3" ) {
|
||||
$session->http->setStatus(403);
|
||||
$session->response->status(403);
|
||||
return createServiceResponse( $outputFormat, {
|
||||
error => 'WebGUI::Error::InvalidParam',
|
||||
param => 'userId',
|
||||
|
|
@ -508,7 +508,7 @@ sub www_ajaxUpdateUser {
|
|||
# Verify access
|
||||
if ( !canEdit($session) || !canUseService($session) ) {
|
||||
# We need an automatic way to send a request for an http basic auth
|
||||
$session->http->setStatus(401);
|
||||
$session->response->status(401);
|
||||
return createServiceResponse( $outputFormat, {
|
||||
error => "WebGUI::Error::Unauthorized",
|
||||
message => "",
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ sub _httpBasicLogin {
|
|||
$self->session->request->headers_out->set(
|
||||
'WWW-Authenticate' => 'Basic realm="'.$self->session->setting->get('companyName').'"'
|
||||
);
|
||||
$self->session->http->setStatus(401);
|
||||
$self->session->response->status(401);
|
||||
$self->session->http->sendHeader;
|
||||
return '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -715,7 +715,7 @@ sub www_processRecurringTransactionPostback {
|
|||
# First check whether the original transaction actualy exists
|
||||
if (WebGUI::Error->caught || !(defined $baseTransaction) ) {
|
||||
$session->log->warn("Check recurring postback: No base transction for XID: [$originatingXid]");
|
||||
$session->http->setStatus(500);
|
||||
$session->response->status(500);
|
||||
return "Check recurring postback. No base transction for XID: [$originatingXid]";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -360,7 +360,7 @@ sub addFileFromFormPost {
|
|||
my $attachmentLimit = shift || 99999;
|
||||
my $session = $self->session;
|
||||
return ""
|
||||
if ($self->session->http->getStatus eq '413');
|
||||
if ($self->session->response->status eq '413');
|
||||
my $filename;
|
||||
my $attachmentCount = 1;
|
||||
foreach my $upload ($session->request->upload($formVariableName)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue