Mercurial > hg > nginx-site
annotate xml/en/docs/http/ngx_http_perl_module.xml @ 760:f0e3d07c66d8
Documented $r->log_error method, redirection limitation, removed outdated info.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Mon, 12 Nov 2012 07:45:20 +0000 |
parents | ddec437b692b |
children | 95c3c3bbf1ce |
rev | line source |
---|---|
416
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1 <?xml version="1.0"?> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
2 |
580
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
416
diff
changeset
|
3 <!-- |
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
416
diff
changeset
|
4 Copyright (C) Igor Sysoev |
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
416
diff
changeset
|
5 Copyright (C) Nginx, Inc. |
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
416
diff
changeset
|
6 --> |
be54c443235a
Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents:
416
diff
changeset
|
7 |
416
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
8 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd"> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
9 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
10 <module name="Module ngx_http_perl_module" |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
11 link="/en/docs/http/ngx_http_perl_module.html" |
589 | 12 lang="en" |
760
f0e3d07c66d8
Documented $r->log_error method, redirection limitation, removed outdated info.
Vladimir Homutov <vl@nginx.com>
parents:
747
diff
changeset
|
13 rev="2"> |
416
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
14 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
15 <section id="summary"> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
16 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
17 <para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
18 The <literal>ngx_http_perl_module</literal> module allows to implement |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
19 location and variable handlers in Perl, and to insert Perl calls into SSI. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
20 </para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
21 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
22 <para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
23 This module is not built by default, it should be enabled with the |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
24 <literal>--with-http_perl_module</literal> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
25 configuration parameter. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
26 <note> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
27 This module requires Perl version 5.6.1 or higher. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
28 The C compiler should be compatible with that used to build Perl. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
29 </note> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
30 </para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
31 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
32 </section> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
33 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
34 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
35 <section id="bugs" name="Known Bugs"> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
36 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
37 <para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
38 The module is experimental, caveat emptor applies. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
39 </para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
40 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
41 <para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
42 In order for Perl to recompile the modified modules during |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
43 reconfiguration, it needs to be built with the parameters |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
44 <literal>-Dusemultiplicity=yes</literal> or |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
45 <literal>-Dusethreads=yes</literal>. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
46 Also, in order for Perl to leak less memory at run time, |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
47 it needs to be built with the |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
48 <literal>-Dusemymalloc=no</literal> parameter. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
49 To check the values of these parameters in an already built |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
50 Perl (preferred values are specified in the example), run: |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
51 <example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
52 $ perl -V:usemultiplicity -V:usemymalloc |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
53 usemultiplicity='define'; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
54 usemymalloc='n'; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
55 </example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
56 </para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
57 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
58 <para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
59 Note that after rebuilding Perl with the new parameters |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
60 <literal>-Dusemultiplicity=yes</literal> or |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
61 <literal>-Dusethreads=yes</literal>, |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
62 all binary Perl modules will have to be rebuilt as well — |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
63 they will just stop working with the new Perl. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
64 </para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
65 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
66 <para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
67 It is possible for the main process and then worker processes |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
68 to grow in size after every reconfiguration. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
69 If the main process grows to an unacceptable size, the |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
70 <link doc="../control.xml" id="upgrade">live upgrade</link> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
71 procedure can be applied without changing an executable file. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
72 </para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
73 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
74 <para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
75 While a Perl module performs long term operation, for example, resolves |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
76 a domain name, connects to another server, queries a database, |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
77 other requests assigned to this worker process will not be processed. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
78 It is thus recommended to limit the work done to operations |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
79 that have predictable and short execution time, for example, |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
80 access local file system. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
81 </para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
82 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
83 <para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
84 The below mentioned issues only affect versions of nginx before 0.6.22. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
85 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
86 <note> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
87 Data returned by the <literal>$r</literal> request object methods |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
88 only has a text value, and the value itself is stored in memory |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
89 allocated by nginx from its own pools, not by Perl. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
90 This allows to reduce the number of copy operations involved in |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
91 most cases, however it can lead to errors in some cases. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
92 For example, a worker process trying to use such a data in the |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
93 numeric context will terminate with an error (FreeBSD): |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
94 <example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
95 nginx in realloc(): warning: pointer to wrong page |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
96 Out of memory! |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
97 Callback called exit. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
98 </example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
99 or (Linux): |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
100 <example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
101 *** glibc detected *** realloc(): invalid pointer: ... *** |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
102 Out of memory! |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
103 Callback called exit. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
104 </example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
105 The workaround is simple — a method’s value should be assigned |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
106 to a variable. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
107 For example, the following code |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
108 <example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
109 my $i = $r->variable('counter') + 1; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
110 </example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
111 should be replaced by |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
112 <example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
113 my $i = $r->variable('counter'); |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
114 $i++; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
115 </example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
116 </note> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
117 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
118 <note> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
119 Since most strings inside nginx are stored without a terminating null |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
120 character, they are similarly returned by the <literal>$r</literal> request |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
121 object methods (except for the <literal>$r->filename</literal> and |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
122 <literal>$r->request_body_file</literal> methods). |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
123 Thus, such values cannot be used as filenames and the likes. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
124 The workaround is similar to a previous case — the value should either be |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
125 assigned to a variable (this results in data copying that in turn adds |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
126 the necessary null character) or used in an expression, for example: |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
127 <example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
128 open FILE, '/path/' . $r->variable('name'); |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
129 </example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
130 </note> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
131 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
132 </para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
133 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
134 </section> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
135 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
136 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
137 <section id="example" name="Example Configuration"> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
138 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
139 <para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
140 <example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
141 http { |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
142 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
143 perl_modules perl/lib; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
144 perl_require hello.pm; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
145 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
146 perl_set $msie6 ' |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
147 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
148 sub { |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
149 my $r = shift; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
150 my $ua = $r->header_in("User-Agent"); |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
151 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
152 return "" if $ua =~ /Opera/; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
153 return "1" if $ua =~ / MSIE [6-9]\.\d+/; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
154 return ""; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
155 } |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
156 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
157 '; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
158 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
159 server { |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
160 location / { |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
161 perl hello::handler; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
162 } |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
163 } |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
164 </example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
165 </para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
166 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
167 <para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
168 The <path>perl/lib/hello.pm</path> module: |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
169 <example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
170 package hello; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
171 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
172 use nginx; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
173 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
174 sub handler { |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
175 my $r = shift; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
176 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
177 $r->send_http_header("text/html"); |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
178 return OK if $r->header_only; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
179 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
180 $r->print("hello!\n<br/>"); |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
181 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
182 if (-f $r->filename or -d _) { |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
183 $r->print($r->uri, " exists!\n"); |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
184 } |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
185 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
186 return OK; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
187 } |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
188 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
189 1; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
190 __END__ |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
191 </example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
192 </para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
193 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
194 </section> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
195 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
196 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
197 <section id="directives" name="Directives"> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
198 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
199 <directive name="perl"> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
200 <syntax><value>module</value>::<value>function</value>|'sub { ... }'</syntax> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
201 <default/> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
202 <context>location</context> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
203 <context>limit_except</context> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
204 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
205 <para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
206 Installs a Perl handler for the given location. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
207 </para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
208 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
209 </directive> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
210 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
211 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
212 <directive name="perl_modules"> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
213 <syntax><value>path</value></syntax> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
214 <default/> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
215 <context>http</context> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
216 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
217 <para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
218 Sets an additional path for Perl modules. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
219 </para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
220 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
221 </directive> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
222 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
223 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
224 <directive name="perl_require"> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
225 <syntax><value>module</value></syntax> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
226 <default/> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
227 <context>http</context> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
228 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
229 <para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
230 Defines the name of a module that will be loaded during each |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
231 reconfiguration. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
232 There could be several <literal>perl_require</literal> directives. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
233 </para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
234 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
235 </directive> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
236 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
237 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
238 <directive name="perl_set"> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
239 <syntax> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
240 <value>$variable</value> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
241 <value>module</value>::<value>function</value>|'sub { ... }'</syntax> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
242 <default/> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
243 <context>http</context> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
244 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
245 <para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
246 Installs a Perl handler for the specified variable. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
247 </para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
248 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
249 </directive> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
250 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
251 </section> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
252 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
253 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
254 <section id="ssi" name="Calling Perl from SSI"> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
255 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
256 <para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
257 An SSI command calling Perl has the following format: |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
258 <example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
259 <!--# perl sub="<value>module</value>::<value>function</value>" arg="<value>parameter1</value>" arg="<value>parameter2</value>" ... |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
260 --> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
261 </example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
262 </para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
263 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
264 </section> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
265 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
266 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
267 <section id="methods" name="The $r Request Object Methods"> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
268 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
269 <para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
270 <list type="tag"> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
271 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
272 <tag-name><literal>$r->args</literal></tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
273 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
274 returns request arguments. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
275 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
276 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
277 <tag-name><literal>$r->filename</literal></tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
278 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
279 returns a filename corresponding to the request URI. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
280 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
281 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
282 <tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
283 <literal>$r->has_request_body(<value>handler</value>)</literal> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
284 </tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
285 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
286 returns 0 if there is no body in a request. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
287 If there is a body, the specified handler is installed |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
288 and 1 is returned. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
289 After reading the request body, nginx will call the installed handler. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
290 Note that the handler function should be passed by reference. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
291 Example: |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
292 <example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
293 package hello; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
294 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
295 use nginx; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
296 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
297 sub handler { |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
298 my $r = shift; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
299 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
300 if ($r->request_method ne "POST") { |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
301 return DECLINED; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
302 } |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
303 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
304 if ($r->has_request_body(<emphasis>\&post</emphasis>)) { |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
305 return OK; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
306 } |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
307 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
308 return HTTP_BAD_REQUEST; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
309 } |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
310 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
311 sub <emphasis>post</emphasis> { |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
312 my $r = shift; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
313 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
314 $r->send_http_header; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
315 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
316 $r->print("request_body: \"", $r->request_body, "\"<br/>"); |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
317 $r->print("request_body_file: \"", $r->request_body_file, "\"<br/>\n"); |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
318 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
319 return OK; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
320 } |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
321 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
322 1; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
323 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
324 __END__ |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
325 </example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
326 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
327 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
328 <tag-name><literal>$r->allow_ranges</literal></tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
329 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
330 enables the use of byte ranges when sending responses. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
331 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
332 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
333 <tag-name><literal>$r->discard_request_body</literal></tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
334 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
335 instructs nginx to discard a request body. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
336 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
337 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
338 <tag-name><literal>$r->header_in(<value>field</value>)</literal></tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
339 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
340 returns value of the specified client request header field. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
341 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
342 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
343 <tag-name><literal>$r->header_only</literal></tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
344 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
345 determines should the whole response or only its header be sent to a client. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
346 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
347 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
348 <tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
349 <literal>$r->header_out(<value>field</value>, |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
350 <value>value</value>)</literal> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
351 </tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
352 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
353 sets a value for the specified response header field. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
354 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
355 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
356 <tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
357 <literal>$r->internal_redirect(<value>uri</value>)</literal> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
358 </tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
359 <tag-desc> |
747 | 360 does an internal redirect to the specified <value>uri</value>. |
416
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
361 An actual redirect happens after the Perl handler has completed. |
760
f0e3d07c66d8
Documented $r->log_error method, redirection limitation, removed outdated info.
Vladimir Homutov <vl@nginx.com>
parents:
747
diff
changeset
|
362 <note> |
f0e3d07c66d8
Documented $r->log_error method, redirection limitation, removed outdated info.
Vladimir Homutov <vl@nginx.com>
parents:
747
diff
changeset
|
363 Redirections to named locations are not currently supported. |
f0e3d07c66d8
Documented $r->log_error method, redirection limitation, removed outdated info.
Vladimir Homutov <vl@nginx.com>
parents:
747
diff
changeset
|
364 </note> |
f0e3d07c66d8
Documented $r->log_error method, redirection limitation, removed outdated info.
Vladimir Homutov <vl@nginx.com>
parents:
747
diff
changeset
|
365 </tag-desc> |
f0e3d07c66d8
Documented $r->log_error method, redirection limitation, removed outdated info.
Vladimir Homutov <vl@nginx.com>
parents:
747
diff
changeset
|
366 |
f0e3d07c66d8
Documented $r->log_error method, redirection limitation, removed outdated info.
Vladimir Homutov <vl@nginx.com>
parents:
747
diff
changeset
|
367 <tag-name><literal>$r->log_error(<value>errno</value>, |
f0e3d07c66d8
Documented $r->log_error method, redirection limitation, removed outdated info.
Vladimir Homutov <vl@nginx.com>
parents:
747
diff
changeset
|
368 <value>message</value>)</literal></tag-name> |
f0e3d07c66d8
Documented $r->log_error method, redirection limitation, removed outdated info.
Vladimir Homutov <vl@nginx.com>
parents:
747
diff
changeset
|
369 <tag-desc> |
f0e3d07c66d8
Documented $r->log_error method, redirection limitation, removed outdated info.
Vladimir Homutov <vl@nginx.com>
parents:
747
diff
changeset
|
370 writes the specified <value>message</value> into the |
f0e3d07c66d8
Documented $r->log_error method, redirection limitation, removed outdated info.
Vladimir Homutov <vl@nginx.com>
parents:
747
diff
changeset
|
371 <link doc="../ngx_core_module.xml" id="error_log"/>. |
f0e3d07c66d8
Documented $r->log_error method, redirection limitation, removed outdated info.
Vladimir Homutov <vl@nginx.com>
parents:
747
diff
changeset
|
372 If <value>errno</value> is non-zero, an error code and its description |
f0e3d07c66d8
Documented $r->log_error method, redirection limitation, removed outdated info.
Vladimir Homutov <vl@nginx.com>
parents:
747
diff
changeset
|
373 will be appended to the message. |
416
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
374 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
375 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
376 <tag-name><literal>$r->print(<value>text</value>, ...)</literal></tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
377 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
378 passes data to a client. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
379 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
380 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
381 <tag-name><literal>$r->request_body</literal></tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
382 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
383 returns a client request body if it was not |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
384 written to a temporary file. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
385 To ensure that a client request body is in memory, |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
386 its size should be limited with |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
387 <link doc="ngx_http_core_module.xml" id="client_max_body_size"/>, |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
388 and a sufficient buffer size should be set with |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
389 <link doc="ngx_http_core_module.xml" id="client_body_buffer_size"/>. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
390 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
391 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
392 <tag-name><literal>$r->request_body_file</literal></tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
393 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
394 returns the name of a file with the client request body. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
395 At the end of processing, the file needs to be removed. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
396 To always write a request body to a file, |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
397 <link doc="ngx_http_core_module.xml" id="client_body_in_file_only"/> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
398 needs to be enabled. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
399 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
400 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
401 <tag-name><literal>$r->request_method</literal></tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
402 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
403 returns client request HTTP method. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
404 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
405 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
406 <tag-name><literal>$r->remote_addr</literal></tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
407 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
408 returns client IP address. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
409 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
410 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
411 <tag-name><literal>$r->flush</literal></tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
412 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
413 immediately sends data to a client. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
414 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
415 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
416 <tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
417 <literal>$r->sendfile(<value>name</value>[, |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
418 <value>offset</value>[, |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
419 <value>length</value>]])</literal> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
420 </tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
421 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
422 sends the specified file content to a client. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
423 Optional parameters |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
424 specify an initial offset and length of data to be transmitted. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
425 The actual data transmission happens after the Perl handler |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
426 has completed. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
427 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
428 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
429 <tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
430 <literal>$r->send_http_header([<value>type</value>])</literal> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
431 </tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
432 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
433 sends the response header to a client. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
434 An optional <value>type</value> parameter sets the value of |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
435 the <header>Content-Type</header> response header field. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
436 If the value is an empty string, the <header>Content-Type</header> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
437 header field will not be passed. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
438 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
439 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
440 <tag-name><literal>$r->status(<value>code</value>)</literal></tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
441 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
442 sets a response code. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
443 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
444 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
445 <tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
446 <literal>$r->sleep(<value>milliseconds</value>, |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
447 <value>handler</value>)</literal> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
448 </tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
449 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
450 sets the specified handler |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
451 and stops request processing for the specified time. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
452 In the mean time, nginx continues to process other requests. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
453 After the specified time has elapsed, nginx will call the installed handler. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
454 Note that the handler function should be passed by reference. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
455 In order to pass data between handlers, |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
456 <literal>$r->variable()</literal> should be used. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
457 Example: |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
458 <example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
459 package hello; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
460 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
461 use nginx; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
462 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
463 sub handler { |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
464 my $r = shift; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
465 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
466 $r->discard_request_body; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
467 $r->variable("var", "OK"); |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
468 $r->sleep(1000, <emphasis>\&next</emphasis>); |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
469 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
470 return OK; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
471 } |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
472 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
473 sub <emphasis>next</emphasis> { |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
474 my $r = shift; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
475 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
476 $r->send_http_header; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
477 $r->print($r->variable("var")); |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
478 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
479 return OK; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
480 } |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
481 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
482 1; |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
483 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
484 __END__ |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
485 </example> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
486 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
487 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
488 <tag-name><literal>$r->unescape(<value>text</value>)</literal></tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
489 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
490 decodes a text encoded in the “%XX” form. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
491 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
492 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
493 <tag-name><literal>$r->uri</literal></tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
494 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
495 returns a request URI. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
496 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
497 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
498 <tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
499 <literal>$r->variable(<value>name</value>[, |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
500 <value>value</value>])</literal> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
501 </tag-name> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
502 <tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
503 returns or sets a value of the specified variable. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
504 Variables are local to each request. |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
505 </tag-desc> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
506 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
507 </list> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
508 </para> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
509 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
510 </section> |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
511 |
c9c0550465c9
English translation of ngx_http_perl_module.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
512 </module> |