home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / Connection.pm < prev    next >
Encoding:
Perl POD Document  |  2004-09-23  |  16.0 KB  |  809 lines

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