Commit graph

5 commits

Author SHA1 Message Date
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
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
Andrei Zeliankou
9bea8c452f Tests: fixed type of applications. 2021-12-12 21:36:44 +00:00
Andrei Zeliankou
39adb292d5 Tests: style. 2021-10-18 01:10:11 +01:00
Oisin Canty
e50bb120e2 Tests: Python targets. 2021-05-20 13:03:12 +00:00