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 / RequestRec.pm < prev    next >
Encoding:
Perl POD Document  |  2004-09-23  |  41.8 KB  |  2,037 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::RequestRec;
  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::RequestRec - Perl API for Apache request record accessors
  34.  
  35.  
  36.  
  37.  
  38. =head1 Synopsis
  39.  
  40.   use Apache::RequestRec ();
  41.   
  42.   # set supported by the handler HTTP methods
  43.   $allowed = $r->allowed();
  44.   
  45.   # auth type
  46.   $auth_type = $r->ap_auth_type();
  47.   
  48.   # QUERY_STRING
  49.   $args = $r->args();
  50.   
  51.   # non-parsed-headers handler
  52.   $status = $r->assbackwards();
  53.   
  54.   # how many bytes were sent
  55.   $bytes_sent = $r->bytes_sent();
  56.   
  57.   # canonical filename
  58.   $canon_filename = $r->canonical_filename();
  59.   
  60.   # client connection record
  61.   $c = $r->connection();
  62.   
  63.   # "Content-Encoding" HTTP response header
  64.   $r->content_encoding("gzip");
  65.   
  66.   # the languages of the content
  67.   $languages = $r->content_languages();
  68.   
  69.   # "Content-Encoding" HTTP response header
  70.   $r->content_type('text/plain');
  71.   
  72.   # special response headers table
  73.   $err_headers_out = $r->err_headers_out();
  74.   
  75.   # request mapped filename
  76.   $filename = $r->filename();
  77.   
  78.   # request finfo
  79.   $finfo = $r->finfo();
  80.   
  81.   # 'SetHandler perl-script' equivalent
  82.   $r->handler('perl-script');
  83.   
  84.   # was it a HEAD request?
  85.   $status = $r->header_only();
  86.   
  87.   # request input headers table
  88.   $headers_in = $r->headers_in();
  89.   
  90.   # request output headers table
  91.   $headers_out = $r->headers_out();
  92.   
  93.   # hostname
  94.   $hostname = $r->hostname();
  95.   
  96.   # input filters stack
  97.   $input_filters = $r->input_filters();
  98.   
  99.   # get the main request obj in a sub-request
  100.   $main_r = $r->main();
  101.   
  102.   # what's the current request (GET/POST/etc)?
  103.   $method = $r->method();
  104.   
  105.   # what's the current method number?
  106.   $methnum = $r->method_number();
  107.   
  108.   # current resource last modified time
  109.   $mtime = $r->mtime();
  110.   
  111.   # next request object (in redirect)
  112.   $next_r = $r->next();
  113.   
  114.   # there is no local copy
  115.   $r->no_local_copy();
  116.   
  117.   # Apache ascii notes table
  118.   $notes = $r->notes();
  119.   
  120.   # output filters stack
  121.   $output_filters = $r->output_filters();
  122.   
  123.   # PATH_INFO
  124.   $path_info = $r->path_info();
  125.   
  126.   # used in configuration directives modules
  127.   $per_dir_config = $r->per_dir_config();
  128.   
  129.   # pool with life span of the current request
  130.   $p = $r->pool();
  131.   
  132.   # previous request object in the internal redirect
  133.   $prev_r = $r->prev();
  134.   
  135.   # connection level input filters stack
  136.   $proto_input_filters = $r->proto_input_filters();
  137.   
  138.   # HTTP protocol version number
  139.   $proto_num = $r->proto_num();
  140.   
  141.   # connection level output filters stack
  142.   $proto_output_filters = $r->proto_output_filters();
  143.   
  144.   # the protocol, the client speaks: "HTTP/1.0", "HTTP/1.1", etc.
  145.   $protocol = $r->protocol();
  146.   
  147.   # is it a proxy request
  148.   $status = $r->proxyreq($val);
  149.   
  150.   # Time when the request started
  151.   $request_time = $r->request_time();
  152.   
  153.   # server object
  154.   $s = $r->server();
  155.   
  156.   # response status
  157.   $status = $r->status();
  158.   
  159.   # response status line
  160.   $status_line = $r->status_line();
  161.   
  162.   # manipulate %ENV of the subprocess
  163.   $r->subprocess_env;
  164.   $r->subprocess_env($key => $val);
  165.   
  166.   # first HTTP request header
  167.   $request = $r->the_request();
  168.   
  169.   # the URI without any parsing performed
  170.   $unparsed_uri = $r->unparsed_uri();
  171.   
  172.   # The path portion of the URI
  173.   $uri = $r->uri();
  174.   
  175.   # auth username
  176.   $user = $r->user();
  177.  
  178.  
  179.  
  180.  
  181. =head1 Description
  182.  
  183. C<Apache::RequestRec> provides the Perl API for Apache request_rec
  184. object.
  185.  
  186. The following packages extend the C<Apache::RequestRec> functionality:
  187. C<L<Apache::Access|docs::2.0::api::Apache::Access>>,
  188. C<L<Apache::Log|docs::2.0::api::Apache::Log>>,
  189. C<L<Apache::RequestIO|docs::2.0::api::Apache::RequestIO>>,
  190. C<L<Apache::RequestUtil|docs::2.0::api::Apache::RequestUtil>>,
  191. C<L<Apache::Response|docs::2.0::api::Apache::Response>>,
  192. C<L<Apache::SubRequest|docs::2.0::api::Apache::SubRequest>> and
  193. C<L<Apache::URI|docs::2.0::api::Apache::URI>>.
  194.  
  195.  
  196.  
  197.  
  198.  
  199. =head1 API
  200.  
  201. C<Apache::RequestRec> provides the following functions and/or methods:
  202.  
  203.  
  204.  
  205. =head2 C<allowed>
  206.  
  207. Get/set the allowed methods bitmask.
  208.  
  209.   $allowed      = $r->allowed();
  210.   $prev_allowed = $r->allowed($new_allowed);
  211.  
  212. =over 4
  213.  
  214. =item obj: C<$r>
  215. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  216.  
  217. =item opt arg1: C<$new_allowed> ( bitmask )
  218.  
  219. Set the bitvector.
  220.  
  221. =item ret: C<$allowed> ( bitmask )
  222.  
  223. returns C<$allowed>, which is a bitvector of the allowed methods.
  224.  
  225. If the C<$new_allowed> argument is passed, the value before the change
  226. is returned.
  227.  
  228. =item since: 1.99_12
  229.  
  230. =back
  231.  
  232. A handler must ensure that the request method is one that it is
  233. capable of handling.  Generally modules should C<Apache::DECLINE> any
  234. request methods they do not handle.  Prior to aborting the handler
  235. like this the handler should set C<$r-E<gt>allowed> to the list of
  236. methods that it is willing to handle.  This bitvector is used to
  237. construct the C<"Allow:"> header required for C<OPTIONS> requests, and
  238. C<Apache::HTTP_METHOD_NOT_ALLOWED> (405) and
  239. C<Apache::HTTP_NOT_IMPLEMENTED> (501) status codes.
  240.  
  241. Since the default Apache handler deals with the C<OPTIONS> method, all
  242. response handlers can usually decline to deal with C<OPTIONS>. For
  243. example if the response handler handles only C<GET> and C<POST>
  244. methods, and not C<OPTIONS>, it may want to say:
  245.  
  246.    use Apache::Const -compile => qw(OK DECLINED M_GET M_POST M_OPTIONS);
  247.    if ($r->method_number == Apache::M_OPTIONS) {
  248.        $r->allowed($r->allowed | (1<<Apache::M_GET) | (1<<Apache::M_POST));
  249.        return Apache::DECLINED;
  250.    }
  251.  
  252. C<TRACE> is always allowed, modules don't need to set it explicitly.
  253.  
  254. Since the default_handler will always handle a C<GET>, a module which
  255. does *not* implement C<GET> should probably return
  256. C<Apache::HTTP_METHOD_NOT_ALLOWED>.  Unfortunately this means that a
  257. script C<GET> handler can't be installed by mod_actions.
  258.  
  259. For example, if the module can handle only POST method it could start
  260. with:
  261.  
  262.    use Apache::Const -compile => qw(M_POST HTTP_METHOD_NOT_ALLOWED);
  263.    unless ($r->method_number == Apache::M_POST) {
  264.        $r->allowed($r->allowed | (1<<Apache::M_POST));
  265.        return Apache::HTTP_METHOD_NOT_ALLOWED;
  266.    }
  267.  
  268.  
  269.  
  270.  
  271. =head2 C<ap_auth_type>
  272.  
  273. If an authentication check was made, get or set the I<ap_auth_type>
  274. slot in the request record
  275.  
  276.   $auth_type = $r->ap_auth_type();
  277.   $r->ap_auth_type($newval);
  278.  
  279. =over 4
  280.  
  281. =item obj: C<$r>
  282. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  283.  
  284. =item opt arg1: C<$newval> (string)
  285.  
  286. If this argument is passed then a new auth type is assigned. For example:
  287.  
  288.   $r->auth_type('Basic');
  289.  
  290. =item ret: C<$auth_type> (string)
  291.  
  292. If C<$newval> is passed, nothing is returned. Otherwise the current
  293. auth type is returned.
  294.  
  295. =item since: 1.99_12
  296.  
  297. =back
  298.  
  299. I<ap_auth_type> holds the authentication type that has been negotiated
  300. between the client and server during the actual request.  Generally,
  301. I<ap_auth_type> is populated automatically when you call
  302. C<$r-E<gt>get_basic_auth_pw> so you don't really need to worry too
  303. much about it, but if you want to roll your own authentication
  304. mechanism then you will have to populate I<ap_auth_type> yourself.
  305.  
  306. Note that C<$r-E<gt>ap_auth_type> was
  307. C<$r-E<gt>connection-E<gt>auth_type> in the mod_perl 1.0 API.
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315. =head2 C<args>
  316.  
  317. Get/set the request QUERY string
  318.  
  319.   $args      = $r->args();
  320.   $prev_args = $r->args($new_args);
  321.  
  322. =over 4
  323.  
  324. =item obj: C<$r>
  325. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  326.  
  327. =item opt arg1: C<$new_args> ( string )
  328.  
  329. Optinally set the new QUERY string
  330.  
  331. =item ret: C<$args> ( string )
  332.  
  333. The current QUERY string
  334.  
  335. If C<$new_args> was passed, returns the value before the change.
  336.  
  337. =item since: 1.99_12
  338.  
  339. =back
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349. =head2 C<assbackwards>
  350.  
  351. When set to a true value, Apache won't send any HTTP response headers
  352. allowing you to send any headers.
  353.  
  354.   $status      = $r->assbackwards();
  355.   $prev_status = $r->assbackwards($newval);
  356.  
  357. =over 4
  358.  
  359. =item obj: C<$r>
  360. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  361.  
  362. =item opt arg1: C<$newval> (integer)
  363.  
  364. assign a new state.
  365.  
  366. =item ret: C<$status> (integer)
  367.  
  368. current state.
  369.  
  370. =item since: 1.99_10
  371.  
  372. =back
  373.  
  374. If you send your own set of headers, which includes the C<Keep-Alive>
  375. HTTP response header, you must make sure to increment the number of
  376. requests served over this connection (which is normally done by the
  377. core connection output filter C<ap_http_header_filter>, but skipped
  378. when C<assbackwards> is enabled).
  379.  
  380.   $r->connection->keepalives($r->connection->keepalives + 1);
  381.  
  382. otherwise code relying on the value of
  383. C<L<$r-E<gt>connection-E<gt>keepalives|docs::2.0::api::Apache::Connection/C_keepalives_>>
  384. may malfunction. For example, this counter is used to tell when a new
  385. request is coming in over the same connection to a filter that wants
  386. to parse only HTTP headers (like
  387. C<Apache::Filter::HTTPHeadersFixup>). Of course you will need to set
  388. C<L<$r-E<gt>connection-E<gt>keepalive(1)|docs::2.0::api::Apache::Connection/C_keepalive_>>
  389. ) as well.
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397. =head2 C<bytes_sent>
  398.  
  399. The number of bytes sent to the client, handy for logging, etc.
  400.  
  401.   $bytes_sent = $r->bytes_sent();
  402.  
  403. =over 4
  404.  
  405. =item obj: C<$r>
  406. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  407.  
  408. =item ret: C<$bytes_sent> (integer)
  409.  
  410. =item since: 1.99_12
  411.  
  412. =back
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429. =head2 C<connection>
  430.  
  431. Get the client connection record
  432.  
  433.   $c = $r->connection();
  434.  
  435. =over 4
  436.  
  437. =item obj: C<$r>
  438. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  439.  
  440. =item ret: C<$c>
  441. ( C<L<Apache::Connection object|docs::2.0::api::Apache::Connection>> )
  442.  
  443. =item since: 1.99_12
  444.  
  445. =back
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453. =head2 C<content_encoding>
  454.  
  455. Get/set content encoding (the "Content-Encoding" HTTP header).
  456. Content encodings are string like I<"gzip"> or I<"compress">.
  457.  
  458.   $ce      = $r->content_encoding();
  459.   $prev_ce = $r->content_encoding($new_ce);
  460.  
  461. =over 4
  462.  
  463. =item obj: C<$r>
  464. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  465.  
  466. =item opt arg1: C<$new_ce> ( string )
  467.  
  468. If passed, sets the content encoding to a new value. It must be a
  469. lowercased string.
  470.  
  471. =item ret: C<$ce> ( string )
  472.  
  473. The current content encoding.
  474.  
  475. If C<$new_ce> is passed, then the previous value is returned.
  476.  
  477. =item since: 1.99_12
  478.  
  479. =back
  480.  
  481. For example, here is how to send a gzip'ed response:
  482.  
  483.   require Compress::Zlib;
  484.   $r->content_type("text/plain");
  485.   $r->content_encoding("gzip");
  486.   $r->print(Compress::Zlib::memGzip("some text to be gzipped));
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495. =head2 C<content_languages>
  496.  
  497. Get/set content languages (the C<"Content-Language"> HTTP header).
  498. Content languages are string like I<"en"> or I<"fr">.
  499.  
  500.   $languages = $r->content_languages();
  501.   $prev_lang = $r->content_languages($nev_lang);
  502.  
  503. =over 4
  504.  
  505. =item obj: C<$r>
  506. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  507.  
  508. =item opt arg1: C<$new_lang> ( ARRAY ref )
  509.  
  510. If passed, sets the content languages to new values. It must be an
  511. ARRAY reference of language names, like I<"en"> or I<"fr">
  512.  
  513. =item ret: C<$languages> ( ARRAY ref )
  514.  
  515. The current list of content languages, as an ARRAY reference.
  516.  
  517. If C<$new_lang> is passed, then the previous value is returned.
  518.  
  519. =item since: 1.99_16
  520.  
  521. =back
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530. =head2 C<content_type>
  531.  
  532. Get/set the HTTP response I<Content-type> header value.
  533.  
  534.   my $content_type      = $r->content_type();
  535.   my $prev_content_type = $r->content_type($new_content_type);
  536.  
  537. =over 4
  538.  
  539. =item obj: C<$r>
  540. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  541.  
  542. =item opt arg1: C<$new_content_type> (MIME type string)
  543.  
  544. Assign a new HTTP response content-type. It will affect the response
  545. only if HTTP headers weren't sent yet.
  546.  
  547. =item ret: C<$content_type>
  548.  
  549. The current content-type value.
  550.  
  551. If C<$new_content_type> was passed, the previous value is returned
  552. instead.
  553.  
  554. =item since 1.99_10
  555.  
  556. =back
  557.  
  558. For example, set the C<Content-type> header to I<text/plain>.
  559.  
  560.   $r->content_type('text/plain');
  561.  
  562. If you set this header via the
  563. C<L<headers_out|docs::2.0::api::Apache::RequestRec/C_headers_out_>>
  564. table directly, it will be ignored by Apache. So do not do that.
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573. =head2 C<err_headers_out>
  574.  
  575. Get/set MIME response headers, printed even on errors and persist
  576. across internal redirects.
  577.  
  578.   $err_headers_out = $r->err_headers_out();
  579.  
  580. =over 4
  581.  
  582. =item obj: C<$r>
  583. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  584.  
  585. =item ret: C<$err_headers_out>
  586. ( C<L<APR::Table object|docs::2.0::api::APR::Table>> )
  587.  
  588. =item since: 1.99_12
  589.  
  590. =back
  591.  
  592. The difference between C<L<headers_out|/C_headers_out_>> and
  593. C<err_headers_out>, is that the latter are printed even on error, and
  594. persist across internal redirects (so the headers printed for
  595. C<ErrorDocument> handlers will have them).
  596.  
  597. For example, if a handler wants to return a 404 response, but
  598. nevertheless to set a cookie, it has to be:
  599.  
  600.   $r->err_headers_out->add('Set-Cookie' => $cookie);
  601.   return Apache::NOT_FOUND;
  602.  
  603. If the handler does:
  604.  
  605.   $r->headers_out->add('Set-Cookie' => $cookie);
  606.   return Apache::NOT_FOUND;
  607.  
  608. the C<Set-Cookie> header won't be sent.
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615. =head2 C<filename>
  616.  
  617. Get/set the filename on disk corresponding to this response (the
  618. result of the I<URI --E<gt> filename> translation).
  619.  
  620.   $filename      = $r->filename();
  621.   $prev_filename = $r->filename($new_filename);
  622.  
  623. =over 4
  624.  
  625. =item obj: C<$r>
  626. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  627.  
  628. =item opt arg1: C<$new_filename> ( string )
  629.  
  630. new value
  631.  
  632. =item ret: C<$filename> ( string )
  633.  
  634. the current filename, or the previous value if the optional
  635. C<$new_filename> argument was passed
  636.  
  637. =item since: 1.99_12
  638.  
  639. =back
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646. =head2 C<finfo>
  647.  
  648. Get and set the I<finfo> request record member:
  649.  
  650.   $finfo = $r->finfo();
  651.   $r->finfo($finfo);
  652.  
  653. =over 4
  654.  
  655. =item obj: C<$r>
  656. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  657.  
  658. =item opt arg1: C<$finfo>
  659. ( C<L<APR::Finfo object|docs::2.0::api::APR::Finfo>> )
  660.  
  661. =item ret: C<$finfo>
  662. ( C<L<APR::Finfo object|docs::2.0::api::APR::Finfo>> )
  663.  
  664. Always returns the current object.
  665.  
  666. Due to the internal Apache implementation it's not possible to have
  667. two different objects originating from C<$r-E<gt>finfo> at the same
  668. time. Whenever C<$r-E<gt>finfo> is updated all objects will be updated
  669. too to the latest value.
  670.  
  671. =item since: 1.99_15
  672.  
  673. =back
  674.  
  675. Most of the time, this method is used to get the C<finfo> member. The
  676. only reason you may want to set it is you need to use it before the
  677. Apache's default map_to_storage phase is called.
  678.  
  679. Examples:
  680.  
  681. =over
  682.  
  683. =item *
  684.  
  685. What Apache thinks is the current request filename (post the
  686. C<L<PerlMapToStorageHandler|docs::2.0::user::handlers::http/PerlMapToStorageHandler>>
  687. phase):
  688.  
  689.   use Apache::RequestRec ();
  690.   use APR::Finfo ();
  691.   print $r->finfo->fname;
  692.  
  693. =item *
  694.  
  695. Populate the C<finfo> member (normally, before the
  696. C<L<PerlMapToStorageHandler|docs::2.0::user::handlers::http/PerlMapToStorageHandler>>
  697. phase):
  698.  
  699.   use APR::Finfo ();
  700.   use APR::Const -compile => qw(FINFO_NORM);
  701.  
  702.   my $finfo = APR::Finfo::stat(__FILE__, APR::FINFO_NORM, $r->pool);
  703.   $r->finfo($finfo);
  704.  
  705. =back
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712. =head2 C<handler>
  713.  
  714. Get/set the equivalent of the C<SetHandler> directive.
  715.  
  716.   $handler      = $r->handler();
  717.   $prev_handler = $r->handler($new_handler);
  718.  
  719. =over 4
  720.  
  721. =item obj: C<$r>
  722. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  723.  
  724. =item opt arg1: C<$new_handler> ( string )
  725.  
  726. the new handler.
  727.  
  728. =item ret: C<$handler> ( string )
  729.  
  730. the current handler.
  731.  
  732. If C<$new_handler> is passed, the previous value is returned.
  733.  
  734. =item since: 1.99_12
  735.  
  736. =back
  737.  
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744. =head2 C<header_only>
  745.  
  746. Did the client has asked for headers only? e.g. if the request method
  747. was B<HEAD>.
  748.  
  749.   $status = $r->header_only();
  750.  
  751. =over 4
  752.  
  753. =item obj: C<$r>
  754. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  755.  
  756. =item ret: C<$status> ( boolean )
  757.  
  758. Returns true if the client is asking for headers only, false otherwise
  759.  
  760. =item since: 1.99_12
  761.  
  762. =back
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769. =head2 C<headers_in>
  770.  
  771. Get/set the request MIME headers:
  772.  
  773.   $headers_in = $r->headers_in();
  774.  
  775. =over 4
  776.  
  777. =item obj: C<$r>
  778. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  779.  
  780. =item ret: C<$headers_in>
  781. ( C<L<APR::Table object|docs::2.0::api::APR::Table>> )
  782.  
  783. =item since: 1.99_12
  784.  
  785. =back
  786.  
  787. This table is available starting from the
  788. C<L<PerlHeaderParserHandler|docs::2.0::user::handlers::http/PerlHeaderParserHandler>>
  789. phase.
  790.  
  791. For example you can use it to retrieve the cookie value sent by the
  792. client, in the C<Cookie:> header:
  793.  
  794.     my $cookie = $r->headers_in->{Cookie} || '';
  795.  
  796.  
  797.  
  798.  
  799.  
  800.  
  801.  
  802. =head2 C<headers_out>
  803.  
  804. Get/set MIME response headers, printed only on 2xx responses.
  805.  
  806.   $headers_out = $r->headers_out();
  807.  
  808. =over 4
  809.  
  810. =item obj: C<$r>
  811. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  812.  
  813. =item ret: C<$headers_out>
  814. ( C<L<APR::Table object|docs::2.0::api::APR::Table>> )
  815.  
  816. =item since: 1.99_12
  817.  
  818. =back
  819.  
  820. See also C<L<err_headers_out|/C_err_headers_out_>>, which allows to
  821. set headers for non-2xx responses and persist across internal
  822. redirects.
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831. =head2 C<hostname>
  832.  
  833. Host, as set by full URI or Host:
  834.  
  835.   $hostname = $r->hostname();
  836.  
  837. =over 4
  838.  
  839. =item obj: C<$r>
  840. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  841.  
  842. =item ret: C<$hostname> ( string )
  843.  
  844. =item since: 1.99_12
  845.  
  846. =back
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856. =head2 C<input_filters>
  857.  
  858. Get/set the first filter in a linked list of request level input
  859. filters:
  860.  
  861.   $input_filters      = $r->input_filters();
  862.   $prev_input_filters = $r->input_filters($new_input_filters);
  863.  
  864. =over 4
  865.  
  866. =item obj: C<$r>
  867. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  868.  
  869. =item opt arg1: C<$new_input_filters>
  870.  
  871. Set a new value
  872.  
  873. =item ret: C<$input_filters>
  874. ( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
  875.  
  876. The first filter in the request level input filters chain.
  877.  
  878. If C<$new_input_filters> was passed, returns the previous value.
  879.  
  880. =item since: 1.99_12
  881.  
  882. =back
  883.  
  884. For example instead of using
  885. C<L<$r-E<gt>read()|docs::2.0::api::Apache::RequestIO/C_read_>> to read
  886. the POST data, one could use an explicit walk through incoming bucket
  887. brigades to get that data. The following function C<read_post()> does
  888. just that (in fact that's what
  889. C<L<$r-E<gt>read()|docs::2.0::api::Apache::RequestIO/C_read_>> does
  890. behind the scenes):
  891.  
  892.   use APR::Brigade ();
  893.   use APR::Bucket ();
  894.   use Apache::Filter ();
  895.   
  896.   use Apache::Const -compile => qw(MODE_READBYTES);
  897.   use APR::Const    -compile => qw(SUCCESS BLOCK_READ);
  898.   
  899.   use constant IOBUFSIZE => 8192;
  900.   
  901.   sub read_post {
  902.       my $r = shift;
  903.   
  904.       my $bb = APR::Brigade->new($r->pool,
  905.                                  $r->connection->bucket_alloc);
  906.   
  907.       my $data = '';
  908.       my $seen_eos = 0;
  909.       do {
  910.           $r->input_filters->get_brigade($bb, Apache::MODE_READBYTES,
  911.                                          APR::BLOCK_READ, IOBUFSIZE);
  912.   
  913.           for (my $b = $bb->first; $b; $b = $bb->next($b)) {
  914.               if ($b->is_eos) {
  915.                   $seen_eos++;
  916.                   last;
  917.               }
  918.   
  919.               if ($b->read(my $buf)) {
  920.                   $data .= $buf;
  921.               }
  922.   
  923.               $b->remove; # optimization to reuse memory
  924.           }
  925.   
  926.       } while (!$seen_eos);
  927.   
  928.       $bb->destroy;
  929.   
  930.       return $data;
  931.   }
  932.  
  933. As you can see C<$r-E<gt>input_filters> gives us a pointer to the last
  934. of the top of the incoming filters stack.
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942. =head2 C<main>
  943.  
  944. Get the main request record
  945.  
  946.   $main_r = $r->main();
  947.  
  948. =over 4
  949.  
  950. =item obj: C<$r>
  951. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  952.  
  953. =item ret: C<$main_r>
  954. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  955.  
  956. If the current request is a sub-request, this method returns a blessed
  957. reference to the main request structure. If the current request is the
  958. main request, then this method returns C<undef>.
  959.  
  960. To figure out whether you are inside a main request or a
  961. sub-request/internal redirect, use
  962. C<L<$r-E<gt>is_initial_req|docs::2.0::api::Apache::RequestUtil/C_is_initial_req_>>.
  963.  
  964. =item since: 1.99_12
  965.  
  966. =back
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973. =head2 C<method>
  974.  
  975. Get/set the current request method (e.g. C<GET>, C<HEAD>, C<POST>, etc.):
  976.  
  977.   $method     = $r->method();
  978.   $pre_method = $r->method($new_method);
  979.  
  980. =over 4
  981.  
  982. =item obj: C<$r>
  983. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  984.  
  985. =item opt arg1: C<$new_method> ( string )
  986.  
  987. a new value
  988.  
  989. =item ret: C<$method> ( string )
  990.  
  991. The current method as a string
  992.  
  993. if C<$new_method> was passed the previous value is returned.
  994.  
  995. =item since: 1.99_15
  996.  
  997. =back
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004. =head2 C<method_number>
  1005.  
  1006. Get/set the HTTP method, issued by the client (C<Apache::M_GET>,
  1007. C<Apache::M_POST>, etc.)
  1008.  
  1009.   $methnum      = $r->method_number();
  1010.   $prev_methnum = $r->method_number($new_methnum);
  1011.  
  1012. =over 4
  1013.  
  1014. =item obj: C<$r>
  1015. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1016.  
  1017. =item opt arg1: C<$new_methnum> ( C<L<Apache::Const :methods
  1018. constant|docs::2.0::api::Apache::Const/C__methods_>> )
  1019.  
  1020. a new value
  1021.  
  1022. =item ret: C<$methnum> ( C<L<Apache::Const :methods
  1023. constant|docs::2.0::api::Apache::Const/C__methods_>> )
  1024.  
  1025. The current method as a number
  1026.  
  1027. if C<$new_methnum> was passed the previous value is returned.
  1028.  
  1029. =item since: 1.99_15
  1030.  
  1031. =back
  1032.  
  1033. See the C<L<$r-E<gt>allowed|/C_allowed_>> entry for examples.
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043. =head2 C<mtime>
  1044.  
  1045. Last modified time of the requested resource
  1046.  
  1047.   $mtime      = $r->mtime();
  1048.   $prev_mtime = $r->mtime($new_mtime);
  1049.  
  1050. =over 4
  1051.  
  1052. =item obj: C<$r>
  1053. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1054.  
  1055. =item opt arg1: C<$new_mtime> ( number )
  1056.  
  1057. a new value (in microseconds).
  1058.  
  1059. =item ret: C<$mtime> ( number )
  1060.  
  1061. the current value (in microseconds).
  1062.  
  1063. if C<$new_mtime> was passed the previous value is returned.
  1064.  
  1065. =item since: 1.99_12
  1066.  
  1067. =back
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076. =head2 C<next>
  1077.  
  1078. Pointer to the redirected request if this is an external redirect
  1079.  
  1080.   $next_r = $r->next();
  1081.  
  1082. =over 4
  1083.  
  1084. =item obj: C<$r>
  1085. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1086.  
  1087. =item ret: C<$next_r>
  1088. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1089.  
  1090. returns a blessed reference to the next (internal) request structure
  1091. or C<undef> if there is no next request.
  1092.  
  1093. =item since: 1.99_12
  1094.  
  1095. =back
  1096.  
  1097.  
  1098.  
  1099.  
  1100. =head2 C<no_local_copy>
  1101.  
  1102. There is no local copy of this response
  1103.  
  1104.   $status = $r->no_local_copy();
  1105.  
  1106. =over 4
  1107.  
  1108. =item obj: C<$r>
  1109. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1110.  
  1111. =item ret: C<$status> (integer)
  1112.  
  1113. =item since: 1.99_12
  1114.  
  1115. =back
  1116.  
  1117. Used internally in certain sub-requests to prevent sending
  1118. C<Apache::HTTP_NOT_MODIFIED> for a fragment or error documents. For
  1119. example see the implementation in F<modules/filters/mod_include.c>.
  1120.  
  1121. Also used internally in
  1122. C<L<$r-E<gt>meets_conditions|docs::2.0::api::Apache::Response/C_meets_conditions_>>
  1123. -- if set to a true value, the conditions are always met.
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133. =head2 C<notes>
  1134.  
  1135. Get/set text notes for the duration of this request. These notes can
  1136. be passed from one module to another (not only mod_perl, but modules
  1137. in any other language):
  1138.  
  1139.   $notes      = $r->notes();
  1140.   $prev_notes = $r->notes($new_notes);
  1141.  
  1142. =over 4
  1143.  
  1144. =item obj: C<$r>
  1145. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1146.  
  1147. =item opt arg1: C<$new_notes>
  1148. ( C<L<APR::Table object|docs::2.0::api::APR::Table>> )
  1149.  
  1150. =item ret: C<$notes>
  1151. ( C<L<APR::Table object|docs::2.0::api::APR::Table>> )
  1152.  
  1153. the current notes table.
  1154.  
  1155. if the C<$new_notes> argument was passed, returns the previous value.
  1156.  
  1157. =item since: 1.99_12
  1158.  
  1159. =back
  1160.  
  1161. If you want to pass Perl structures, you can use
  1162. C<L<$r-E<gt>pnotes|docs::2.0::api::Apache::RequestUtil/C_pnotes_>>.
  1163.  
  1164. Also see
  1165. C<L<$c-E<gt>notes|docs::2.0::api::Apache::Connection/C_notes_>>
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173. =head2 C<output_filters>
  1174.  
  1175. Get the first filter in a linked list of request level output filters:
  1176.  
  1177.   $output_filters      = $r->output_filters();
  1178.   $prev_output_filters = $r->output_filters($new_output_filters);
  1179.  
  1180. =over 4
  1181.  
  1182. =item obj: C<$r>
  1183. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1184.  
  1185. =item opt arg1: C<$new_output_filters>
  1186.  
  1187. Set a new value
  1188.  
  1189. =item ret: C<$output_filters>
  1190. ( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
  1191.  
  1192. The first filter in the request level output filters chain.
  1193.  
  1194. If C<$new_output_filters> was passed, returns the previous value.
  1195.  
  1196. =item since: 1.99_12
  1197.  
  1198. =back
  1199.  
  1200. For example instead of using
  1201. C<L<$r-E<gt>print()|docs::2.0::api::Apache::RequestIO/C_print_>> to
  1202. send the response body, one could send the data directly to the first
  1203. output filter. The following function C<send_response_body()> does
  1204. just that:
  1205.  
  1206.   use APR::Brigade ();
  1207.   use APR::Bucket ();
  1208.   use Apache::Filter ();
  1209.   
  1210.   sub send_response_body {
  1211.       my($r, $data) = @_;
  1212.   
  1213.       my $bb = APR::Brigade->new($r->pool,
  1214.                                  $r->connection->bucket_alloc);
  1215.   
  1216.       my $b = APR::Bucket->new($data);
  1217.       $bb->insert_tail($b);
  1218.       $r->output_filters->fflush($bb);
  1219.       $bb->destroy;
  1220.   }
  1221.  
  1222. In fact that's what
  1223. C<L<$r-E<gt>read()|docs::2.0::api::Apache::RequestIO/C_read_>> does
  1224. behind the scenes. But it also knows to parse HTTP headers passed
  1225. together with the data and it also implements buffering, which the
  1226. above function does not.
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236. =head2 C<path_info>
  1237.  
  1238. Get/set the C<PATH_INFO>, what is left in the path after the I<URI
  1239. --E<gt> filename> translation:
  1240.  
  1241.   $path_info      = $r->path_info();
  1242.   $prev_path_info = $r->path_info($path_info);
  1243.  
  1244. =over 4
  1245.  
  1246. =item obj: C<$r>
  1247. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1248.  
  1249. =item opt arg1: C<$path_info> ( string )
  1250.  
  1251. Set a new value
  1252.  
  1253. =item ret: C<$path_info> ( string )
  1254.  
  1255. Return the current value.
  1256.  
  1257. If the optional argument C<$path_info> is passed, the previous value
  1258. is returned.
  1259.  
  1260. =item since: 1.99_12
  1261.  
  1262. =back
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269. =head2 C<per_dir_config>
  1270.  
  1271. Get the dir config vector:
  1272.  
  1273.   $per_dir_config = $r->per_dir_config();
  1274.  
  1275. =over 4
  1276.  
  1277. =item obj: C<$r>
  1278. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1279.  
  1280. =item ret: C<$per_dir_config>
  1281. ( C<L<Apache::ConfVector object|docs::2.0::api::Apache::ConfVector>> )
  1282.  
  1283. =item since: 1.99_12
  1284.  
  1285. =back
  1286.  
  1287. For an indepth discussion, refer to the L<Apache Server Configuration
  1288. Customization in Perl chapter|docs::2.0::user::config::custom>.
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297. =head2 C<pool>
  1298.  
  1299. The pool associated with the request
  1300.  
  1301.   $p = $r->pool();
  1302.  
  1303. =over 4
  1304.  
  1305. =item obj: C<$r>
  1306. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1307.  
  1308. =item ret: C<$p> ( C<L<APR::Pool object|docs::2.0::api::APR::Pool>> )
  1309.  
  1310. =item since: 1.99_12
  1311.  
  1312. =back
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321. =head2 C<prev>
  1322.  
  1323. Pointer to the previous request if this is an internal redirect
  1324.  
  1325.   $prev_r = $r->prev();
  1326.  
  1327. =over 4
  1328.  
  1329. =item obj: C<$r>
  1330. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1331.  
  1332. =item ret: C<$prev_r> ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1333.  
  1334. a blessed reference to the previous (internal) request structure or
  1335. C<undef> if there is no previous request.
  1336.  
  1337. =item since: 1.99_12
  1338.  
  1339. =back
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.  
  1346.  
  1347. =head2 C<proto_input_filters>
  1348.  
  1349. Get the first filter in a linked list of protocol level input filters:
  1350.  
  1351.   $proto_input_filters      = $r->proto_input_filters();
  1352.   $prev_proto_input_filters = $r->proto_input_filters($new_proto_input_filters);
  1353.  
  1354. =over 4
  1355.  
  1356. =item obj: C<$r>
  1357. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1358.  
  1359. =item opt arg1: C<$new_proto_input_filters>
  1360.  
  1361. Set a new value
  1362.  
  1363. =item ret: C<$proto_input_filters>
  1364. ( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
  1365.  
  1366. The first filter in the protocol level input filters chain.
  1367.  
  1368. If C<$new_proto_input_filters> was passed, returns the previous value.
  1369.  
  1370. =item since: 1.99_12
  1371.  
  1372. =back
  1373.  
  1374. C<$r-E<gt>proto_input_filters> points to the same filter as
  1375. C<L<$r-E<gt>connection-E<gt>input_filters|docs::2.0::api::Apache::Connection/C_input_filters_>>.
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383. =head2 C<proto_num>
  1384.  
  1385. Get current request's HTTP protocol version number
  1386.  
  1387.   $proto_num = $r->proto_num();
  1388.  
  1389. =over 4
  1390.  
  1391. =item obj: C<$r>
  1392. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1393.  
  1394. =item ret: C<$proto_num> (integer)
  1395.  
  1396. current request's HTTP protocol version number, e.g.: HTTP/1.0 ==
  1397. 1000, HTTP/1.1 = 1001
  1398.  
  1399. =item since: 1.99_12
  1400.  
  1401. =back
  1402.  
  1403.  
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409. =head2 C<proto_output_filters>
  1410.  
  1411. Get the first filter in a linked list of protocol level output
  1412. filters:
  1413.  
  1414.   $proto_output_filters      = $r->proto_output_filters();
  1415.   $prev_proto_output_filters = $r->proto_output_filters($new_proto_output_filters);
  1416.  
  1417. =over 4
  1418.  
  1419. =item obj: C<$r>
  1420. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1421.  
  1422. =item opt arg1: C<$new_proto_output_filters>
  1423.  
  1424. Set a new value
  1425.  
  1426. =item ret: C<$proto_output_filters>
  1427. ( C<L<Apache::Filter object|docs::2.0::api::Apache::Filter>> )
  1428.  
  1429. The first filter in the protocol level output filters chain.
  1430.  
  1431. If C<$new_proto_output_filters> was passed, returns the previous value.
  1432.  
  1433. =item since: 1.99_12
  1434.  
  1435. =back
  1436.  
  1437. C<$r-E<gt>proto_output_filters> points to the same filter as
  1438. C<L<$r-E<gt>connection-E<gt>output_filters|docs::2.0::api::Apache::Connection/C_output_filters_>>.
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446. =head2 C<protocol>
  1447.  
  1448. Get a string identifying the protocol that the client speaks.
  1449.  
  1450.   $protocol = $r->protocol();
  1451.  
  1452. =over 4
  1453.  
  1454. =item obj: C<$r>
  1455. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1456.  
  1457. =item ret: C<$protocl> ( string )
  1458.  
  1459. Typical values are C<"HTTP/1.0"> or C<"HTTP/1.1">.
  1460.  
  1461. If the client didn't specify the protocol version, the default is
  1462. C<"HTTP/0.9">
  1463.  
  1464. =item since: 1.99_12
  1465.  
  1466. =back
  1467.  
  1468.  
  1469.  
  1470.  
  1471.  
  1472.  
  1473. =head2 C<proxyreq>
  1474.  
  1475. Get/set the I<proxyrec> request record member and optionally adjust
  1476. other related fields.
  1477.  
  1478.   $status = $r->proxyreq($val);
  1479.  
  1480. =over 4
  1481.  
  1482. =item obj: C<$r>
  1483. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1484.  
  1485. =item opt arg1: C<$val> ( integer )
  1486.  
  1487. 0, 1 or none.
  1488.  
  1489. =item ret: C<$status> ( integer )
  1490.  
  1491. If C<$val> is 0 or 1, the I<proxyrec> member will be set to that value
  1492. and previous value will be returned.
  1493.  
  1494. If C<$val> is not passed, and C<$r-E<gt>proxyreq> is not true, and the
  1495. proxy request is matching the current vhost (scheme, hostname and
  1496. port), the I<proxyrec> member will be set to 1 and that value will be
  1497. returned. In addition C<$r-E<gt>uri> is set to C<$r-E<gt>unparsed_uri>
  1498. and C<$r-E<gt>filename> is set to C<"modperl-proxy:".$r-E<gt>uri>. If
  1499. those conditions aren't true 0 is returned.
  1500.  
  1501. =item since: 1.99_12
  1502.  
  1503. =back
  1504.  
  1505. For example to turn a normal request into a proxy request to be
  1506. handled on the same server in the C<PerlTransHandler> phase run:
  1507.  
  1508.   my $real_url = $r->unparsed_uri;
  1509.   $r->proxyreq(1);
  1510.   $r->uri($real_url);
  1511.   $r->filename("proxy:$real_url");
  1512.   $r->handler('proxy-server');
  1513.  
  1514. Also remember that if you want to turn a proxy request into a
  1515. non-proxy request, it's not enough to call:
  1516.  
  1517.   $r->proxyreq(0);
  1518.  
  1519. You need to adjust C<$r-E<gt>uri> and C<$r-E<gt>filename> as well if
  1520. you run that code in C<PerlPostReadRequestHandler> phase, since if you
  1521. don't -- C<mod_proxy>'s own post_read_request handler will override
  1522. your settings (as it will run after the mod_perl handler).
  1523.  
  1524.  
  1525.  
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532. =head2 C<request_time>
  1533.  
  1534. Time when the request started
  1535.  
  1536.   $request_time = $r->request_time();
  1537.  
  1538. =over 4
  1539.  
  1540. =item obj: C<$r>
  1541. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1542.  
  1543. =item ret: C<$request_time> ( number )
  1544.  
  1545. (in microseconds).
  1546.  
  1547. =item since: 1.99_12
  1548.  
  1549. =back
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557. =head2 C<server>
  1558.  
  1559. Get the C<L<Apache::Server|docs::2.0::api::Apache::ServerRec>> object for
  1560. the server the request C<$r> is running under.
  1561.  
  1562.   $s = $r->server();
  1563.  
  1564. =over 4
  1565.  
  1566. =item obj: C<$r>
  1567. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1568.  
  1569. =item ret: C<$s>
  1570. ( C<L<Apache::ServerRec object|docs::2.0::api::Apache::ServerRec>> )
  1571.  
  1572. =item since: 1.99_12
  1573.  
  1574. =back
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582. =head2 C<status>
  1583.  
  1584. Get/set the reply status for the client request.
  1585.  
  1586.   $status      = $r->status();
  1587.   $prev_status = $r->status($new_status);
  1588.  
  1589. =over 4
  1590.  
  1591. =item obj: C<$r>
  1592. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1593.  
  1594. =item opt arg1: C<$new_status> ( integer )
  1595.  
  1596. If C<$new_status> is passed the new status is assigned.
  1597.  
  1598. Normally you would use some C<L<Apache::Const
  1599. constant|docs::2.0::api::Apache::Const>>, e.g. C<Apache::REDIRECT>.
  1600.  
  1601. =item ret: C<$newval> ( integer )
  1602.  
  1603. The current value.
  1604.  
  1605. If C<$new_status> is passed the old value is returned.
  1606.  
  1607. =item since: 1.99_12
  1608.  
  1609. =back
  1610.  
  1611. Usually you will set this value indirectly by returning the status
  1612. code as the handler's function result.  However, there are rare
  1613. instances when you want to trick Apache into thinking that the module
  1614. returned an C<Apache::OK> status code, but actually send the browser a
  1615. non-OK status. This may come handy when implementing an HTTP proxy
  1616. handler.  The proxy handler needs to send to the client, whatever
  1617. status code the proxied server has returned, while returning
  1618. C<Apache::OK> to Apache. e.g.:
  1619.  
  1620.   $r->status($some_code);
  1621.   return Apache::OK
  1622.  
  1623. See also C<L<$r-E<gt>status_line|/C_status_line_>>, which. if set,
  1624. overrides C<$r-E<gt>status>.
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632. =head2 C<status_line>
  1633.  
  1634. Get/set the response status line.  The status line is a string like
  1635. "200 Document follows" and it will take precedence over the value
  1636. specified using the C<$r-E<gt>status()> described above.
  1637.  
  1638.   $status_line      = $r->status_line();
  1639.   $prev_status_line = $r->status_line($new_status_line);
  1640.  
  1641. =over 4
  1642.  
  1643. =item obj: C<$r>
  1644. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1645.  
  1646. =item opt arg1: C<$new_status_line> ( string )
  1647.  
  1648. =item ret: C<$status_line> ( string )
  1649.  
  1650. =item since: 1.99_12
  1651.  
  1652. =back
  1653.  
  1654. When discussing C<L<$r-E<gt>status|/C_status_>> we have mentioned that
  1655. sometimes a handler runs to a successful completion, but may need to
  1656. return a different code, which is the case with the proxy
  1657. server. Assuming that the proxy handler forwards to the client
  1658. whatever response the proxied server has sent, it'll usually use
  1659. C<status_line()>, like so:
  1660.  
  1661.   $r->status_line($response->code() . ' ' . $response->message());
  1662.   return Apache::OK;
  1663.  
  1664. In this example C<$response> could be for example an C<HTTP::Response>
  1665. object, if C<LWP::UserAgent> was used to implement the proxy.
  1666.  
  1667. This method is also handy when you extend the HTTP protocol and add
  1668. new response codes. For example you could invent a new error code and
  1669. tell Apache to use that in the response like so:
  1670.  
  1671.   $r->status_line("499 We have been FooBared");
  1672.   return Apache::OK;
  1673.  
  1674. Here C<499> is the new response code, and I<We have been FooBared> is
  1675. the custom response message.
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.  
  1684. =head2 C<subprocess_env>
  1685.  
  1686. Get/set the Apache C<subprocess_env> table, or optionally set the
  1687. value of a named entry.
  1688.  
  1689.                $r->subprocess_env;
  1690.   $env_table = $r->subprocess_env;
  1691.   
  1692.          $r->subprocess_env($key => $val);
  1693.   $val = $r->subprocess_env($key);
  1694.  
  1695. =over 4
  1696.  
  1697. =item obj: C<$r>
  1698. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1699.  
  1700. =item opt arg1: C<$key> ( string )
  1701.  
  1702. =item opt arg2: C<$val> ( string )
  1703.  
  1704. =item ret: C<...>
  1705.  
  1706. =item since: 1.99_12
  1707.  
  1708. =back
  1709.  
  1710. When called in VOID context with no arguments, it populate C<%ENV>
  1711. with special variables (e.g. C<$ENV{QUERY_STRING}>) like mod_cgi
  1712. does.
  1713.  
  1714. When called in a non-VOID context with no arguments, it returns an
  1715. C<L<APR::Table object|docs::2.0::api::APR::Table>>.
  1716.  
  1717. When the C<$key> argument (string) is passed, it returns the
  1718. corresponding value (if such exists, or C<undef>. The following two
  1719. lines are equivalent:
  1720.  
  1721.   $val = $r->subprocess_env($key);
  1722.   $val = $r->subprocess_env->get($key);
  1723.  
  1724. When the C<$key> and the C<$val> arguments (strings) are passed, the
  1725. value is set. The following two lines are equivalent:
  1726.  
  1727.   $r->subprocess_env($key => $val);
  1728.   $r->subprocess_env->set($key => $val);
  1729.  
  1730. The C<subprocess_env> C<L<table|docs::2.0::api::APR::Table>> is used
  1731. by C<L<Apache::SubProcess|docs::2.0::api::Apache::SubProcess>>, to
  1732. pass environment variables to externally spawned processes. It's also
  1733. used by various Apache modules, and you should use this table to pass
  1734. the environment variables. For example if in
  1735. C<PerlHeaderParserHandler> you do:
  1736.  
  1737.    $r->subprocess_env(MyLanguage => "de");
  1738.  
  1739. you can then deploy C<mod_include> and write in I<.shtml> document:
  1740.  
  1741.    <!--#if expr="$MyLanguage = en" -->
  1742.    English
  1743.    <!--#elif expr="$MyLanguage = de" -->
  1744.    Deutsch
  1745.    <!--#else -->
  1746.    Sorry
  1747.    <!--#endif -->
  1748.  
  1749.  
  1750.  
  1751.  
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758. =head2 C<the_request>
  1759.  
  1760. First HTTP request header
  1761.  
  1762.   $request = $r->the_request();
  1763.  
  1764. =over 4
  1765.  
  1766. =item obj: C<$r>
  1767. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1768.  
  1769. =item ret: C<$request> ( string )
  1770.  
  1771. For example:
  1772.  
  1773.   GET /foo/bar/my_path_info?args=3 HTTP/1.0
  1774.  
  1775. =item since: 1.99_12
  1776.  
  1777. =back
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787. =head2 C<unparsed_uri>
  1788.  
  1789. The URI without any parsing performed
  1790.  
  1791.   $unparsed_uri = $r->unparsed_uri();
  1792.  
  1793. =over 4
  1794.  
  1795. =item obj: C<$r>
  1796. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1797.  
  1798. =item ret: C<$unparsed_uri> ( string )
  1799.  
  1800. =item since: 1.99_12
  1801.  
  1802. =back
  1803.  
  1804. If for example the request was:
  1805.  
  1806.   GET /foo/bar/my_path_info?args=3 HTTP/1.0
  1807.  
  1808. C<L<$r-E<gt>uri|/C_uri_>> returns:
  1809.  
  1810.   /foo/bar/my_path_info
  1811.  
  1812. whereas C<$r-E<gt>unparsed_uri> returns:
  1813.  
  1814.   /foo/bar/my_path_info?args=3
  1815.  
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821.  
  1822. =head2 C<uri>
  1823.  
  1824. The path portion of the URI
  1825.  
  1826.   $uri         = $r->uri();
  1827.   my $prec_uri = $r->uri($new_uri);
  1828.  
  1829. =over 4
  1830.  
  1831. =item obj: C<$r>
  1832. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1833.  
  1834. =item opt arg1: C<$new_uri> ( string )
  1835.  
  1836. =item ret: C<$uri> ( string )
  1837.  
  1838. =item since: 1.99_12
  1839.  
  1840. =back
  1841.  
  1842. See the example in the C<L<$r-E<gt>unparsed_uri|/C_unparsed_uri_>>
  1843. section.
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852. =head2 C<user>
  1853.  
  1854. Get the user name, if an L<authentication> process was successful. Or
  1855. set it.
  1856.  
  1857.   $user      = $r->user();
  1858.   $prev_user = $r->user($new_user);
  1859.  
  1860. =over 4
  1861.  
  1862. =item obj: C<$r>
  1863. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1864.  
  1865. =item opt arg1: C<$new_user> ( string )
  1866.  
  1867. Pass C<$new_user> to set a new value
  1868.  
  1869. =item ret: C<$user> ( string )
  1870.  
  1871. The current username if an authentication process was successful.
  1872.  
  1873. If C<$new_user> was passed, the previous value is returned.
  1874.  
  1875. =item since: 1.99_12
  1876.  
  1877. =back
  1878.  
  1879. For example, let's print the username passed by the client:
  1880.  
  1881.   my($res, $sent_pw) = $r->get_basic_auth_pw;
  1882.   return $res if $res != Apache::OK;
  1883.   print "User: ", $r->user;
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892. =head1 Unsupported API
  1893.  
  1894. C<Apache::RequestRec> also provides auto-generated Perl interface for
  1895. a few other methods which aren't tested at the moment and therefore
  1896. their API is a subject to change. These methods will be finalized
  1897. later as a need arises. If you want to rely on any of the following
  1898. methods please contact the L<the mod_perl development mailing
  1899. list|maillist::dev> so we can help each other take the steps necessary
  1900. to shift the method to an officially supported API.
  1901.  
  1902.  
  1903.  
  1904. =head2 C<allowed_methods>
  1905.  
  1906. META: Autogenerated - needs to be reviewed/completed
  1907.  
  1908. List of allowed methods
  1909.  
  1910.   $list = $r->allowed_methods();
  1911.  
  1912. =over 4
  1913.  
  1914. =item obj: C<$r>
  1915. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1916.  
  1917. =item ret: C<$list>
  1918. ( C<L<Apache::MethodList object|docs::2.0::api::Apache::MethodList>> )
  1919.  
  1920. =item since: 1.99_12
  1921.  
  1922. =back
  1923.  
  1924. META: Apache::MethodList is not available at the moment
  1925.  
  1926.  
  1927.  
  1928.  
  1929.  
  1930.  
  1931.  
  1932. =head2 C<allowed_xmethods>
  1933.  
  1934. META: Autogenerated - needs to be reviewed/completed
  1935.  
  1936. Array of extension methods
  1937.  
  1938.   $array = $r->allowed_xmethods();
  1939.  
  1940. =over 4
  1941.  
  1942. =item obj: C<$r>
  1943. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1944.  
  1945. =item ret: C<$array>
  1946. ( C<L<APR::ArrayHeader object|docs::2.0::api::APR::ArrayHeader>> )
  1947.  
  1948. =item since: 1.99_12
  1949.  
  1950. =back
  1951.  
  1952. META: APR::ArrayHeader is not available at the moment
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960. =head2 C<request_config>
  1961.  
  1962. Config vector containing pointers to request's per-server config
  1963. structures
  1964.  
  1965.   $ret = $r->request_config($newval);
  1966.  
  1967. =over 4
  1968.  
  1969. =item obj: C<$r>
  1970. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  1971.  
  1972. =item opt arg1: C<$newval>
  1973. ( C<L<Apache::ConfVector object|docs::2.0::api::Apache::ConfVector>> )
  1974.  
  1975. =item since: 1.99_12
  1976.  
  1977. =back
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983. =head2 C<used_path_info>
  1984.  
  1985. META: Autogenerated - needs to be reviewed/completed
  1986.  
  1987. Flag for the handler to accept or reject path_info on
  1988. the current request.  All modules should respect the
  1989. AP_REQ_ACCEPT_PATH_INFO and AP_REQ_REJECT_PATH_INFO
  1990. values, while AP_REQ_DEFAULT_PATH_INFO indicates they
  1991. may follow existing conventions.  This is set to the
  1992. user's preference upon HOOK_VERY_FIRST of the fixups.
  1993.  
  1994.   $ret = $r->used_path_info($newval);
  1995.  
  1996. =over 4
  1997.  
  1998. =item obj: C<$r>
  1999. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  2000.  
  2001. =item arg1: C<$newval> (integer)
  2002.  
  2003. =item since: 1.99_12
  2004.  
  2005. =back
  2006.  
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013. =head1 See Also
  2014.  
  2015. L<mod_perl 2.0 documentation|docs::2.0::index>.
  2016.  
  2017.  
  2018.  
  2019.  
  2020. =head1 Copyright
  2021.  
  2022. mod_perl 2.0 and its core modules are copyrighted under
  2023. The Apache Software License, Version 2.0.
  2024.  
  2025.  
  2026.  
  2027.  
  2028. =head1 Authors
  2029.  
  2030. L<The mod_perl development team and numerous
  2031. contributors|about::contributors::people>.
  2032.  
  2033. =cut
  2034.  
  2035.