diff options
author | Max Romanov <max.romanov@nginx.com> | 2020-11-10 22:27:08 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2020-11-10 22:27:08 +0300 |
commit | 5fd2933d2e54a7b5781698a670abf89b1031db44 (patch) | |
tree | 7d682ba1785ac883760331b4d123b0c17eaed10e /src/python/nxt_python.c | |
parent | 4ca9ba34081c44f5d421b171ffaf874fb341d73f (diff) | |
download | unit-5fd2933d2e54a7b5781698a670abf89b1031db44.tar.gz unit-5fd2933d2e54a7b5781698a670abf89b1031db44.tar.bz2 |
Python: supporting ASGI legacy protocol.
Introducing manual protocol selection for 'universal' apps and frameworks.
Diffstat (limited to 'src/python/nxt_python.c')
-rw-r--r-- | src/python/nxt_python.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/python/nxt_python.c b/src/python/nxt_python.c index 26a6f093..faf0c0e1 100644 --- a/src/python/nxt_python.c +++ b/src/python/nxt_python.c @@ -68,6 +68,7 @@ nxt_python_start(nxt_task_t *task, nxt_process_data_t *data) char *nxt_py_module; size_t len; PyObject *obj, *pypath, *module; + nxt_str_t proto; const char *callable; nxt_unit_ctx_t *unit_ctx; nxt_unit_init_t python_init; @@ -82,6 +83,9 @@ nxt_python_start(nxt_task_t *task, nxt_process_data_t *data) static const char bin_python[] = "/bin/python"; #endif + static const nxt_str_t wsgi = nxt_string("wsgi"); + static const nxt_str_t asgi = nxt_string("asgi"); + app_conf = data->app; c = &app_conf->u.python; @@ -244,7 +248,13 @@ nxt_python_start(nxt_task_t *task, nxt_process_data_t *data) python_init.shm_limit = data->app->shm_limit; python_init.callbacks.ready_handler = nxt_python_ready_handler; - if (nxt_python_asgi_check(nxt_py_application)) { + proto = c->protocol; + + if (proto.length == 0) { + proto = nxt_python_asgi_check(nxt_py_application) ? asgi : wsgi; + } + + if (nxt_strstr_eq(&proto, &asgi)) { rc = nxt_python_asgi_init(&python_init, &nxt_py_proto); } else { |