summaryrefslogtreecommitdiffhomepage
path: root/src/python/nxt_python_asgi.c
diff options
context:
space:
mode:
authorAndrew Clayton <a.clayton@nginx.com>2025-07-04 16:38:25 +0100
committerAndrew Clayton <a.clayton@nginx.com>2025-07-25 04:49:45 +0100
commitc8b859e373089d3f347efb806c9926823de41bf6 (patch)
tree96f080acede9233e2b13e657ac371f1867fd8a90 /src/python/nxt_python_asgi.c
parenta9071e11602ec73b96302c852709c16c9d55996d (diff)
downloadunit-c8b859e373089d3f347efb806c9926823de41bf6.tar.gz
unit-c8b859e373089d3f347efb806c9926823de41bf6.tar.bz2
Set SERVER_PORT appropriately
The Perl, PHP, Python, Ruby & Java language modules all hard code SERVER_PORT to "80". Adjust them to bring them in line with the wasm language module which uses r->local_port (I.e. the port unit accepted the connection on). Closes: https://github.com/nginx/unit/issues/761 Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'src/python/nxt_python_asgi.c')
-rw-r--r--src/python/nxt_python_asgi.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/python/nxt_python_asgi.c b/src/python/nxt_python_asgi.c
index 702f4d8d..a123e941 100644
--- a/src/python/nxt_python_asgi.c
+++ b/src/python/nxt_python_asgi.c
@@ -644,6 +644,7 @@ nxt_py_asgi_create_http_scope(nxt_unit_request_info_t *req,
PyObject *scope, *v, *type, *scheme;
PyObject *headers, *header;
nxt_str_t prefix;
+ unsigned long port;
nxt_unit_field_t *f;
nxt_unit_request_t *r;
@@ -752,7 +753,10 @@ nxt_py_asgi_create_http_scope(nxt_unit_request_info_t *req,
SET_ITEM(scope, client, v)
Py_DECREF(v);
- v = nxt_py_asgi_create_address(&r->local_addr, r->local_addr_length, 80);
+ p = nxt_unit_sptr_get(&r->local_port);
+ port = strtoul(p, NULL, 10);
+
+ v = nxt_py_asgi_create_address(&r->local_addr, r->local_addr_length, port);
if (nxt_slow_path(v == NULL)) {
nxt_unit_req_alert(req, "Python failed to create 'server' pair");
goto fail;