Skip to content

Commit 154fec5

Browse files
committed
[en] massive wording improvements in "Nginx Variables (03)"; also did some minor edits in (01) and (02).
1 parent ee4cbc5 commit 154fec5

File tree

3 files changed

+147
-132
lines changed

3 files changed

+147
-132
lines changed

en/01-NginxVariables01.tut

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ it. This is required by the language syntax: whenever we want to reference an
4242
Nginx variable in the configuration file, we must add a C<$> prefix. This looks
4343
very familiar to those Perl and PHP programmers.
4444

45-
Such variable prefix modifiers may discomfort some C<Java> and C<C#>
45+
Such variable prefix modifiers may discomfort some Java and C#
4646
programmers, this notation does have an
4747
obvious advantage though, that is, variables can be embedded directly into a
4848
string literal:

en/01-NginxVariables02.tut

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,34 @@ end user could usually observe the change of the URL in her web browser's
4040
address bar while this is not the case for internal ones. "Internal
4141
redirections"
4242
are 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

4646
Being an "internal redirection", the request after the redirection
4747
remains the original one. It is just the current C<location> that is changed,
4848
so 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
5050
C<$a> variable the string value C<hello> via the L<ngx_rewrite/set> directive
5151
in C<location /foo>, and then it issues an internal redirection via the
5252
L<ngx_echo/echo_exec> directive, thus leaving C<location /foo> and entering
5353
C<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
5656
confirms this:
5757

5858
:bash
5959
$ curl localhost:8080/foo
6060
a = [hello]
6161

6262
But 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
6464
get initialized.
6565

6666
It can be observed that during a request's lifetime, the copy
6767
of 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
7071
L<ngx_rewrite/rewrite> directive of the L<ngx_rewrite> module can also be used
7172
to initiate "internal redirections". For instance, we can rewrite the example
7273
above with the L<ngx_rewrite/rewrite> directive as follows:
@@ -105,10 +106,10 @@ Let's call this kind of variables "built-in variables".
105106
One common use of Nginx built-in variables is to retrieve various types of
106107
information about the current request or response. For instance, the built-in
107108
variable 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.
109110
Another example is the L<ngx_core/$request_uri> variable provided by the same
110111
module, 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:
140141
There is another very common built-in variable that does not have a fixed
141142
variable name. Instead, It has I<infinite> variations. That is, all those
142143
variables 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,
144145
the C<$arg_name> variable is evaluated to the value of the C<name> URI argument
145146
for 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
147148
complete 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
156157
combinations:
157158

158159
:bash
@@ -181,7 +182,7 @@ C<NAME> or even C<Name>. That is, the letter case does not matter here:
181182

182183
Behind the scene, Nginx just converts the URI argument names into the
183184
pure lower-case form before matching against the name specified by
184-
C<$arg_XXX>.
185+
L<$arg_XXX>.
185186

186187
If you want to decode the special sequences like C<%20> in the URI argument
187188
values, 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

208209
Another thing that we can observe from this example is that the
209210
L<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
225226
will not go into the details for each of them here. Interested readers can
226227
refer 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

230231
All the user-defined variables are writable. Actually the way that we declare
231232
or create such variables so far is to use a configure directive, like

0 commit comments

Comments
 (0)