diff options
author | Valentin Bartenev <vbart@nginx.com> | 2019-02-27 17:25:07 +0300 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2019-02-27 17:25:07 +0300 |
commit | e929d08201aae949db25ae8c1051a91e96ba3011 (patch) | |
tree | 76af15b49cb67547dbd1942466a6bb360459fc6b /src/nxt_python_wsgi.c | |
parent | a881c31abdb9fda2ba0d2e05c45c2ce890a6cfab (diff) | |
download | unit-e929d08201aae949db25ae8c1051a91e96ba3011.tar.gz unit-e929d08201aae949db25ae8c1051a91e96ba3011.tar.bz2 |
Fixed processing of SERVER_NAME after 77aad2c142a0.
Previously, the nxt_router_prepare_msg() function expected server host among
other headers unmodified. It's not true anymore since normalization of the
Host header has been introduced in 77aad2c142a0.
The nxt_unit_split_host() function was removed. It didn't work correctly with
IPv6 literals. Anyway, after 77aad2c142a0 the port splitting is done in router
while Host header processing.
Diffstat (limited to 'src/nxt_python_wsgi.c')
-rw-r--r-- | src/nxt_python_wsgi.c | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/src/nxt_python_wsgi.c b/src/nxt_python_wsgi.c index bd3a2cb2..871c8e91 100644 --- a/src/nxt_python_wsgi.c +++ b/src/nxt_python_wsgi.c @@ -72,7 +72,7 @@ static PyObject *nxt_python_get_environ(nxt_python_run_ctx_t *ctx); static int nxt_python_add_sptr(nxt_python_run_ctx_t *ctx, const char *name, nxt_unit_sptr_t *sptr, uint32_t size); static int nxt_python_add_str(nxt_python_run_ctx_t *ctx, const char *name, - char *str, uint32_t size); + const char *str, uint32_t size); static PyObject *nxt_py_start_resp(PyObject *self, PyObject *args); static int nxt_python_response_add_field(nxt_python_run_ctx_t *ctx, @@ -690,8 +690,8 @@ static PyObject * nxt_python_get_environ(nxt_python_run_ctx_t *ctx) { int rc; - char *name, *host_start, *port_start; - uint32_t i, host_length, port_length; + char *name; + uint32_t i; PyObject *environ; nxt_unit_field_t *f; nxt_unit_request_t *r; @@ -732,6 +732,10 @@ nxt_python_get_environ(nxt_python_run_ctx_t *ctx) RC(nxt_python_add_sptr(ctx, "SERVER_PROTOCOL", &r->version, r->version_length)); + RC(nxt_python_add_sptr(ctx, "SERVER_NAME", &r->server_name, + r->server_name_length)); + RC(nxt_python_add_str(ctx, "SERVER_PORT", "80", 2)); + for (i = 0; i < r->fields_count; i++) { f = r->fields + i; name = nxt_unit_sptr_get(&f->name); @@ -753,23 +757,6 @@ nxt_python_get_environ(nxt_python_run_ctx_t *ctx) f->value_length)); } - if (r->host_field != NXT_UNIT_NONE_FIELD) { - f = r->fields + r->host_field; - - host_start = nxt_unit_sptr_get(&f->value); - host_length = f->value_length; - - } else { - host_start = NULL; - host_length = 0; - } - - nxt_unit_split_host(host_start, host_length, &host_start, &host_length, - &port_start, &port_length); - - RC(nxt_python_add_str(ctx, "SERVER_NAME", host_start, host_length)); - RC(nxt_python_add_str(ctx, "SERVER_PORT", port_start, port_length)); - #undef RC return environ; @@ -818,7 +805,7 @@ nxt_python_add_sptr(nxt_python_run_ctx_t *ctx, const char *name, static int nxt_python_add_str(nxt_python_run_ctx_t *ctx, const char *name, - char *str, uint32_t size) + const char *str, uint32_t size) { PyObject *value; |