⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apache2::filter.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 3 页
字号:
.PPThis method should be used only in streamingfilters..ie n .Sh """read""".el .Sh "\f(CWread\fP".IX Subsection "read"Read data from the filter.PP.Vb 1\&  $read = $f\->read($buffer, $wanted);.Ve.ie n .IP "obj: $f\fR ( \f(CW""Apache2::Filter object"" )" 4.el .IP "obj: \f(CW$f\fR ( \f(CWApache2::Filter object\fR )" 4.IX Item "obj: $f ( Apache2::Filter object )".PD 0.ie n .IP "arg1: $buffer ( \s-1SCALAR\s0 )" 4.el .IP "arg1: \f(CW$buffer\fR ( \s-1SCALAR\s0 )" 4.IX Item "arg1: $buffer ( SCALAR )".PDThe buffer to fill. All previous data will be lost..ie n .IP "opt arg2: $wanted ( integer )" 4.el .IP "opt arg2: \f(CW$wanted\fR ( integer )" 4.IX Item "opt arg2: $wanted ( integer )"How many bytes to attempt to read..SpIf this optional argument is not specified \*(-- the default 8192 will beused..ie n .IP "ret: $read ( integer )" 4.el .IP "ret: \f(CW$read\fR ( integer )" 4.IX Item "ret: $read ( integer )"How many bytes were actually read..Sp\&\f(CW$buffer\fR gets populated with the string that is read. It willcontain an empty string if there was nothing to read..ie n .IP "excpt: ""APR::Error""" 4.el .IP "excpt: \f(CWAPR::Error\fR" 4.IX Item "excpt: APR::Error".PD 0.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.PPReads at most \f(CW$wanted\fR characters into \f(CW$buffer\fR. The returnedvalue \f(CW$read\fR tells exactly how many were read, making it easy to useit in a while loop:.PP.Vb 4\&  while ($filter\->read(my $buffer, $wanted)) {\&      # transform $buffer here\&      $filter\->print($buffer);\&  }.Ve.PPThis is a streaming filter method, which acquires a single bucketbrigade behind the scenes and reads data from all itsbuckets. Therefore it can only read from one bucket brigade per filterinvocation..PPIf the \s-1EOS\s0 bucket is read, the \f(CW\*(C`seen_eos\*(C'\fR method willreturn a true value..ie n .Sh """seen_eos""".el .Sh "\f(CWseen_eos\fP".IX Subsection "seen_eos"This methods returns a true value when the \s-1EOS\s0 bucket is seen by the\&\f(CW\*(C`read\*(C'\fR method..PP.Vb 1\&  $ok = $f\->seen_eos;.Ve.ie n .IP "obj: $f\fR ( \f(CW""Apache2::Filter object"" )" 4.el .IP "obj: \f(CW$f\fR ( \f(CWApache2::Filter object\fR )" 4.IX Item "obj: $f ( Apache2::Filter object )"The filter to remove.ie n .IP "ret: $ok ( boolean )" 4.el .IP "ret: \f(CW$ok\fR ( boolean )" 4.IX Item "ret: $ok ( boolean )"a true value if \s-1EOS\s0 has been seen, otherwise a false value.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PPThis method only works in streaming filters which exhaustively\&\f(CW\*(C`$f\->read\*(C'\fR all the incoming data in a while loop,like so:.PP.Vb 6\&      while ($f\->read(my $buffer, $wanted)) {\&          # do something with $buffer\&      }\&      if ($f\->seen_eos) {\&          # do something\&      }.Ve.PPThe technique in this example is useful when a streaming filter wantsto append something to the very end of data, or do something at theend of the last filter invocation. After the \s-1EOS\s0 bucket is read, thefilter should expect not to be invoked again..PPIf an input streaming filter doesn't consume all data in the bucketbrigade (or even in several bucket brigades), it has to generate the\&\s-1EOS\s0 event by itself. So when the filter is done it has to set the \s-1EOS\s0flag:.PP.Vb 1\&  $f\->seen_eos(1);.Ve.PPwhen the filter handler returns, internally mod_perl will take care ofcreating and sending the \s-1EOS\s0 bucket to the upstream input filter..PPA similar logic may apply for output filters..PPIn most other cases you shouldn't set this flag.  When this flag isprematurely set (before the real \s-1EOS\s0 bucket has arrived) in thecurrent filter invocation, instead of invoking the filter again,mod_perl will create and send the \s-1EOS\s0 bucket to the next filter,ignoring any other bucket brigades that may have left to consume. Asmentioned earlier this special behavior is useful in writing specialtests that test abnormal situations..SH "Other Filter-related API".IX Header "Other Filter-related API"Other methods which affect filters, but called onnon\-\f(CW\*(C`Apache2::Filter\*(C'\fR objects:.ie n .Sh """add_input_filter""".el .Sh "\f(CWadd_input_filter\fP".IX Subsection "add_input_filter"Add \f(CW&callback\fR filter handler to input request filter chain..PP.Vb 1\&  $r\->add_input_filter(\e&callback);.Ve.PPAdd \f(CW&callback\fR filter handler to input connection filter chain..PP.Vb 1\&  $c\->add_input_filter(\e&callback);.Ve.ie n .IP "obj: $c\fR ( \f(CW""Apache2::Connection object""\fR ) or \f(CW$r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$c\fR ( \f(CWApache2::Connection object\fR ) or \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $c ( Apache2::Connection object ) or $r ( Apache2::RequestRec object )".PD 0.ie n .IP "arg1: &callback (\s-1CODE\s0 ref)" 4.el .IP "arg1: \f(CW&callback\fR (\s-1CODE\s0 ref)" 4.IX Item "arg1: &callback (CODE ref)".IP "ret: no return value" 4.IX Item "ret: no return value".IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.PP[\s-1META:\s0 It seems that you can't add a filter when another filter iscalled. I've tried to add an output connection filter from the inputconnection filter when it was called for the first time. It didn'thave any affect for the first request (over keepalive connection). Theonly way I succeeded to do that is from that input connection filter'sfilter_init handler.In fact it does work if there is any filter additional filter of thesame kind configured from httpd.conf or via filter_init. It looks likethere is a bug in httpd, where it doesn't prepare the chain of 3rdparty filter if none were inserted before the first filter was called.].ie n .Sh """add_output_filter""".el .Sh "\f(CWadd_output_filter\fP".IX Subsection "add_output_filter"Add \f(CW&callback\fR filter handler to output request filter chain..PP.Vb 1\&  $r\->add_output_filter(\e&callback);.Ve.PPAdd \f(CW&callback\fR filter handler to output connection filter chain..PP.Vb 1\&  $c\->add_output_filter(\e&callback);.Ve.ie n .IP "obj: $c\fR ( \f(CW""Apache2::Connection object""\fR ) or \f(CW$r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$c\fR ( \f(CWApache2::Connection object\fR ) or \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $c ( Apache2::Connection object ) or $r ( Apache2::RequestRec object )".PD 0.ie n .IP "arg1: &callback (\s-1CODE\s0 ref)" 4.el .IP "arg1: \f(CW&callback\fR (\s-1CODE\s0 ref)" 4.IX Item "arg1: &callback (CODE ref)".IP "ret: no return value" 4.IX Item "ret: no return value".IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.SH "Filter Handler Attributes".IX Header "Filter Handler Attributes"Packages using filter attributes have to subclass \f(CW\*(C`Apache2::Filter\*(C'\fR:.PP.Vb 2\&  package MyApache2::FilterCool;\&  use base qw(Apache2::Filter);.Ve.PPAttributes are parsed during the code compilation, by the function\&\f(CW\*(C`MODIFY_CODE_ATTRIBUTES\*(C'\fR, inherited from the \f(CW\*(C`Apache2::Filter\*(C'\fRpackage..ie n .Sh """FilterRequestHandler""".el .Sh "\f(CWFilterRequestHandler\fP".IX Subsection "FilterRequestHandler"The \f(CW\*(C`FilterRequestHandler\*(C'\fR attribute tells mod_perl to insert thefilter into an \s-1HTTP\s0 request filter chain..PPFor example, to configure an output request filter handler, use the\&\f(CW\*(C`FilterRequestHandler\*(C'\fR attribute in the handler subroutine'sdeclaration:.PP.Vb 2\&  package MyApache2::FilterOutputReq;\&  sub handler : FilterRequestHandler { ... }.Ve.PPand add the configuration entry:.PP.Vb 1\&  PerlOutputFilterHandler MyApache2::FilterOutputReq.Ve.PPThis is the default mode. So if you are writing an \s-1HTTP\s0 requestfilter, you don't have to specify this attribute..PPThe section \s-1HTTP\s0 Request vs. ConnectionFiltersdelves into more details..ie n .Sh """FilterConnectionHandler""".el .Sh "\f(CWFilterConnectionHandler\fP".IX Subsection "FilterConnectionHandler"The \f(CW\*(C`FilterConnectionHandler\*(C'\fR attribute tells mod_perl to insert thisfilter into a connection filter chain..PPFor example, to configure an output connection filter handler, use the\&\f(CW\*(C`FilterConnectionHandler\*(C'\fR attribute in the handler subroutine'sdeclaration:.PP.Vb 2\&  package MyApache2::FilterOutputCon;\&  sub handler : FilterConnectionHandler { ... }.Ve.PPand add the configuration entry:.PP.Vb 1\&  PerlOutputFilterHandler MyApache2::FilterOutputCon.Ve.PPThe section \s-1HTTP\s0 Request vs. ConnectionFiltersdelves into more details..ie n .Sh """FilterInitHandler""".el .Sh "\f(CWFilterInitHandler\fP".IX Subsection "FilterInitHandler"The attribute \f(CW\*(C`FilterInitHandler\*(C'\fR marks the function suitable to beused as a filter initialization callback, which is called immediatelyafter a filter is inserted to the filter chain and before it'sactually called..PP.Vb 5\&  sub init : FilterInitHandler {\&      my $f = shift;\&      #...\&      return Apache2::Const::OK;\&  }.Ve.PPIn order to hook this filter callback, the real filter has to assignthis callback using the\&\f(CW\*(C`FilterHasInitHandler\*(C'\fR which accepts areference to the callback function..PPFor further discussion and examples refer to the FilterInitializationPhasetutorial section..ie n .Sh """FilterHasInitHandler""".el .Sh "\f(CWFilterHasInitHandler\fP".IX Subsection "FilterHasInitHandler"If a filter wants to run an initialization callback it can registersuch using the \f(CW\*(C`FilterHasInitHandler\*(C'\fR attribute. Similar to\&\f(CW\*(C`push_handlers\*(C'\fR the callback reference is expected, rather than acallback name. The used callback function has to have the\&\f(CW\*(C`FilterInitHandler\*(C'\fR attribute. For example:.PP.Vb 8\&  package MyApache2::FilterBar;\&  use base qw(Apache2::Filter);\&  sub init   : FilterInitHandler { ... }\&  sub filter : FilterRequestHandler FilterHasInitHandler(\e&init) {\&      my ($f, $bb) = @_;\&      # ...\&      return Apache2::Const::OK;\&  }.Ve.PPFor further discussion and examples refer to the FilterInitializationPhasetutorial section..SH "Configuration".IX Header "Configuration"mod_perl 2.0 filters configuration is explained in the filterhandlerstutorial..ie n .Sh """PerlInputFilterHandler""".el .Sh "\f(CWPerlInputFilterHandler\fP".IX Subsection "PerlInputFilterHandler"See\&\f(CW\*(C`PerlInputFilterHandler\*(C'\fR..ie n .Sh """PerlOutputFilterHandler""".el .Sh "\f(CWPerlOutputFilterHandler\fP".IX Subsection "PerlOutputFilterHandler"See\&\f(CW\*(C`PerlOutputFilterHandler\*(C'\fR..ie n .Sh """PerlSetInputFilter""".el .Sh "\f(CWPerlSetInputFilter\fP".IX Subsection "PerlSetInputFilter"See\&\f(CW\*(C`PerlSetInputFilter\*(C'\fR..ie n .Sh """PerlSetOutputFilter""".el .Sh "\f(CWPerlSetOutputFilter\fP".IX Subsection "PerlSetOutputFilter"See\&\f(CW\*(C`PerlSetInputFilter\*(C'\fR..SH "TIE Interface".IX Header "TIE Interface"\&\f(CW\*(C`Apache2::Filter\*(C'\fR also implements a tied interface, so you can workwith the \f(CW$f\fR object as a hash reference..PPThe \s-1TIE\s0 interface is mostly unimplemented and might be implementedpost 2.0 release..ie n .Sh """TIEHANDLE""".el .Sh "\f(CWTIEHANDLE\fP".IX Subsection "TIEHANDLE".Vb 1\&  $ret = TIEHANDLE($stashsv, $sv);.Ve.ie n .IP "obj: $stashsv ( \s-1SCALAR\s0 )" 4.el .IP "obj: \f(CW$stashsv\fR ( \s-1SCALAR\s0 )" 4.IX Item "obj: $stashsv ( SCALAR )".PD 0.ie n .IP "arg1: $sv ( \s-1SCALAR\s0 )" 4.el .IP "arg1: \f(CW$sv\fR ( \s-1SCALAR\s0 )" 4.IX Item "arg1: $sv ( SCALAR )".ie n .IP "ret: $ret ( \s-1SCALAR\s0 )" 4.el .IP "ret: \f(CW$ret\fR ( \s-1SCALAR\s0 )" 4.IX Item "ret: $ret ( SCALAR )".IP "since: subject to change" 4.IX Item "since: subject to change".PD.ie n .Sh """PRINT""".el .Sh "\f(CWPRINT\fP".IX Subsection "PRINT".Vb 1\&  $ret = PRINT(...);.Ve.ie n .IP "obj: ""..."" (\s-1XXX\s0)" 4.el .IP "obj: \f(CW...\fR (\s-1XXX\s0)" 4.IX Item "obj: ... (XXX)".PD 0.ie n .IP "ret: $ret ( integer )" 4.el .IP "ret: \f(CW$ret\fR ( integer )" 4.IX Item "ret: $ret ( integer )".IP "since: subject to change" 4.IX Item "since: subject to change".PD.SH "See Also".IX Header "See Also"mod_perl 2.0 documentation..SH "Copyright".IX Header "Copyright"mod_perl 2.0 and its core modules are copyrighted underThe Apache Software License, Version 2.0..SH "Authors".IX Header "Authors"The mod_perl development team and numerouscontributors.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -