/usr/lib/perl5/Apache2/Connection.pm is in libapache2-mod-perl2 2.0.8+httpd24-r1449661-6ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 | #
# /*
# * *********** WARNING **************
# * This file generated by ModPerl::WrapXS/0.01
# * Any changes made here will be lost
# * ***********************************
# * 01: lib/ModPerl/Code.pm:709
# * 02: lib/ModPerl/WrapXS.pm:633
# * 03: lib/ModPerl/WrapXS.pm:1182
# * 04: Makefile.PL:427
# * 05: Makefile.PL:329
# * 06: Makefile.PL:58
# */
#
package Apache2::Connection;
use strict;
use warnings FATAL => 'all';
use Apache2::XSLoader ();
our $VERSION = '2.000008';
Apache2::XSLoader::load __PACKAGE__;
1;
__END__
=head1 NAME
Apache2::Connection - Perl API for Apache connection object
=head1 Synopsis
use Apache2::Connection ();
use Apache2::RequestRec ();
my $c = $r->connection;
my $c = $r->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 Description
C<Apache2::RequestRec> provides the Perl API for Apache connection
record object.
=head1 API
C<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
=back
This 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 socket
if the optional argument C<$new_socket> was passed the previous socket
object 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<:remotehost
constant|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 reverse
lookup, regardless of the C<HostnameLookups> setting. The result is
the (double reverse checked) hostname, or undef if any of the lookups
fail.
=item C<Apache2::Const::REMOTE_HOST>
returns the hostname, or C<undef> if the hostname lookup fails. It
will 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 never
forced.
=back
Default value is C<Apache2::Const::REMOTE_NAME>.
=item opt arg2: C<$dir_config>
( C<L<Apache2::ConfVector object|docs::2.0::api::Apache2::RequestRec/C_per_dir_config_>> )
The directory config vector from the request. It's needed to find the
container in which the directive C<HostnameLookups> is set. To get one
for the current request use
C<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 if
C<HostnameLookups> was set to C<Off>.
=item ret: C<$remote_host> ( string/undef )
The remote hostname. If the configuration directive
B<HostNameLookups> is set to off, this returns the dotted decimal
representation of the client's IP address instead. Might return
C<undef> if the hostname is not known.
=item since: 2.0.00
=back
The result of C<get_remote_host> call is cached in
C<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 any
checkups.
=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 input
filters:
$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
=back
For an example see: L<Bucket Brigades-based Protocol
Module|docs::2.0::user::handlers::protocols/Bucket_Brigades_based_Protocol_Module>
=head2 C<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);
=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_keepalive
constant|docs::2.0::api::Apache2::Const/C__conn_keepalive_>> )
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
C<L<$r-E<gt>assbackwards|docs::2.0::api::Apache2::RequestRec/C_assbackwards_>>)
-- take a look at the ap_set_keepalive() function in
F<httpd-2.0/modules/http/http_protocol.c>.
=item ret: C<$status> ( C<L<:conn_keepalive
constant|docs::2.0::api::Apache2::Const/C__conn_keepalive_>> )
The method does B<not> return true or false, but one of the states
which can be compared against (C<L<:conn_keepalive
constants|docs::2.0::api::Apache2::Const/C__conn_keepalive_>>).
=item since: 2.0.00
=back
Unless you set this value yourself when implementing non-HTTP
protocols, 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
}
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 code
should make no assumptions and do things only if the desired state
matches.
=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 current
connection. Normally you won't do that when handling HTTP
requests. (But see below a note regarding
C<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't
count the current request. For the latter it'll count the current
request.
=item since: 2.0.00
=back
This method is only relevant for L<keepalive|/C_keepalive_>
connections. The core connection output filter
C<ap_http_header_filter> increments this value when the response
headers are sent and it decides that the connection should not be
closed (see C<ap_set_keepalive()>).
If you send your own set of HTTP headers with
C<L<$r-E<gt>assbackwards|docs::2.0::api::Apache2::RequestRec/C_assbackwards_>>,
which includes the C<Keep-Alive> HTTP response header, you must make
sure 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
=back
META: 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 can
be passed from one module to another (not only mod_perl, but modules
in 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
=back
Also see
C<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 output
filters:
$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
=back
For an example see: L<Bucket Brigades-based Protocol
Module|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 address
if the optional argument C<$new_remote_ip> was passed the previous
value 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 it
returns the cached value, which is a client DNS name or C<""> if it
wasn't found. If the check wasn't run -- C<undef> is returned.
=item since: 2.0.00
=back
It'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 API
C<Apache2::Connection> also provides auto-generated Perl interface for
a few other methods which aren't tested at the moment and therefore
their API is a subject to change. These methods will be finalized
later as a need arises. If you want to rely on any of the following
methods please contact the L<the mod_perl development mailing
list|maillist::dev> so we can help each other take the steps necessary
to shift the method to an officially supported API.
=head2 C<conn_config>
Config vector containing pointers to connections per-server config
structures
$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::RequestRec/C_per_dir_config_>> )
=item since: 2.0.00
=back
=head2 C<sbh>
META: Autogenerated - needs to be reviewed/completed
handle 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
=back
META: Not sure how this can be used from mod_perl at the
moment. Unless C<Apache2::Scoreboard> is extended to provide a hook to
read from this variable.
=head1 See Also
L<mod_perl 2.0 documentation|docs::2.0::index>.
=head1 Copyright
mod_perl 2.0 and its core modules are copyrighted under
The Apache Software License, Version 2.0.
=head1 Authors
L<The mod_perl development team and numerous
contributors|about::contributors::people>.
=cut
|