summaryrefslogtreecommitdiffhomepage
path: root/src/perl/nxt_perl_psgi.c
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2019-02-27 17:25:07 +0300
committerValentin Bartenev <vbart@nginx.com>2019-02-27 17:25:07 +0300
commite929d08201aae949db25ae8c1051a91e96ba3011 (patch)
tree76af15b49cb67547dbd1942466a6bb360459fc6b /src/perl/nxt_perl_psgi.c
parenta881c31abdb9fda2ba0d2e05c45c2ce890a6cfab (diff)
downloadunit-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/perl/nxt_perl_psgi.c')
-rw-r--r--src/perl/nxt_perl_psgi.c30
1 files changed, 7 insertions, 23 deletions
diff --git a/src/perl/nxt_perl_psgi.c b/src/perl/nxt_perl_psgi.c
index da4a3864..a86fd0de 100644
--- a/src/perl/nxt_perl_psgi.c
+++ b/src/perl/nxt_perl_psgi.c
@@ -68,7 +68,7 @@ static SV *nxt_perl_psgi_env_create(PerlInterpreter *my_perl,
nxt_inline int nxt_perl_psgi_add_sptr(PerlInterpreter *my_perl, HV *hash_env,
const char *name, uint32_t name_len, nxt_unit_sptr_t *sptr, uint32_t len);
nxt_inline int nxt_perl_psgi_add_str(PerlInterpreter *my_perl, HV *hash_env,
- const char *name, uint32_t name_len, char *str, uint32_t len);
+ const char *name, uint32_t name_len, const char *str, uint32_t len);
nxt_inline int nxt_perl_psgi_add_value(PerlInterpreter *my_perl, HV *hash_env,
const char *name, uint32_t name_len, void *value);
@@ -450,8 +450,7 @@ nxt_perl_psgi_env_create(PerlInterpreter *my_perl,
{
HV *hash_env;
AV *array_version;
- char *host_start, *port_start;
- uint32_t i, host_length, port_length;
+ uint32_t i;
nxt_unit_field_t *f;
nxt_unit_request_t *r;
@@ -519,6 +518,10 @@ nxt_perl_psgi_env_create(PerlInterpreter *my_perl,
RC(nxt_perl_psgi_add_sptr(my_perl, hash_env, NL("SERVER_ADDR"),
&r->local, r->local_length));
+ RC(nxt_perl_psgi_add_sptr(my_perl, hash_env, NL("SERVER_NAME"),
+ &r->server_name, r->server_name_length));
+ RC(nxt_perl_psgi_add_str(my_perl, hash_env, NL("SERVER_PORT"), "80", 2));
+
for (i = 0; i < r->fields_count; i++) {
f = r->fields + i;
@@ -541,25 +544,6 @@ nxt_perl_psgi_env_create(PerlInterpreter *my_perl,
&f->value, 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_perl_psgi_add_str(my_perl, hash_env, NL("SERVER_NAME"),
- host_start, host_length));
- RC(nxt_perl_psgi_add_str(my_perl, hash_env, NL("SERVER_PORT"),
- port_start, port_length));
-
#undef NL
#undef RC
@@ -584,7 +568,7 @@ nxt_perl_psgi_add_sptr(PerlInterpreter *my_perl, HV *hash_env,
nxt_inline int
nxt_perl_psgi_add_str(PerlInterpreter *my_perl, HV *hash_env,
- const char *name, uint32_t name_len, char *str, uint32_t len)
+ const char *name, uint32_t name_len, const char *str, uint32_t len)
{
SV **ha;