@@ -40,33 +40,34 @@ end user could usually observe the change of the URL in her web browser's
4040address bar while this is not the case for internal ones. "Internal
4141redirections"
4242are very similar to the C<exec> command in
43- C< Bourne Shell> (or C<Bash>) ; it is a "one way trip" and never returns. Another
44- similar example is the C<goto> statement in the C<C> language.
43+ Bourne Shell; it is a "one way trip" and never returns. Another
44+ similar example is the C<goto> statement in the C language.
4545
4646Being an "internal redirection", the request after the redirection
4747remains the original one. It is just the current C<location> that is changed,
4848so we are still using the original copy of the Nginx variable containers. Back
49- to our example, the whole workflow is like this: Nginx first assigns to the
49+ to our example, the whole process looks like this: Nginx first assigns to the
5050C<$a> variable the string value C<hello> via the L<ngx_rewrite/set> directive
5151in C<location /foo>, and then it issues an internal redirection via the
5252L<ngx_echo/echo_exec> directive, thus leaving C<location /foo> and entering
5353C<location /bar>, and finally it
54- outputs the value of C<$a>. Because the value container of C<$a> remains the
55- original one , we can expect the response output to be C<hello>. The test result
54+ outputs the value of C<$a>. Because the value container of C<$a> remains
55+ untouched , we can expect the response output to be C<hello>. The test result
5656confirms this:
5757
5858 :bash
5959 $ curl localhost:8080/foo
6060 a = [hello]
6161
6262But when accessing C</bar> directly from the client side, we will get an empty
63- value for the C<$a> value , since this variable relies on C<location /foo> to
63+ value for the C<$a> variable , since this variable relies on C<location /foo> to
6464get initialized.
6565
6666It can be observed that during a request's lifetime, the copy
6767of Nginx variable containers does not change at all even when Nginx goes across
68- different C<location> configuration blocks. Here we also meet the concept of
69- "internal redirections" for the first time and it's worth mentioning that, the
68+ different C<location> configuration blocks. Here we also encounter the concept
69+ of
70+ "internal redirections" for the first time and it's worth mentioning that the
7071L<ngx_rewrite/rewrite> directive of the L<ngx_rewrite> module can also be used
7172to initiate "internal redirections". For instance, we can rewrite the example
7273above with the L<ngx_rewrite/rewrite> directive as follows:
@@ -105,10 +106,10 @@ Let's call this kind of variables "built-in variables".
105106One common use of Nginx built-in variables is to retrieve various types of
106107information about the current request or response. For instance, the built-in
107108variable L<ngx_core/$uri> provided by L<ngx_http_core> is used to fetch the
108- (decoded) URI of the current request, excluding any query- string arguments.
109+ (decoded) URI of the current request, excluding any query string arguments.
109110Another example is the L<ngx_core/$request_uri> variable provided by the same
110111module, which is used to fetch the raw, non-decoded form of the URI, including
111- any query- string. Let's look at the following example.
112+ any query string. Let's look at the following example.
112113
113114 :nginx
114115 location /test {
@@ -140,10 +141,10 @@ requests:
140141There is another very common built-in variable that does not have a fixed
141142variable name. Instead, It has I<infinite> variations. That is, all those
142143variables whose names have the prefix C<arg_>, like C<$arg_foo> and
143- C<$arg_bar>. Let's just call it the C <$arg_XXX> "variable group". For example,
144+ C<$arg_bar>. Let's just call it the L <$arg_XXX> "variable group". For example,
144145the C<$arg_name> variable is evaluated to the value of the C<name> URI argument
145146for the current request. Also, the URI argument's value obtained here is not
146- decoded yet, potentially containing C<%XX> sequences. Let's check out a
147+ decoded yet, potentially containing the C<%XX> sequences. Let's check out a
147148complete example:
148149
149150 :nginx
@@ -152,7 +153,7 @@ complete example:
152153 echo "class: $arg_class";
153154 }
154155
155- Then we test this interface out with various different URI argument
156+ Then we test this interface with various different URI argument
156157combinations:
157158
158159 :bash
@@ -181,7 +182,7 @@ C<NAME> or even C<Name>. That is, the letter case does not matter here:
181182
182183Behind the scene, Nginx just converts the URI argument names into the
183184pure lower-case form before matching against the name specified by
184- C <$arg_XXX>.
185+ L <$arg_XXX>.
185186
186187If you want to decode the special sequences like C<%20> in the URI argument
187188values, then you could use the L<ngx_set_misc/set_unescape_uri> directive
@@ -203,7 +204,7 @@ Let's check out the actual effect:
203204 name: hello world
204205 class: 9
205206
206- The encoded space has indeed been decoded!
207+ The space has indeed been decoded!
207208
208209Another thing that we can observe from this example is that the
209210L<ngx_set_misc/set_unescape_uri> directive can also implicitly create Nginx
@@ -225,7 +226,7 @@ as the L<$sent_http_XXX> variable group for retrieving response headers. We
225226will not go into the details for each of them here. Interested readers can
226227refer to the official documentation for the L<ngx_http_core> module.
227228
228- === Writing to Built-in Variables ===
229+ === Read-only Built-in Variables ===
229230
230231All the user-defined variables are writable. Actually the way that we declare
231232or create such variables so far is to use a configure directive, like
0 commit comments