📄 connection.pm
字号:
# # /*# * *********** WARNING **************# * This file generated by ModPerl::WrapXS/0.01# * Any changes made here will be lost# * ***********************************# * 01: lib/ModPerl/Code.pm:708# * 02: lib/ModPerl/WrapXS.pm:624# * 03: lib/ModPerl/WrapXS.pm:1173# * 04: Makefile.PL:423# * 05: Makefile.PL:325# * 06: Makefile.PL:56# */# package Apache2::Connection;use strict;use warnings FATAL => 'all';use Apache2::XSLoader ();our $VERSION = '2.000002';Apache2::XSLoader::load __PACKAGE__;1;__END__=head1 NAMEApache2::Connection - Perl API for Apache connection object=head1 Synopsis use Apache2::Connection (); # is connection still open? $status = $c->aborted; # base server $base_server = $c->base_server(); # needed for creating buckets/brigades $ba = $c->bucket_alloc(); # client's socket $socket = $c->client_socket; # unique connection id $id = $c->id(); # connection filters stack $input_filters = $c->input_filters(); $output_filters = $c->output_filters(); # keep the connection alive? $status = $c->keepalive(); # how many requests served over the current connection $served = $c->keepalives(); # this connection's local and remote socket addresses $local_sa = $c->local_addr(); $remote_sa = $c->remote_addr(); # local and remote hostnames $local_host = $c->local_host(); $remote_host = $c->get_remote_host(); $remote_host = $c->remote_host(); # server and remote client's IP addresses $local_ip = $c->local_ip(); $remote_ip = $c->remote_ip(); # connection level Apache notes $notes = $c->notes(); # this connection's pool $p = $c->pool();=head1 DescriptionC<Apache2::RequestRec> provides the Perl API for Apache connectionrecord object.=head1 APIC<Apache2::Connection> provides the following functions and/or methods:=head2 C<aborted>Check whether the connection is still open $status = $c->aborted();=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item ret: C<$status> ( boolean )true if the connection has been aborted, false if still open=item since: 2.0.00=back=head2 C<base_server>Physical server this connection came in on (main server or vhost): $base_server = $c->base_server();=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item ret: C<$base_server>( C<L<Apache2::Server object|docs::2.0::api::Apache2::ServerRec>> )=item since: 2.0.00=back=head2 C<bucket_alloc>The bucket allocator to use for all bucket/brigade creations $ba = $c->bucket_alloc();=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item ret: C<$ba>( C<L<APR::BucketAlloc object|docs::2.0::api::APR::BucketAlloc>> )=item since: 2.0.00=backThis object is needed by C<L<APR::Bucket|docs::2.0::api::APR::Bucket>>and C<L<APR::Brigade|docs::2.0::api::APR::Brigade>> methods/functions.=head2 C<client_socket>Get/set the client socket $socket = $c->client_socket; $prev_socket = $c->client_socket($new_socket);=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item opt arg1: C<$new_socket>( C<L<APR::Socket object|docs::2.0::api::APR::Socket>> object )If passed a new socket will be set.=item ret: C<$socket>( C<L<APR::Socket object|docs::2.0::api::APR::Socket>> object )current client socketif the optional argument C<$new_socket> was passed the previous socketobject is returned.=item since: 2.0.00=back=head2 C<get_remote_host>Lookup the client's DNS hostname or IP address $remote_host = $c->remote_host(); $remote_host = $c->remote_host($type); $remote_host = $c->remote_host($type, $dir_config);=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )The current connection=item opt arg1: C<$type> ( C<L<:remotehostconstant|docs::2.0::api::Apache2::Const/C__remotehost_>> )The type of lookup to perform:=over=item C<Apache2::Const::REMOTE_DOUBLE_REV>will always force a DNS lookup, and also force a double reverselookup, regardless of the C<HostnameLookups> setting. The result isthe (double reverse checked) hostname, or undef if any of the lookupsfail.=item C<Apache2::Const::REMOTE_HOST>returns the hostname, or C<undef> if the hostname lookup fails. Itwill force a DNS lookup according to the C<HostnameLookups> setting.=item C<Apache2::Const::REMOTE_NAME>returns the hostname, or the dotted quad if the hostname lookup fails.It will force a DNS lookup according to the C<HostnameLookups>setting.=item C<Apache2::Const::REMOTE_NOLOOKUP>is like C<Apache2::Const::REMOTE_NAME> except that a DNS lookup is neverforced.=backDefault value is C<Apache2::Const::REMOTE_NAME>.=item opt arg2: C<$dir_config>( C<L<Apache2::ConfVector object|docs::2.0::api::Apache2::ConfVector>> )The directory config vector from the request. It's needed to find thecontainer in which the directive C<HostnameLookups> is set. To get onefor the current request useC<L<$r-E<gt>per_dir_config|docs::2.0::api::Apache2::RequestRec/C_per_dir_config_>>.By default, C<undef> is passed, in which case it's the same as ifC<HostnameLookups> was set to C<Off>.=item ret: C<$remote_host> ( string/undef )The remote hostname. If the configuration directiveB<HostNameLookups> is set to off, this returns the dotted decimalrepresentation of the client's IP address instead. Might returnC<undef> if the hostname is not known.=item since: 2.0.00=backThe result of C<get_remote_host> call is cached inC<L<$c-E<gt>remote_host|/C_remote_host_>>. If the latter is set,C<get_remote_host> will return that value immediately, w/o doing anycheckups.=head2 C<id>ID of this connection; unique at any point in time $id = $c->id();=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item ret: C<$id> (integer)=item since: 2.0.00=back=head2 C<input_filters>Get/set the first filter in a linked list of protocol level inputfilters: $input_filters = $c->input_filters(); $prev_input_filters = $c->input_filters($new_input_filters);=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item opt arg1: C<$new_input_filters>Set a new value=item ret: C<$input_filters>( C<L<Apache2::Filter object|docs::2.0::api::Apache2::Filter>> )The first filter in the connection input filters chain.If C<$new_input_filters> was passed, returns the previous value.=item since: 2.0.00=backFor an example see: L<Bucket Brigades-based ProtocolModule|docs::2.0::user::handlers::protocols/Bucket_Brigades_based_Protocol_Module>=head2 C<keepalive>This method answers the question: Should the the connection be keptalive for another HTTP request after the current request is completed? $status = $c->keepalive(); $status = $c->keepalive($new_status);=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item opt arg1: C<$new_status> ( C<L<:conn_keepaliveconstant|docs::2.0::api::Apache2::Const/C__conn_keepalive_>> )Normally you should not mess with setting this option when handlingthe HTTP protocol. If you do (for example when sending your ownheaders set withC<L<$r-E<gt>assbackwards|docs::2.0::api::Apache2::RequestRec/C_assbackwards_>>)-- take a look at the ap_set_keepalive() function inF<httpd-2.0/modules/http/http_protocol.c>.=item ret: C<$status> ( C<L<:conn_keepaliveconstant|docs::2.0::api::Apache2::Const/C__conn_keepalive_>> )The method does B<not> return true or false, but one of the stateswhich can be compared against (C<L<:conn_keepaliveconstants|docs::2.0::api::Apache2::Const/C__conn_keepalive_>>).=item since: 2.0.00=backUnless you set this value yourself when implementing non-HTTPprotocols, it's only relevant for HTTP requests.For example: use Apache2::RequestRec (); use Apache2::Connection (); use Apache2::Const -compile => qw(:conn_keepalive); ... my $c = $r->connection; if ($c->keepalive == Apache2::Const::CONN_KEEPALIVE) { # do something } elsif ($c->keepalive == Apache2::Const::CONN_CLOSE) { # do something else }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -