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 / RequestIO.pm < prev    next >
Encoding:
Perl POD Document  |  2004-09-23  |  10.6 KB  |  639 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::RequestIO;
  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::RequestIO - Perl API for Apache request record IO
  34.  
  35.  
  36.  
  37.  
  38. =head1 Synopsis
  39.  
  40.   use Apache::RequestIO ();
  41.   
  42.   $rc = $r->discard_request_body();
  43.   
  44.   $r->print("foo", "bar");
  45.   $r->puts("foo", "bar"); # same as print, but no flushing
  46.   $r->printf("%s $d", "foo", 5);
  47.   
  48.   $r->read($buffer, $len);
  49.   
  50.   $r->rflush();
  51.   
  52.   $r->sendfile($filename);
  53.   
  54.   $r->write("foobartarcar", 3, 5);
  55.  
  56.  
  57.  
  58.  
  59. =head1 Description
  60.  
  61. C<Apache::RequestIO> provides the API to perform IO on the L<Apache
  62. request object|docs::2.0::api::Apache::RequestRec>.
  63.  
  64.  
  65.  
  66.  
  67. =head1 API
  68.  
  69. C<Apache::RequestIO> provides the following functions and/or methods:
  70.  
  71.  
  72.  
  73.  
  74. =head2 C<discard_request_body>
  75.  
  76. In HTTP/1.1, any method can have a body.  However, most GET handlers
  77. wouldn't know what to do with a request body if they received one.
  78. This helper routine tests for and reads any message body in the
  79. request, simply discarding whatever it receives.  We need to do this
  80. because failing to read the request body would cause it to be
  81. interpreted as the next request on a persistent connection.
  82.  
  83.   $rc = $r->discard_request_body();
  84.  
  85. =over 4
  86.  
  87. =item obj: C<$r>
  88. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  89.  
  90. The current request
  91.  
  92. =item ret: C<$rc> ( integer )
  93.  
  94. C<L<APR::Const status constant|docs::2.0::api::APR::Const>> if request
  95. is malformed, C<Apache::OK> otherwise.
  96.  
  97. =item since: 1.99_10
  98.  
  99. =back
  100.  
  101. Since we return an error status if the request is malformed, this
  102. routine should be called at the beginning of a no-body handler, e.g.,
  103.  
  104.    use Apache::Const -compile => qw(OK);
  105.    $rc = $r->discard_request_body;
  106.    return $rc if $rc != Apache::OK;
  107.  
  108.  
  109.  
  110.  
  111.  
  112. =head2 C<print>
  113.  
  114. Send data to the client.
  115.  
  116.   $cnt = $r->print(@msg);
  117.  
  118. =over 4
  119.  
  120. =item obj: C<$r>
  121. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  122.  
  123. =item arg1: C<@msg> ( ARRAY )
  124.  
  125. Data to send
  126.  
  127. =item ret: C<$cnt> ( number )
  128.  
  129. How many bytes were sent (or buffered)
  130.  
  131. =item excpt: C<L<APR::Error|docs::2.0::api::APR::Error>>
  132.  
  133. =item since: 1.99_10
  134.  
  135. =back
  136.  
  137. The data is flushed only if STDOUT stream's C<$|> is true. Otherwise
  138. it's buffered up to the size of the buffer, flushing only excessive
  139. data.
  140.  
  141.  
  142.  
  143.  
  144. =head2 C<printf>
  145.  
  146. Format and send data to the client (same as C<printf>).
  147.  
  148.   $cnt = $r->printf($format, @args);
  149.  
  150. =over 4
  151.  
  152. =item obj: C<$r>
  153. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  154.  
  155. =item arg1: C<$format> ( string )
  156.  
  157. Format string, as in the Perl core C<printf> function.
  158.  
  159. =item arg2: C<@args> ( ARRAY )
  160.  
  161. Arguments to be formatted, as in the Perl core C<printf> function.
  162.  
  163. =item ret: C<$cnt> ( number )
  164.  
  165. How many bytes were sent (or buffered)
  166.  
  167. =item excpt: C<L<APR::Error|docs::2.0::api::APR::Error>>
  168.  
  169. =item since: 1.99_10
  170.  
  171. =back
  172.  
  173. The data is flushed only if STDOUT stream's C<$|> is true. Otherwise
  174. it's buffered up to the size of the buffer, flushing only excessive
  175. data.
  176.  
  177.  
  178.  
  179.  
  180. =head2 C<puts>
  181.  
  182. Send data to the client
  183.  
  184.   $cnt = $r->puts(@msg);
  185.  
  186. =over 4
  187.  
  188. =item obj: C<$r>
  189. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  190.  
  191. =item arg1: C<@msg> ( ARRAY )
  192.  
  193. Data to send
  194.  
  195. =item ret: C<$cnt> ( number )
  196.  
  197. How many bytes were sent (or buffered)
  198.  
  199. =item excpt: C<L<APR::Error|docs::2.0::api::APR::Error>>
  200.  
  201. =item since: 1.99_10
  202.  
  203. =back
  204.  
  205. C<puts()> is similar to C<L<print()|/C_print_>>, but it won't attempt
  206. to flush data, no matter what the value of STDOUT stream's C<$|>
  207. is. Therefore assuming that STDOUT stream's C<$|> is true, this method
  208. should be a tiny bit faster than C<L<print()|/C_print_>>, especially
  209. if small strings are printed.
  210.  
  211.  
  212.  
  213.  
  214.  
  215. =head2 C<read>
  216.  
  217. Read data from the client.
  218.  
  219.   $cnt = $r->read($buffer, $len);
  220.   $cnt = $r->read($buffer, $len, $offset);
  221.  
  222. =over 4
  223.  
  224. =item obj: C<$r>
  225. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  226.  
  227. =item arg1: C<$buffer> ( SCALAR )
  228.  
  229. The buffer to populate with the read data
  230.  
  231. =item arg2: C<$len> ( number )
  232.  
  233. How many bytes to attempt to read
  234.  
  235. =item opt arg3: C<$offset> ( number )
  236.  
  237. If a non-zero C<$offset> is specified, the read data will be placed at
  238. that offset in the C<$buffer>.
  239.  
  240. META: negative offset and \0 padding are not supported at the moment
  241.  
  242. =item ret: C<$cnt> ( number )
  243.  
  244. How many characters were actually read
  245.  
  246. =item excpt: C<L<APR::Error|docs::2.0::api::APR::Error>>
  247.  
  248. =item since: 1.99_10
  249.  
  250. =back
  251.  
  252. This method shares a lot of similarities with the Perl core C<read()>
  253. function. The main difference in the error handling, which is done via
  254. C<L<APR::Error exceptions|docs::2.0::api::APR::Error>>
  255.  
  256.  
  257.  
  258.  
  259. =head2 C<rflush>
  260.  
  261. Flush any buffered data to the client.
  262.  
  263.   $r->rflush();
  264.  
  265. =over 4
  266.  
  267. =item obj: C<$r>
  268. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  269.  
  270. =item ret: no return value
  271.  
  272. =item since: 1.99_15
  273.  
  274. =back
  275.  
  276. Unless STDOUT stream's C<$|> is false, data sent via
  277. C<L<$r-E<gt>print()|/C_print_>> is buffered. This method flushes that
  278. data to the client.
  279.  
  280.  
  281.  
  282.  
  283.  
  284. =head2 C<sendfile>
  285.  
  286. Send a file or a part of it
  287.  
  288.   $rc = $r->sendfile($filename);
  289.   $rc = $r->sendfile($filename, $offset);
  290.   $rc = $r->sendfile($filename, $offset, $len);
  291.  
  292. =over 4
  293.  
  294. =item obj: C<$r>
  295. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  296.  
  297. =item arg1: C<$filename> ( string )
  298.  
  299. The full path to the file (using C</> on all systems)
  300.  
  301. =item opt arg2: C<$offset> ( integer )
  302.  
  303. Offset into the file to start sending.
  304.  
  305. No offset is used if C<$offset> is not specified.
  306.  
  307. =item opt arg3: C<$len> ( integer )
  308.  
  309. How many bytes to send.
  310.  
  311. If not specified the whole file is sent (or a part of it, if
  312. C<$offset> if specified)
  313.  
  314. =item ret: C<$rc> ( C<L<APR::Const status
  315. constant|docs::2.0::api::APR::Const>> )
  316.  
  317. On success,
  318. C<L<APR::SUCCESS|docs::2.0::api::APR::Const/C_APR__SUCCESS_>> is
  319. returned.
  320.  
  321. In case of a failure -- a failure code is returned, in which case
  322. normally it should be returned to the caller.
  323.  
  324. =item excpt: C<L<APR::Error|docs::2.0::api::APR::Error>>
  325.  
  326. Exceptions are thrown only when this function is called in the VOID
  327. context. So if you don't want to handle the errors, just don't ask for
  328. a return value and the function will handle all the errors on its own.
  329.  
  330. =item since: 1.99_15
  331.  
  332. =back
  333.  
  334.  
  335.  
  336.  
  337.  
  338. =head2 C<write>
  339.  
  340. Send partial string to the client
  341.  
  342.   $cnt = $r->write($buffer);
  343.   $cnt = $r->write($buffer, $len);
  344.   $cnt = $r->write($buffer, $len, $offset);
  345.  
  346. =over 4
  347.  
  348. =item obj: C<$r>
  349. ( C<L<Apache::RequestRec object|docs::2.0::api::Apache::RequestRec>> )
  350.  
  351. =item arg1: C<$buffer> ( SCALAR )
  352.  
  353. The string with data
  354.  
  355. =item opt arg2: C<$len> ( SCALAR )
  356.  
  357. How many bytes to send. If not specified, or -1 is specified, all the
  358. data in C<$buffer> (or starting from C<$offset>) will be sent.
  359.  
  360. =item opt arg3: C<$offset> ( number )
  361.  
  362. Offset into the C<$buffer> string.
  363.  
  364. =item ret: C<$cnt> ( number )
  365.  
  366. How many bytes were sent (or buffered)
  367.  
  368. =item excpt: C<L<APR::Error|docs::2.0::api::APR::Error>>
  369.  
  370. =item since: 1.99_10
  371.  
  372. =back
  373.  
  374. Examples:
  375.  
  376. Assuming that we have a string:
  377.  
  378.   $string = "123456789";
  379.  
  380. Then:
  381.  
  382.   $r->write($string);
  383.  
  384. sends:
  385.  
  386.   123456789
  387.  
  388. Whereas:
  389.  
  390.   $r->write($string, 3);
  391.  
  392. sends:
  393.  
  394.   123
  395.  
  396. And:
  397.  
  398.   $r->write($string, 3, 5);
  399.  
  400. sends:
  401.  
  402.   678
  403.  
  404. Finally:
  405.  
  406.   $r->write($string, -1, 5);
  407.  
  408. sends:
  409.  
  410.   6789
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419. =head1 TIE Interface
  420.  
  421. The TIE interface implementation. This interface is used for HTTP
  422. request handlers, when running under C<L<SetHandler
  423. perl-script|docs::2.0::user::config::config/C_perl_script_>> and
  424. Perl doesn't have perlio enabled.
  425.  
  426. See the I<perltie> manpage for more information.
  427.  
  428.  
  429.  
  430.  
  431. =head2 C<BINMODE>
  432.  
  433. =over 4
  434.  
  435. =item since: 1.99_10
  436.  
  437. =back
  438.  
  439. NoOP
  440.  
  441. See the I<binmode> Perl entry in the I<perlfunc> manpage
  442.  
  443.  
  444.  
  445. =head2 C<CLOSE>
  446.  
  447. =over 4
  448.  
  449. =item since: 1.99_10
  450.  
  451. =back
  452.  
  453. NoOP
  454.  
  455. See the I<close> Perl entry in the I<perlfunc> manpage
  456.  
  457.  
  458.  
  459. =head2 C<FILENO>
  460.  
  461. =over 4
  462.  
  463. =item since: 1.99_10
  464.  
  465. =back
  466.  
  467. See the I<fileno> Perl entry in the I<perlfunc> manpage
  468.  
  469.  
  470.  
  471.  
  472. =head2 C<GETC>
  473.  
  474. =over 4
  475.  
  476. =item since: 1.99_10
  477.  
  478. =back
  479.  
  480. See the I<getc> Perl entry in the I<perlfunc> manpage
  481.  
  482.  
  483.  
  484.  
  485. =head2 C<OPEN>
  486.  
  487. =over 4
  488.  
  489. =item since: 1.99_10
  490.  
  491. =back
  492.  
  493. See the I<open> Perl entry in the I<perlfunc> manpage
  494.  
  495.  
  496.  
  497.  
  498.  
  499. =head2 C<PRINT>
  500.  
  501. =over 4
  502.  
  503. =item since: 1.99_10
  504.  
  505. =back
  506.  
  507. See the I<print> Perl entry in the I<perlfunc> manpage
  508.  
  509.  
  510.  
  511.  
  512. =head2 C<PRINTF>
  513.  
  514. =over 4
  515.  
  516. =item since: 1.99_10
  517.  
  518. =back
  519.  
  520. See the I<printf> Perl entry in the I<perlfunc> manpage
  521.  
  522.  
  523.  
  524.  
  525. =head2 C<READ>
  526.  
  527. =over 4
  528.  
  529. =item since: 1.99_10
  530.  
  531. =back
  532.  
  533. See the I<read> Perl entry in the I<perlfunc> manpage
  534.  
  535.  
  536.  
  537.  
  538.  
  539. =head2 C<TIEHANDLE>
  540.  
  541. =over 4
  542.  
  543. =item since: 1.99_10
  544.  
  545. =back
  546.  
  547. See the I<tie> Perl entry in the I<perlfunc> manpage
  548.  
  549.  
  550.  
  551.  
  552. =head2 C<UNTIE>
  553.  
  554. =over 4
  555.  
  556. =item since: 1.99_10
  557.  
  558. =back
  559.  
  560. NoOP
  561.  
  562. See the I<untie> Perl entry in the I<perlfunc> manpage
  563.  
  564.  
  565.  
  566.  
  567.  
  568. =head2 C<WRITE>
  569.  
  570. =over 4
  571.  
  572. =item since: 1.99_10
  573.  
  574. =back
  575.  
  576. See the I<write> Perl entry in the I<perlfunc> manpage
  577.  
  578.  
  579.  
  580.  
  581. =head1 Deprecated API
  582.  
  583. The following methods are deprecated, Apache plans to remove those in
  584. the future, therefore avoid using them.
  585.  
  586.  
  587.  
  588. =head2 C<get_client_block>
  589.  
  590. This method is deprecated since the C implementation is buggy and we
  591. don't want you to use it at all. Instead use the plain
  592. C<L<$r-E<gt>read()|/C_read_>>.
  593.  
  594.  
  595.  
  596.  
  597. =head2 C<setup_client_block>
  598.  
  599. This method is deprecated since
  600. C<L<$r-E<gt>get_client_block|/C__get_client_block_>> is deprecated.
  601.  
  602.  
  603.  
  604.  
  605. =head2 C<should_client_block>
  606.  
  607. This method is deprecated since
  608. C<L<$r-E<gt>get_client_block|/C__get_client_block_>> is deprecated.
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615. =head1 See Also
  616.  
  617. L<mod_perl 2.0 documentation|docs::2.0::index>.
  618.  
  619.  
  620.  
  621.  
  622. =head1 Copyright
  623.  
  624. mod_perl 2.0 and its core modules are copyrighted under
  625. The Apache Software License, Version 2.0.
  626.  
  627.  
  628.  
  629.  
  630. =head1 Authors
  631.  
  632. L<The mod_perl development team and numerous
  633. contributors|about::contributors::people>.
  634.  
  635. =cut
  636.  
  637.