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