📄 apache2::requestrec.3
字号:
\& $r\->finfo($finfo);.Ve.ie n .Sh """handler""".el .Sh "\f(CWhandler\fP".IX Subsection "handler"Get/set the equivalent of the \f(CW\*(C`SetHandler\*(C'\fR directive..PP.Vb 2\& $handler = $r\->handler();\& $prev_handler = $r\->handler($new_handler);.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )".PD 0.ie n .IP "opt arg1: $new_handler ( string )" 4.el .IP "opt arg1: \f(CW$new_handler\fR ( string )" 4.IX Item "opt arg1: $new_handler ( string )".PDthe new handler..ie n .IP "ret: $handler ( string )" 4.el .IP "ret: \f(CW$handler\fR ( string )" 4.IX Item "ret: $handler ( string )"the current handler..SpIf \f(CW$new_handler\fR is passed, the previous value is returned..IP "since: 2.0.00" 4.IX Item "since: 2.0.00".ie n .Sh """header_only""".el .Sh "\f(CWheader_only\fP".IX Subsection "header_only"Did the client has asked for headers only? e.g. if the request methodwas \fB\s-1HEAD\s0\fR..PP.Vb 1\& $status = $r\->header_only();.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )".PD 0.ie n .IP "ret: $status ( boolean )" 4.el .IP "ret: \f(CW$status\fR ( boolean )" 4.IX Item "ret: $status ( boolean )".PDReturns true if the client is asking for headers only, false otherwise.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".ie n .Sh """headers_in""".el .Sh "\f(CWheaders_in\fP".IX Subsection "headers_in"Get/set the request \s-1MIME\s0 headers:.PP.Vb 1\& $headers_in = $r\->headers_in();.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )".PD 0.ie n .IP "ret: $headers_in\fR ( \f(CW""APR::Table object"" )" 4.el .IP "ret: \f(CW$headers_in\fR ( \f(CWAPR::Table object\fR )" 4.IX Item "ret: $headers_in ( APR::Table object )".IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.PPThis table is available starting from the\&\f(CW\*(C`PerlHeaderParserHandler\*(C'\fRphase..PPFor example you can use it to retrieve the cookie value sent by theclient, in the \f(CW\*(C`Cookie:\*(C'\fR header:.PP.Vb 1\& my $cookie = $r\->headers_in\->{Cookie} || \*(Aq\*(Aq;.Ve.ie n .Sh """headers_out""".el .Sh "\f(CWheaders_out\fP".IX Subsection "headers_out"Get/set \s-1MIME\s0 response headers, printed only on 2xx responses..PP.Vb 1\& $headers_out = $r\->headers_out();.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )".PD 0.ie n .IP "ret: $headers_out\fR ( \f(CW""APR::Table object"" )" 4.el .IP "ret: \f(CW$headers_out\fR ( \f(CWAPR::Table object\fR )" 4.IX Item "ret: $headers_out ( APR::Table object )".IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.PPSee also \f(CW\*(C`err_headers_out\*(C'\fR, which allows toset headers for non\-2xx responses and persist across internalredirects..ie n .Sh """hostname""".el .Sh "\f(CWhostname\fP".IX Subsection "hostname"Host, as set by full \s-1URI\s0 or Host:.PP.Vb 2\& $hostname = $r\->hostname();\& $prev_hostname = $r\->hostname($new_hostname);.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )".PD 0.ie n .IP "opt arg1: $new_hostname ( string )" 4.el .IP "opt arg1: \f(CW$new_hostname\fR ( string )" 4.IX Item "opt arg1: $new_hostname ( string )".PDnew value.ie n .IP "ret: $hostname ( string )" 4.el .IP "ret: \f(CW$hostname\fR ( string )" 4.IX Item "ret: $hostname ( string )"the current hostname, or the previous value if the optional\&\f(CW$new_hostname\fR argument was passed.IP "since: 2.0.00" 4.IX Item "since: 2.0.00".ie n .Sh """input_filters""".el .Sh "\f(CWinput_filters\fP".IX Subsection "input_filters"Get/set the first filter in a linked list of request level inputfilters:.PP.Vb 2\& $input_filters = $r\->input_filters();\& $prev_input_filters = $r\->input_filters($new_input_filters);.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )".PD 0.ie n .IP "opt arg1: $new_input_filters" 4.el .IP "opt arg1: \f(CW$new_input_filters\fR" 4.IX Item "opt arg1: $new_input_filters".PDSet a new value.ie n .IP "ret: $input_filters\fR ( \f(CW""Apache2::Filter object"" )" 4.el .IP "ret: \f(CW$input_filters\fR ( \f(CWApache2::Filter object\fR )" 4.IX Item "ret: $input_filters ( Apache2::Filter object )"The first filter in the request level input filters chain..SpIf \f(CW$new_input_filters\fR was passed, returns the previous value..IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PPFor example instead of using\&\f(CW\*(C`$r\->read()\*(C'\fR to readthe \s-1POST\s0 data, one could use an explicit walk through incoming bucketbrigades to get that data. The following function \f(CW\*(C`read_post()\*(C'\fR doesjust that (in fact that's what\&\f(CW\*(C`$r\->read()\*(C'\fR doesbehind the scenes):.PP.Vb 3\& use APR::Brigade ();\& use APR::Bucket ();\& use Apache2::Filter ();\& \& use Apache2::Const \-compile => qw(MODE_READBYTES);\& use APR::Const \-compile => qw(SUCCESS BLOCK_READ);\& \& use constant IOBUFSIZE => 8192;\& \& sub read_post {\& my $r = shift;\& \& my $bb = APR::Brigade\->new($r\->pool,\& $r\->connection\->bucket_alloc);\& \& my $data = \*(Aq\*(Aq;\& my $seen_eos = 0;\& do {\& $r\->input_filters\->get_brigade($bb, Apache2::Const::MODE_READBYTES,\& APR::Const::BLOCK_READ, IOBUFSIZE);\& \& for (my $b = $bb\->first; $b; $b = $bb\->next($b)) {\& if ($b\->is_eos) {\& $seen_eos++;\& last;\& }\& \& if ($b\->read(my $buf)) {\& $data .= $buf;\& }\& \& $b\->remove; # optimization to reuse memory\& }\& \& } while (!$seen_eos);\& \& $bb\->destroy;\& \& return $data;\& }.Ve.PPAs you can see \f(CW\*(C`$r\->input_filters\*(C'\fR gives us a pointer to the lastof the top of the incoming filters stack..ie n .Sh """main""".el .Sh "\f(CWmain\fP".IX Subsection "main"Get the main request record.PP.Vb 1\& $main_r = $r\->main();.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )".PD 0.ie n .IP "ret: $main_r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "ret: \f(CW$main_r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "ret: $main_r ( Apache2::RequestRec object )".PDIf the current request is a sub-request, this method returns a blessedreference to the main request structure. If the current request is themain request, then this method returns \f(CW\*(C`undef\*(C'\fR..SpTo figure out whether you are inside a main request or asub\-request/internal redirect, use\&\f(CW\*(C`$r\->is_initial_req\*(C'\fR..IP "since: 2.0.00" 4.IX Item "since: 2.0.00".ie n .Sh """method""".el .Sh "\f(CWmethod\fP".IX Subsection "method"Get/set the current request method (e.g. \f(CW\*(C`GET\*(C'\fR, \f(CW\*(C`HEAD\*(C'\fR, \f(CW\*(C`POST\*(C'\fR, etc.):.PP.Vb 2\& $method = $r\->method();\& $pre_method = $r\->method($new_method);.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )".PD 0.ie n .IP "opt arg1: $new_method ( string )" 4.el .IP "opt arg1: \f(CW$new_method\fR ( string )" 4.IX Item "opt arg1: $new_method ( string )".PDa new value.ie n .IP "ret: $method ( string )" 4.el .IP "ret: \f(CW$method\fR ( string )" 4.IX Item "ret: $method ( string )"The current method as a string.Spif \f(CW$new_method\fR was passed the previous value is returned..IP "since: 2.0.00" 4.IX Item "since: 2.0.00".ie n .Sh """method_number""".el .Sh "\f(CWmethod_number\fP".IX Subsection "method_number"Get/set the \s-1HTTP\s0 method, issued by the client (\f(CW\*(C`Apache2::Const::M_GET\*(C'\fR,\&\f(CW\*(C`Apache2::Const::M_POST\*(C'\fR, etc.).PP.Vb 2\& $methnum = $r\->method_number();\& $prev_methnum = $r\->method_number($new_methnum);.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )".PD 0.ie n .IP "opt arg1: $new_methnum\fR ( \f(CW""Apache2::Const :methods constant"" )" 4.el .IP "opt arg1: \f(CW$new_methnum\fR ( \f(CWApache2::Const :methods constant\fR )" 4.IX Item "opt arg1: $new_methnum ( Apache2::Const :methods constant )".PDa new value.ie n .IP "ret: $methnum\fR ( \f(CW""Apache2::Const :methods constant"" )" 4.el .IP "ret: \f(CW$methnum\fR ( \f(CWApache2::Const :methods constant\fR )" 4.IX Item "ret: $methnum ( Apache2::Const :methods constant )"The current method as a number.Spif \f(CW$new_methnum\fR was passed the previous value is returned..IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PPSee the \f(CW\*(C`$r\->allowed\*(C'\fR entry for examples..ie n .Sh """mtime""".el .Sh "\f(CWmtime\fP".IX Subsection "mtime"Last modified time of the requested resource.PP.Vb 2\& $mtime = $r\->mtime();\& $prev_mtime = $r\->mtime($new_mtime);.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )".PD 0.ie n .IP "opt arg1: $new_mtime (epoch seconds)." 4.el .IP "opt arg1: \f(CW$new_mtime\fR (epoch seconds)." 4.IX Item "opt arg1: $new_mtime (epoch seconds).".PDa new value.ie n .IP "ret: $mtime (epoch seconds)." 4.el .IP "ret: \f(CW$mtime\fR (epoch seconds)." 4.IX Item "ret: $mtime (epoch seconds)."the current value.Spif \f(CW$new_mtime\fR was passed the previous value is returned..IP "since: 2.0.00" 4.IX Item "since: 2.0.00".ie n .Sh """next""".el .Sh "\f(CWnext\fP".IX Subsection "next"Pointer to the redirected request if this is an external redirect.PP.Vb 1\& $next_r = $r\->next();.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )".PD 0.ie n .IP "ret: $next_r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "ret: \f(CW$next_r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "ret: $next_r ( Apache2::RequestRec object )".PDreturns a blessed reference to the next (internal) request structureor \f(CW\*(C`undef\*(C'\fR if there is no next request..IP "since: 2.0.00" 4.IX Item "since: 2.0.00".ie n .Sh """no_local_copy""".el .Sh "\f(CWno_local_copy\fP".IX Subsection "no_local_copy"There is no local copy of this response.PP.Vb 1\& $status = $r\->no_local_copy();.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )".PD 0.ie n .IP "ret: $status (integer)" 4.el .IP "ret: \f(CW$status\fR (integer)" 4.IX Item "ret: $status (integer)".IP "since: 2.0.00" 4.IX Item "since: 2.0.00".PD.PPUsed internally in certain sub-requests to prevent sending\&\f(CW\*(C`Apache2::Const::HTTP_NOT_MODIFIED\*(C'\fR for a fragment or error documents. Forexample see the implementation in \fImodules/filters/mod_include.c\fR..PPAlso used internally in\&\f(CW\*(C`$r\->meets_conditions\*(C'\fR\&\*(-- if set to a true value, the conditions are always met..ie n .Sh """notes""".el .Sh "\f(CWnotes\fP".IX Subsection "notes"Get/set text notes for the duration of this request. These notes canbe passed from one module to another (not only mod_perl, but modulesin any other language):.PP.Vb 2\& $notes = $r\->notes();\& $prev_notes = $r\->notes($new_notes);.Ve.ie n .IP "obj: $r\fR ( \f(CW""Apache2::RequestRec object"" )" 4.el .IP "obj: \f(CW$r\fR ( \f(CWApache2::RequestRec object\fR )" 4.IX Item "obj: $r ( Apache2::RequestRec object )".PD 0.ie n .IP "opt arg1: $new_notes\fR ( \f(CW""APR::Table object"" )" 4.el .IP "opt arg1: \f(CW$new_notes\fR ( \f(CWAPR::Table object\fR )" 4.IX Item "opt arg1: $new_notes ( APR::Table object )".ie n .IP "ret: $notes\fR ( \f(CW""APR::Table object"" )" 4.el .IP "ret: \f(CW$notes\fR ( \f(CWAPR::Table object\fR )" 4
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -