📄 connection.pm
字号:
elsif ($c->keepalive == Apache2::Const::CONN_UNKNOWN) { # do yet something else } else { # die "unknown state"; }Notice that new states could be added later by Apache, so your codeshould make no assumptions and do things only if the desired statematches.=head2 C<keepalives>How many requests were already served over the current connection. $served = $c->keepalives(); $served = $c->keepalives($new_served);=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item opt arg1: C<$new_served> (integer)Set the number of served requests over the currentconnection. Normally you won't do that when handling HTTPrequests. (But see below a note regardingC<L<$r-E<gt>assbackwards|docs::2.0::api::Apache2::RequestRec/C_assbackwards_>>).=item ret: C<$served> (integer)How many requests were already served over the current connection.In most handlers, but HTTP output filter handlers, that value doesn'tcount the current request. For the latter it'll count the currentrequest.=item since: 2.0.00=backThis method is only relevant for L<keepalive|/C_keepalive_>connections. The core connection output filterC<ap_http_header_filter> increments this value when the responseheaders are sent and it decides that the connection should not beclosed (see C<ap_set_keepalive()>).If you send your own set of HTTP headers withC<L<$r-E<gt>assbackwards|docs::2.0::api::Apache2::RequestRec/C_assbackwards_>>,which includes the C<Keep-Alive> HTTP response header, you must makesure to increment the C<keepalives> counter.=head2 C<local_addr>Get this connection's local socket address $local_sa = $c->local_addr();=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item ret: C<$local_sa>( C<L<APR::SockAddr object|docs::2.0::api::APR::SockAddr>> )=item since: 2.0.00=back=head2 C<local_host>used for ap_get_server_name when UseCanonicalName is set to DNS(ignores setting of HostnameLookups) $local_host = $c->local_host();=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item ret: C<$local_host> (string)=item since: 2.0.00=backMETA: you probably shouldn't use this method, but (C<L<get_server_name|docs::2.0::api::Apache2::RequestUtil/C_get_server_name_>>) if inside request and C<$r> is available.=head2 C<local_ip>server IP address $local_ip = $c->local_ip();=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item ret: C<$local_ip> (string)=item since: 2.0.00=back=head2 C<notes>Get/set text notes for the duration of this connection. These notes canbe passed from one module to another (not only mod_perl, but modulesin any other language): $notes = $c->notes(); $prev_notes = $c->notes($new_notes);=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item opt arg1: C<$new_notes>( C<L<APR::Table object|docs::2.0::api::APR::Table>> )=item ret: C<$notes>( C<L<APR::Table object|docs::2.0::api::APR::Table>> )the current notes table.if the C<$new_notes> argument was passed, returns the previous value.=item since: 2.0.00=backAlso seeC<L<$r-E<gt>notes|docs::2.0::api::Apache2::RequestRec/C_notes_>>=head2 C<output_filters>Get the first filter in a linked list of protocol level outputfilters: $output_filters = $c->output_filters(); $prev_output_filters = $r->output_filters($new_output_filters);=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item opt arg1: C<$new_output_filters>Set a new value=item ret: C<$output_filters>( C<L<Apache2::Filter object|docs::2.0::api::Apache2::Filter>> )The first filter in the connection output filters chain.If C<$new_output_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<pool>Pool associated with this connection $p = $c->pool();=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item ret: C<$p>( C<L<APR::Pool object|docs::2.0::api::APR::Pool>> )=item since: 2.0.00=back=head2 C<remote_addr>Get this connection's remote socket address $remote_sa = $c->remote_addr();=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item ret: C<$remote_sa>( C<L<APR::SockAddr object|docs::2.0::api::APR::SockAddr>> )=item since: 2.0.00=back=head2 C<remote_ip>Client's IP address $remote_ip = $c->remote_ip(); $prev_remote_ip = $c->remote_ip($new_remote_ip);=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item opt arg1: C<$new_remote_ip> ( string )If passed a new value will be set=item ret: C<$remote_ip> ( string )current remote ip addressif the optional argument C<$new_remote_ip> was passed the previousvalue is returned.=item since: 2.0.00=back=head2 C<remote_host>Client's DNS name: $remote_host = $c->remote_host();=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item ret: C<$remote_host> ( string/undef )If C<L<$c-E<gt>get_remote_host|/C_get_remote_host_>> was run itreturns the cached value, which is a client DNS name or C<""> if itwasn't found. If the check wasn't run -- C<undef> is returned.=item since: 2.0.00=backIt's best to to call C<L<$c-E<gt>get_remote_host|/C_get_remote_host_>>instead of directly accessing this variable.=head1 Unsupported APIC<Apache2::Connection> also provides auto-generated Perl interface fora few other methods which aren't tested at the moment and thereforetheir API is a subject to change. These methods will be finalizedlater as a need arises. If you want to rely on any of the followingmethods please contact the L<the mod_perl development mailinglist|maillist::dev> so we can help each other take the steps necessaryto shift the method to an officially supported API.=head2 C<conn_config>Config vector containing pointers to connections per-server configstructures $ret = $c->conn_config();=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item ret: C<$ret>( C<L<Apache2::ConfVector object|docs::2.0::api::Apache2::ConfVector>> )=item since: 2.0.00=back=head2 C<sbh>META: Autogenerated - needs to be reviewed/completedhandle to scoreboard information for this connection $sbh = $c->sbh();=over 4=item obj: C<$c>( C<L<Apache2::Connection object|docs::2.0::api::Apache2::Connection>> )=item ret: C<$sbh> (XXX)=item since: 2.0.00=backMETA: Not sure how this can be used from mod_perl at themoment. Unless C<Apache2::Scoreboard> is extended to provide a hook toread from this variable.=head1 See AlsoL<mod_perl 2.0 documentation|docs::2.0::index>.=head1 Copyrightmod_perl 2.0 and its core modules are copyrighted underThe Apache Software License, Version 2.0.=head1 AuthorsL<The mod_perl development team and numerouscontributors|about::contributors::people>.=cut
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -