Apache2-ASP

 view release on metacpan or  search on metacpan

inc/Module/Install.pm  view on Meta::CPAN






# If the script that is loading Module::Install is from the future,
# then make will detect this and cause it to re-run over and over
# again. This is bad. Rather than taking action to touch it (which
# is unreliable on some platforms and requires write permissions)
# for now we should catch this and refuse to run.
if ( -f $0 and (stat($0))[9] > time ) { die <<"END_DIE" }

Your installer $0 has a modification time in the future.

This is known to create infinite loops in make.

Please correct this, then run $0 again.

END_DIE


lib/Apache2/ASP/ASPHandler.pm  view on Meta::CPAN

  my $pm_folder = $cache_root . '/' . $Config->web->application_name;
  my $pm_path = $pm_folder . '/' . $pm_filename;
  mkdir( $pm_folder ) unless -d $pm_folder;
  my $pkg_path = $Config->web->application_name . '/' . $pm_filename;
  
  push @INC, $cache_root unless grep { $_ eq $cache_root } @INC;
  if( -f $asp_filename )
  {
    (my $pkg_name = $pkg_path) =~ s/\//::/g;
    $pkg_name =~ s/\.pm$//;
    if( ( ! -f $pm_path ) || ((stat($asp_filename))[9] > (stat($pm_path))[9] ) )
    {
      require Apache2::ASP::ASPPage;
      Apache2::ASP::ASPPage->init_asp_objects( $context );
      Apache2::ASP::ASPPage->new( virtual_path => $ENV{SCRIPT_NAME} );
    }# end if()
    
    # Now load and execute the compiled ASP:
#    eval {
      delete($INC{$pkg_path});
      require $pkg_path;

lib/Apache2/ASP/ASPPage.pm  view on Meta::CPAN

  }# end foreach()
  
  my $pkg = $s->virtual_path;
  $pkg =~ s/^\///;
  $pkg =~ s/[^a-z0-9_]/_/ig;
  $s->{package_name} = $s->context->config->web->application_name . '::' . $pkg;
  $s->{pm_path} = $pm_folder . '/' . $pkg . '.pm';
  my $pm_inc = $s->context->config->web->application_name . '/' . $pkg . '.pm';
  
  # Determine age of ASP and PM:
  my $asp_age = (stat($s->context->server->MapPath($s->virtual_path)))[9];
  no strict 'refs';
  my $timestamp = ${$s->package_name . "::TIMESTAMP"} || 0;
  my $pm_age  = (stat($s->pm_path))[9] || 0;

  if( ( ! $pm_age ) || ( $asp_age > $pm_age ) )
  {
#warn "(Re)compiling $pkg";
    delete( $INC{$pm_inc} );
    $s->_init_source_code();
    $s->parse;
    require $pm_inc;
  }
  elsif( $asp_age > $timestamp )

lib/Apache2/ASP/MediaManager.pm  view on Meta::CPAN

  $s->before_download( $context, $filename )
    or return;
  
  # Wait until "before_download" has cleared before we open a filehandle:
  my $ifh = $s->open_file_for_reading( $context, $filename );
  
  # Send any HTTP headers:
  $s->send_http_headers($context, $filename, $file, $ext);
  
  # Print the file out:
  if( (stat($ifh))[7] < 1024 ** 2 )
  {
    # File is < 1M, so just slurp and print:
    local $/;
    $context->response->Write( scalar(<$ifh>) );
  }
  else
  {
    while( my $line = <$ifh> )
    {
      $context->response->Write( $line );

lib/Apache2/ASP/MediaManager.pm  view on Meta::CPAN

  $s->after_download( $context, $filename );
}# end run()


#==============================================================================
sub send_http_headers
{
  my ($s, $context, $filename, $file, $ext) = @_;
  
  # Send the 'content-length' header:
  $context->r->err_headers_out->{'Content-Length'} = (stat($filename))[7];
  
  # PDF files should force the "Save file as..." dialog:
  my $disposition = (lc($ext) eq 'pdf') ? 'attachment' : 'inline';
  $file =~ s/\s/_/g;
  
  $context->r->err_headers_out->{'content-disposition'} = "$disposition;filename=" . $file . ';yay=yay';
}# end send_http_headers()


#==============================================================================

t/010-coverage/050-mediamanager.t  view on Meta::CPAN

  close($ofh);

  my $uploadID = int(rand() * 1000) . ':' . int(rand() * 1000);
  my $res = $api->ua->upload("/handlers/upload01?mode=create&uploadID=$uploadID", [
    uploaded_file => [ $upload_filename ]
  ]);


  my ($file) = 'asp-upload-test.txt';
  $res = $api->ua->get("/handlers/upload01?file=$file");
  is( length($res->content) => (stat($upload_filename))[7], "Uploaded/Downloaded filesizes match" );
}


# Now update that file:
{
  my $uploadID = int(rand() * 1000) . ':' . int(rand() * 1000);
  my $res = $api->ua->upload("/handlers/upload01?mode=edit&uploadID=$uploadID", [
    uploaded_file => [ $upload_filename ]
  ]);
}

t/010-coverage/050-mediamanager.t  view on Meta::CPAN

    print $ofh "."x1024, "\n";
  }# end for()
  close($ofh);
  my $uploadID = int(rand() * 1000) . ':' . int(rand() * 1000);
  my $res = $api->ua->upload("/handlers/upload01?mode=edit&uploadID=$uploadID", [
    uploaded_file => [ $upload_filename ]
  ]);
  
  my ($file) = 'asp-upload-test.txt';
  $res = $api->ua->get("/handlers/upload01?file=$file");
  is( length($res->content) => (stat($upload_filename))[7], "Uploaded/Downloaded filesizes match" );
}



# Try out a mode that doesn't exist:
{
  $api->ua->get('/handlers/upload01?mode=no-existo&file=sdf.txt');
}


t/010-coverage/050-mediamanager.t  view on Meta::CPAN

  close($ofh);

  my $uploadID = int(rand() * 1000) . ':' . int(rand() * 1000);
  my $res = $api->ua->upload("/handlers/upload01?mode=create&uploadID=$uploadID", [
    uploaded_file => [ $upload_filename ]
  ]);


  my ($file) = 'test-file.pdf';
  $res = $api->ua->get("/handlers/upload01?file=$file");
  is( length($res->content) => (stat($upload_filename))[7], "Uploaded/Downloaded filesizes match" );
}





( run in 1.440 second using v1.01-cache-2.11-cpan-49f99fa48dc )