Commit graph

549 commits

Author SHA1 Message Date
Andrei Zeliankou
4b39cb1fc7 Tests: added tests for "path" option in isolation/cgroup. 2022-12-14 19:00:14 +00:00
OutOfFocus4
6dae517ebd Python: Added "prefix" to configuration.
This patch gives users the option to set a `"prefix"` attribute
for Python applications, either at the top level or for specific
`"target"`s. If the attribute is present, the value of `"prefix"`
must be a string beginning with `"/"`. If the value of the `"prefix"`
attribute is longer than 1 character and ends in `"/"`, the
trailing `"/"` is stripped.

The purpose of the `"prefix"` attribute is to set the `SCRIPT_NAME`
context value for WSGI applications and the `root_path` context
value for ASGI applications, allowing applications to properly route
requests regardless of the path that the server uses to expose the
application.

The context value is only set if the request's URL path begins with
the value of the `"prefix"` attribute. In all other cases, the
`SCRIPT_NAME` or `root_path` values are not set. In addition, for
WSGI applications, the value of `"prefix"` will be stripped from
the beginning of the request's URL path before it is sent to the
application.

Reviewed-by: Andrei Zeliankou <zelenkov@nginx.com>
Reviewed-by: Artem Konev <artem.konev@nginx.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-12-14 11:30:30 +01:00
Sergey A. Osokin
c9c001ee16 Java: upgrading third-party components. 2022-12-14 01:43:24 +00:00
Andrei Zeliankou
6313cffd26 Tests: added tests for the large header buffer settings.
Added tests for the "large_header_buffer_size" and
"large_header_buffers" configuration options.
2022-12-13 14:51:11 +00:00
Andrei Zeliankou
12e2cbae8a Tests: stop execution if can't unmount any filesystem. 2022-12-12 16:27:02 +00:00
Andrei Zeliankou
648e91a623 Tests: pretty output.
Hide expected alerts by default.
Silence succesfull "go build" information.
2022-12-12 16:24:54 +00:00
Andrei Zeliankou
55b9a5307d Tests: fixed tests to run as privileged user. 2022-12-09 14:17:49 +00:00
Andrei Zeliankou
190691ade8 Tests: NJS. 2022-11-29 01:02:08 +00:00
Zhidao HONG
3711632c00 Var: improved variable parsing with empty names.
Unit parsed the case of "$uri$$host" into unknown variables.
This commit makes it invalid variable instead.
2022-11-20 23:11:41 +08:00
Andrei Zeliankou
9ea5ed2813 Tests: fixed _check_processes() checks in "--restart" mode. 2022-11-15 01:07:41 +00:00
Andrei Zeliankou
bb11ef694c Tests: removed migration test.
Migration of "share" behaviour was dropped after b57b4749b993.
2022-11-15 00:56:49 +00:00
Andrei Zeliankou
2c2156e236 Tests: fixed assertion in test_variables_dynamic. 2022-11-15 00:42:12 +00:00
Andrei Zeliankou
0d3b31e671 Tests: features and options checks improved.
Now version output evaluates only once.
OpenSSL checks more carefully.
2022-11-15 00:39:21 +00:00
Andrew Clayton
a03274456b PHP: allowed to specify URLs without a trailing '/'.
Both @lucatacconi & @mwoodpatrick reported what appears to be the same
issue on GitHub. Namely that when using the PHP language module and
trying to access a URL that is a directory but without specifying the
trailing '/', they were getting a '503 Service Unavailable' error.

Note: This is when _not_ using the 'script' option.

E.g with the following config

  {
      "listeners": {
          "[::1]:8080": {
              "pass": "applications/php"
          }
      },

      "applications": {
          "php": {
              "type": "php",
              "root": "/var/tmp/unit-php"
          }
      }
  }

and with a directory path of /var/tmp/unit-php/foo containing an
index.php, you would see the following

  $ curl http://localhost/foo
  <title>Error 503</title>
  Error 503

However

  $ curl http://localhost/foo/

would work and serve up the index.php

This commit fixes the above so you get the desired behaviour without
specifying the trailing '/' by doing the following

  1] If the URL doesn't end in .php and doesn't have a trailing '/'
     then check if the requested path is a directory.

  2) If it is a directory then create a 301 re-direct pointing to it.
     This matches the behaviour of the likes of nginx, Apache and
     lighttpd.

     This also matches the behaviour of the "share" action in Unit.

This doesn't effect the behaviour of the 'script' option which bypasses
the nxt_php_dynamic_request() function.

This also adds a couple of tests to test/test_php_application.py to
ensure this continues to work.

Closes: <https://github.com/nginx/unit/issues/717>
Closes: <https://github.com/nginx/unit/issues/753>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2022-11-02 14:22:39 +00:00
Andrei Zeliankou
af5903ff4e Tests: added tests for the $request_time variable. 2022-10-13 10:13:57 +01:00
Andrei Zeliankou
08dab702cb Tests: reworked "test_variables.py".
Access log used for the variables testing instead of limited routing.
Added missed test for $status variable.
Some tests moved from "test_access_log.py" to "test_variables.py".
2022-10-11 13:49:44 +01:00
Andrei Zeliankou
8e1e047191 Tests: don't try to return response when "no_recv" is True. 2022-10-11 13:49:10 +01:00
Andrei Zeliankou
97fa587c9f Tests: added test with proxy for status. 2022-09-27 12:08:36 +01:00
Zhidao HONG
76df62a623 HTTP: fixed cookie parsing.
The fixing supports the cookie value with the '=' character.

This is related to #756 PR on Github.
Thanks to changxiaocui.
2022-09-19 02:45:44 +08:00
Andrei Zeliankou
c65e04682e Tests: minor fixes. 2022-09-07 01:11:04 +01:00
Andrei Zeliankou
6915ce1d1c Tests: added tests for basic statistics. 2022-09-05 23:06:16 +01:00
Andrei Zeliankou
d1cb8ab2bb Tests: added tests with abstract UNIX sockets. 2022-08-25 15:50:49 +01:00
Andrei Zeliankou
6ddf14a6c1 Tests: added test for ASGI with UNIX socket. 2022-08-16 03:12:12 +01:00
Max Romanov
900828cc4b Fixing isolated process PID manipulation.
Registering an isolated PID in the global PID hash is wrong
because it can be duplicated.  Isolated processes are stored only
in the children list until the response for the WHOAMI message is
processed and the global PID is discovered.

To remove isolated siblings, a pointer to the children list is
introduced in the nxt_process_init_t struct.

This closes #633 issue on GitHub.
2022-08-11 13:33:46 +01:00
Andrei Zeliankou
e5d835e159 Tests: added tests with UNIX sockets in "source". 2022-08-08 10:32:24 +01:00
Andrei Zeliankou
698680d894 Tests: added tests for the log format.
Also added tests for the following variables:
$request_line, $time_local, $bytes_sent, and $status.
2022-07-28 14:13:03 +01:00
Andrei Zeliankou
69e690affe Tests: added flags to search functions in proto.py.
Also removed unnesessary re.compile() calls.
2022-07-28 14:12:19 +01:00
Alejandro Colomar
9b4b4925b3 Ruby: fixed contents of SCRIPT_NAME.
Having the basename of the script pathname was incorrect.  While
we don't have something more accurate, the best thing to do is to
have it empty (which should be the right thing most of the time).

This closes #715 issue on GitHub.

The bug was introduced in git commit
0032543fa6
'Ruby: added the Rack environment parameter "SCRIPT_NAME".'.
2022-07-27 12:46:42 +02:00
Andrew Clayton
02659b1ee3 Tests: added tests for translating $dollar into a literal $.
If you need to specify a $ in a URI you can now use '$dollar' or
'${dollar}'.

Added some tests for the above to test_variables.py setting a Location
string.
2022-07-20 23:28:06 +01:00
Andrei Zeliankou
a1cda6455f Tests: added tests for more HTTP variables. 2022-07-19 17:34:32 +01:00
Andrei Zeliankou
d358b1d448 Tests: added tests for dynamic variables. 2022-07-14 11:50:41 +01:00
Andrei Zeliankou
a3699557a3 Tests: minor improvements.
Added "go" availability check before trying to build an application.

update_action() method used were possible and fixed bug with
the relative path determination in test_static_chroot.py.

Templates optimization and style fixes.
2022-06-30 14:40:17 +01:00
Zhidao HONG
045c05e468 Tests: forwarded header replacement tests. 2022-06-20 17:19:35 +08:00
Zhidao HONG
6da74019a0 Tests: reworked client IP tests. 2022-06-20 13:58:04 +08:00
Andrei Zeliankou
161230b955 Tests: improved test for $request_uri variable. 2022-06-01 16:40:27 +01:00
Andrei Zeliankou
880c8e51c3 Tests: removed deprecated ssl.PROTOCOL_TLSv1_2 constant. 2022-06-01 00:15:15 +01:00
Alejandro Colomar
aee8b9bfb2 Tests: Added tests for $request_uri. 2022-05-31 12:41:11 +02:00
Alejandro Colomar
8027e7ce0f Tests: added tests for "index" (string) option. 2022-05-30 12:42:18 +02:00
Alejandro Colomar
c60f678485 Tests: Added tests for empty "location". 2022-05-16 12:57:37 +02:00
Andrei Zeliankou
de0a0beb83 Tests: added tests for Ruby stream IO.close(). 2022-05-13 15:43:57 +01:00
Andrei Zeliankou
1bffba6d1e Tests: added test for "SCRIPT_NAME" variable in Ruby. 2022-05-10 01:53:23 +01:00
Andrei Zeliankou
03a7701133 Tests: added more tests with reconfiguration. 2022-05-09 10:14:29 +01:00
Alejandro Colomar
d929fbe1a4 Tests: Added tests for variables in "location". 2022-04-28 20:40:01 +02:00
Alejandro Colomar
6d017dfbe4 Tests: Changed tests to accept variables in "location". 2022-04-28 20:40:01 +02:00
Andrei Zeliankou
8138d15f76 Tests: added check for zombie processes. 2022-04-12 04:16:00 +01:00
Andrei Zeliankou
0f72534660 Tests: style. 2022-04-11 21:05:14 +01:00
Andrei Zeliankou
170752e96f Tests: added test with long certificate chain. 2022-02-15 21:43:02 +00:00
Andrei Zeliankou
e53ce40c58 Tests: removed TestApplicationTLS.get_server_certificate().
distutils.version is replaced by packaging.version.  Also minor style fixes.
2022-01-31 23:10:30 +00:00
Max Romanov
1297e8a16a Tests: using modules in Go. 2022-01-10 16:07:31 +03:00
Max Romanov
f845283820 Perl: creating input and error streams if closed.
Application handler can do anything with a stream object (including close it).
Once the stream is closed, Unit creates a new stream.

This closes #616 issue on GitHub.
2021-12-27 16:37:35 +03:00