NAME

Apache::Connection - Perl API for Apache connection object

Synopsis

use Apache::Connection ();

META: to be completed

Description

META: to be completed

API

Apache::Connection provides the following functions and/or methods:

aborted

Check whether the connection is still open

$status = $c->aborted();
arg1: $c (Apache::Connection)
ret: $status (number)

true if the connection has been aborted, false if still open

base_server

Physical vhost this connection came in on

$base_server = $c->base_server();
arg1: $c (Apache::Connection)
ret: $base_server (Apache::Server)

bucket_alloc

META: Autogenerated - needs to be reviewed/completed

The bucket allocator to use for all bucket/brigade creations

$ba = $c->bucket_alloc();
arg1: $c (Apache::Connection)
ret: $ba (APR::BucketAlloc)

conn_config

META: Autogenerated - needs to be reviewed/completed

Notes on *this* connection

$ret = $c->conn_config();
arg1: $c (Apache::Connection)
ret: $ret (Apache::ConfVector)

id

ID of this connection; unique at any point in time

$id = $c->id();
arg1: $c (Apache::Connection)
ret: $id (integer)

input_filters

A list of input filters to be used for this connection

$input_filters = $c->input_filters();
arg1: $c (Apache::Connection)
ret: $input_filters (Apache::Filter)

The first filter in the connection input filters chain.

keepalive

This method answers the question: Should the the connection be kept alive for another HTTP request after the current request is completed?

$status = $c->keepalive();
$status = $c->keepalive($new_status);
arg1: $c (Apache::Connection)
arg2 opt: $new_status (:conn_keepalive constant)

Normally you should not mess with setting this option when handling the HTTP protocol. If you do (for example when sending your own headers set with $r->assbackwards) -- take a look at the ap_set_keepalive() function in httpd-2.0/modules/http/http_protocol.c.

ret: $status (:conn_keepalive constant)

The method does not return true or false, but one of the states which can be compared against (:conn_keepalive constants).

since: 1.99_13

Unless you set this value yourself when implementing non-HTTP protocols, it's only relevant for HTTP requests.

For example:

use Apache::RequestRec ();
use Apache::Connection ();

use Apache::Const -compile => qw(:conn_keepalive);
...
my $c = $r->connection;
if ($c->keepalive == Apache::CONN_KEEPALIVE) {
    # do something
}
elsif ($c->keepalive == Apache::CONN_CLOSE) {
    # do something else
}
elsif ($c->keepalive == Apache::CONN_UNKNOWN) {
    # do yet something else
}
else {
    # die "unknown state";
}

Notice that new states could be added later by Apache, so your code should make no assumptions and do things only if the desired state matches.

keepalives

How many requests were already served over the current connection.

$served = $c->keepalives();
$served = $c->keepalives($new_served);
arg1: $c (Apache::Connection)
arg1 opt: $new_served (integer)

Set the number of served requests over the current connection. Normally you won't do that when handling HTTP requests. (But see below a note regarding $r->assbackwards).

ret: $served (integer)

How many requests were already served over the current connection.

In most handlers, but HTTP output filter handlers, that value doesn't count the current request. For the latter it'll count the current request.

since: 1.99_13

This method is only relevant for keepalive connections. The core connection output filter ap_http_header_filter increments this value when the response headers are sent and it decides that the connection should not be closed (see ap_set_keepalive()).

If you send your own set of HTTP headers with $r->assbackwards, which includes the Keep-Alive HTTP response header, you must make sure to increment the keepalives counter.

local_addr

Get this connection's local socket address

$sa = $c->local_addr();
arg1: $c (Apache::Connection)
ret: $sa (APR::SockAddr)

local_host

used for ap_get_server_name when UseCanonicalName is set to DNS (ignores setting of HostnameLookups)

$local_host = $c->local_host();
arg1: $c (Apache::Connection)
ret: $local_host (string)

local_ip

server IP address

$local_ip = $c->local_ip();
arg1: $c (Apache::Connection)
ret: $local_ip (string)

notes

META: Autogenerated - needs to be reviewed/completed

send note from one module to another, must remain valid for all requests on this conn

$c->notes($notes);
$notes = $c->notes();
arg1: $c (Apache::Connection)
arg2: $notes (APR::Table)
ret:

output_filters

META: Autogenerated - needs to be reviewed/completed

A list of output filters to be used for this connection

$output_filters = $c->output_filters();
arg1: $c (Apache::Connection)
ret: $output_filters (Apache::Filter)

The first filter in the connection output filters chain.

pool

Pool associated with this connection

$p = $c->pool();
arg1: $c (Apache::Connection)
ret: $p (APR::Pool)

remote_addr

Get this connection's remote socket address

$sa = $c->remote_addr();
arg1: $c (Apache::Connection)
ret: $sa (APR::SockAddr)

remote_ip

Client's IP address

$remote_ip = $c->remote_ip();
arg1: $c (Apache::Connection)
ret: $remote_ip (string)

remote_host

Client's DNS name, if known. NULL if DNS hasn't been checked, "" if it has and no address was found. N.B. Only access this though get_remote_host()

$remote_host = $c->remote_host();
arg1: $c (Apache::Connection)
ret: $remote_host (string)

remote_logname

Only ever set if doing rfc1413 lookups. N.B. Only access this through get_remote_logname()

$remote_logname = $c->remote_logname();
arg1: $c (Apache::Connection)
ret: $remote_logname (string)

sbh

META: Autogenerated - needs to be reviewed/completed

handle to scoreboard information for this connection

$sbh = $c->sbh();
arg1: $c (Apache::Connection)
ret: $sbh (XXX)

See Also

mod_perl 2.0 documentation.

Copyright

mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 1.1.

Authors

The mod_perl development team and numerous contributors.