Apache-ASP
view release on metacpan or search on metacpan
lib/Apache/ASP/Response.pm view on Meta::CPAN
} else {
$asp->{dbg} &&
$asp->Debug("form fill for form of start length $start_length ".
"end length ".length($form));
}
$form;
}
/iexsg;
1;
}
sub FlushXSLT {
my $self = shift;
my $asp = $self->{asp};
my $xml_out = $self->{BinaryRef};
return unless length($$xml_out); # could happen after a redirect
$asp->{xslt_match} = &config($asp, 'XSLTMatch') || '^.';
return unless ($asp->{filename} =~ /$asp->{xslt_match}/);
## XSLT FETCH & CACHE
$asp->{dbg} && $asp->Debug("xslt processing with $asp->{xslt}");
my $xsl_dataref = $self->TrapInclude($asp->{xslt});
$asp->{dbg} && $asp->Debug(length($$xsl_dataref)." bytes in XSL $xsl_dataref");
return if($asp->{errs});
## XSLT XML RENDER
eval {
my $xslt_data = $asp->XSLT($xsl_dataref, $xml_out);
$asp->{dbg} && $asp->Debug("xml_out $xml_out length ".length($$xml_out)." set to $xslt_data length ".
length($$xslt_data));
${$self->{BinaryRef}} = $$xslt_data;
};
if($@) {
$@ =~ s/^\s*//s;
$asp->Error("XSLT/XML processing error: $@");
return;
}
1;
}
sub IsClientConnected {
my $self = shift;
return(0) if ! $self->{IsClientConnected};
# must init Request first for the aborted test to be meaningful.
# it seems that under mod_perl 1.25, apache 1.20 on a fast local network,
# if $r->connection->aborted is checked on a file upload before $Request
# is initialized, then aborted will return true, even under normal use.
# This causes a file upload script to not render any output. It may be that this
# check was done too fast for apache, where it might have still been setting
# up the upload, so not to check the outbound client connection yet
#
unless($self->{asp}{Request}) {
$self->{asp}->Out("need to init Request object before running Response->IsClientConnected");
return 1;
}
# IsClientConnected ? Might already be disconnected for busy site, if
# a user hits stop/reload
my $conn = $self->{r}->connection;
my $is_connected = $conn->aborted ? 0 : 1;
if($is_connected) {
my $fileno = eval { $conn->fileno };
if(defined $fileno) {
# sleep 3;
# my $s = IO::Select->new($fileno);
# $is_connected = $s->can_read(0) ? 0 : 1;
# much faster than IO::Select interface() which calls
# a few perl OO methods to construct & then can_read()
my $bits = '';
vec($bits, $fileno, 1) = 1;
$is_connected = select($bits, undef, undef, 0) > 0 ? 0 : 1;
if(! $is_connected) {
$self->{asp}{dbg} && $self->{asp}->Debug("client is no longer connected, detected via Apache->request->connetion->fileno");
}
}
}
$self->{IsClientConnected} = $is_connected;
if(! $is_connected) {
$self->{asp}{dbg} && $self->{asp}->Debug("client is no longer connected");
}
$is_connected;
}
# use the apache internal redirect? Thought that would be counter
# to portability, but is still something to consider
sub Redirect {
my($self, $location) = @_;
my $asp = $self->{asp};
my $r = $self->{r};
$asp->{dbg} && $asp->Debug('redirect called', {location=>$location});
# X: maybe this instead, so no session-id on normal redirects?
# if($asp->{Session}) {
# $location = $asp->{Server}->URL($location);
if($asp->{Session} and $asp->{session_url_parse}) {
$location = &SessionQueryParseURL($self, $location);
$asp->{dbg} && $asp->Debug("new location after session query parsing $location");
}
$r->headers_out->set('Location', $location);
$self->{Status} = 302;
$r->status(302);
# Always SendHeaders() immediately for a Redirect() ... only in a SoftRedirect
# will execution continue. Since we call SendHeaders here, instead of
# Flush() a Redirect() will still work even in a XMLSubs call where Flush is
# trapped to Null()
&SendHeaders($self);
# if we have soft redirects, keep processing page after redirect
if(&config($asp, 'SoftRedirect')) {
( run in 1.859 second using v1.01-cache-2.11-cpan-39bf76dae61 )