summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_python_wsgi.c
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2019-03-21 13:55:57 +0300
committerMax Romanov <max.romanov@nginx.com>2019-03-21 13:55:57 +0300
commit452ce0789e8e8f1ac98cc0ed7efce03656a3d616 (patch)
tree395a7f6964448568ec8521e6cd1338763a9d743f /src/nxt_python_wsgi.c
parent39e147a858e7d135aa224a308b4d41061e00c296 (diff)
downloadunit-452ce0789e8e8f1ac98cc0ed7efce03656a3d616.tar.gz
unit-452ce0789e8e8f1ac98cc0ed7efce03656a3d616.tar.bz2
Adjusting request schema value according to connection tls state.
This closes #223 issue on GitHub.
Diffstat (limited to 'src/nxt_python_wsgi.c')
-rw-r--r--src/nxt_python_wsgi.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/src/nxt_python_wsgi.c b/src/nxt_python_wsgi.c
index 6478f38c..a6d5f217 100644
--- a/src/nxt_python_wsgi.c
+++ b/src/nxt_python_wsgi.c
@@ -619,26 +619,6 @@ nxt_python_create_environ(nxt_task_t *task)
}
- obj = PyString_FromStringAndSize("http", nxt_length("http"));
-
- if (nxt_slow_path(obj == NULL)) {
- nxt_alert(task,
- "Python failed to create the \"wsgi.url_scheme\" environ value");
- goto fail;
- }
-
- if (nxt_slow_path(PyDict_SetItemString(environ, "wsgi.url_scheme", obj)
- != 0))
- {
- nxt_alert(task,
- "Python failed to set the \"wsgi.url_scheme\" environ value");
- goto fail;
- }
-
- Py_DECREF(obj);
- obj = NULL;
-
-
if (nxt_slow_path(PyType_Ready(&nxt_py_input_type) != 0)) {
nxt_alert(task,
"Python failed to initialize the \"wsgi.input\" type object");
@@ -726,6 +706,13 @@ nxt_python_get_environ(nxt_python_run_ctx_t *ctx)
RC(nxt_python_add_sptr(ctx, "REMOTE_ADDR", &r->remote, r->remote_length));
RC(nxt_python_add_sptr(ctx, "SERVER_ADDR", &r->local, r->local_length));
+ if (r->tls) {
+ RC(nxt_python_add_str(ctx, "wsgi.url_scheme", "https", 5));
+
+ } else {
+ RC(nxt_python_add_str(ctx, "wsgi.url_scheme", "http", 4));
+ }
+
RC(nxt_python_add_sptr(ctx, "SERVER_PROTOCOL", &r->version,
r->version_length));