Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.3 KiB

  1. package CGI::Apache;
  2. use Apache ();
  3. use vars qw(@ISA $VERSION);
  4. require CGI;
  5. @ISA = qw(CGI);
  6. $VERSION = (qw$Revision: 1.1 $)[1];
  7. $CGI::DefaultClass = 'CGI::Apache';
  8. $CGI::Apache::AutoloadClass = 'CGI';
  9. sub import {
  10. my $self = shift;
  11. my ($callpack, $callfile, $callline) = caller;
  12. ${"${callpack}::AutoloadClass"} = 'CGI';
  13. }
  14. sub new {
  15. my($class) = shift;
  16. my($r) = Apache->request;
  17. %ENV = $r->cgi_env unless defined $ENV{GATEWAY_INTERFACE}; #PerlSetupEnv On
  18. my $self = $class->SUPER::new(@_);
  19. $self->{'.req'} = $r;
  20. $self;
  21. }
  22. sub header {
  23. my ($self,@rest) = CGI::self_or_default(@_);
  24. my $r = $self->{'.req'};
  25. $r->basic_http_header;
  26. return CGI::header($self,@rest);
  27. }
  28. sub print {
  29. my($self,@rest) = CGI::self_or_default(@_);
  30. $self->{'.req'}->print(@rest);
  31. }
  32. sub read_from_client {
  33. my($self, $fh, $buff, $len, $offset) = @_;
  34. my $r = $self->{'.req'} || Apache->request;
  35. return $r->read($$buff, $len, $offset);
  36. }
  37. sub new_MultipartBuffer {
  38. my $self = shift;
  39. my $new = CGI::Apache::MultipartBuffer->new($self, @_);
  40. $new->{'.req'} = $self->{'.req'} || Apache->request;
  41. return $new;
  42. }
  43. package CGI::Apache::MultipartBuffer;
  44. use vars qw(@ISA);
  45. @ISA = qw(MultipartBuffer);
  46. $CGI::Apache::MultipartBuffer::AutoloadClass = 'MultipartBuffer';
  47. *CGI::Apache::MultipartBuffer::read_from_client =
  48. \&CGI::Apache::read_from_client;
  49. 1;
  50. __END__
  51. =head1 NAME
  52. CGI::Apache - Make things work with CGI.pm against Perl-Apache API
  53. =head1 SYNOPSIS
  54. require CGI::Apache;
  55. my $q = new Apache::CGI;
  56. $q->print($q->header);
  57. #do things just like you do with CGI.pm
  58. =head1 DESCRIPTION
  59. When using the Perl-Apache API, your applications are faster, but the
  60. environment is different than CGI.
  61. This module attempts to set-up that environment as best it can.
  62. =head1 NOTE 1
  63. This module used to be named Apache::CGI. Sorry for the confusion.
  64. =head1 NOTE 2
  65. If you're going to inherit from this class, make sure to "use" it
  66. after your package declaration rather than "require" it. This is
  67. because CGI.pm does a little magic during the import() step in order
  68. to make autoloading work correctly.
  69. =head1 SEE ALSO
  70. perl(1), Apache(3), CGI(3)
  71. =head1 AUTHOR
  72. Doug MacEachern E<lt>dougm@osf.orgE<gt>, hacked over by Andreas KE<ouml>nig E<lt>a.koenig@mind.deE<gt>, modified by Lincoln Stein <lt>lstein@genome.wi.mit.edu<gt>
  73. =cut