| Solstice documentation | view source | Contained in the Solstice distribution. |
Solstice::Server::ModPerl::API - An interface to mod_perl that abstracts the differences in versions.
use Solstice::Server::ModPerl::API;
An interface to mod_perl that abstracts the differences in versions.
Returns a boolean for whether Apache[2]::Request should be used in preference of CGI.
Sets the version of mod_perl
Gets the version of mod_perl.
Sets the maximum post size.
Gets the maximum post size.
Returns whether the version is 2.
Returns whether the version is 1.
Sets the apache request object that is passed to the mod_perl handler.
Gets the apache request object.
Gets the apache request object that is provided by libapreq.
sub sendfile { my $self = shift; if ($self->is2()) { return $self->request()->sendfile(@_); } else { return $self->request()->send_fd(@_); } }
sub uri { my $self = shift; return $self->request()->uri(@_); }
sub args { my $self = shift; return $self->request()->args(@_); }
sub filename { my $self = shift; return $self->request()->filename(@_); }
sub set_last_modified { my $self = shift; return $self->request()->set_last_modified(@_); }
sub set_etag { my $self = shift; return $self->request()->set_etag(@_); }
sub set_content_length { my $self = shift; return $self->request()->set_content_length(@_); }
sub set_content_disposition { my $self = shift; my $input = shift; return $self->header_out('Content-Disposition', $input); }
sub set_content_type { my $self = shift; return $self->content_type(@_); }
sub content_type { my $self = shift; my $type = shift; if( $type ){ $self->request()->content_type($type); }else{ return $self->request()->content_type(); } }
sub update_mtime { my $self = shift; return $self->request()->update_mtime(@_); }
sub meets_conditions { my $self = shift; return $self->request()->meets_conditions(@_);
}
sub method { my $self = shift; return $self->request()->method(@_); }
sub header_only { my $self = shift; return $self->request()->header_only(@_); }
sub header_in { my $self = shift; my $header = shift;
if($self->is2()){
return $self->request()->headers_in->{$header};
}else{
return $self->request()->header_in($header);
}
}
sub header_out { my $self = shift; my $header = shift; my $value = shift;
my $r = $self->request();
if ($self->is2()) {
return $r->headers_out->add($header => $value);
} else {
return $self->request()->header_out($header => $value);
}
}
#I don't believe this method is used any longer, if you see this after nov 2007 or so, remove it sub send_http_header { my $self = shift;
if($self->is2()) {
#there is no equivalent to send_http_header in mp2
#mp2 should handle this correctly now, we might need to look into rflush if we find this
#is not good enough
}else {
return $self->request()->send_http_header();
}
}
Sets the statuscode of the response
Returns the equivalent Apache::Constant or Apache2::Const, depending on what version of mod_perl you're using.
sub get_handlers { my $self = shift; if ($self->is2()) { # Allegedly you can just do the following: # return Apache2::ServerUtil->server->get_handlers(@_); # but i always get nothing. So, instead i traverse the config tree. # TODO: See if this is a known mod_perl2 bug, that we can upgrade past
my $handler_name = $_[0];
my $virtual_root = $ENV{'SOLSTICE_VIRTUAL_ROOT'};
my $tree = Apache2::Directive::conftree();
my $conf_data = $tree->as_hash;
my $vhost_data = $conf_data->{'VirtualHost'};
return [] unless defined $vhost_data;
foreach my $vhost (keys %{$vhost_data}) {
my $location_data = $vhost_data->{$vhost}->{'Location'};
return [] unless defined $location_data;
foreach my $location (keys %{$location_data}) {
# If this is handling the path given in config, and it's handled by Solstice, assume that this is the place.
# If there are multiple VHosts with Solstice handling the same virtual root, this could be problematic.
# Hopefully before that happens, we'll be able to use the get_handlers() method mentioned above.
if ($location eq $virtual_root && 'Solstice::Handler' eq $location_data->{$location}->{'PerlResponseHandler'}) {
return [$location_data->{$location}->{$handler_name}];
}
}
}
return [];
}
elsif ($self->is1()) {
return $self->request()->get_handlers(@_);
}
return [];
}
1; __END__
Catalyst Group, <catalyst@u.washington.edu>
$Revision$
Copyright 1998-2007 Office of Learning Technologies, University of Washington
Licensed under the Educational Community License, Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.opensource.org/licenses/ecl1.php
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
| Solstice documentation | view source | Contained in the Solstice distribution. |