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/ruby | |
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/ruby')
-rw-r--r-- | src/ruby/nxt_ruby.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/src/ruby/nxt_ruby.c b/src/ruby/nxt_ruby.c index a08b8189..d099a338 100644 --- a/src/ruby/nxt_ruby.c +++ b/src/ruby/nxt_ruby.c @@ -45,7 +45,7 @@ static int nxt_ruby_read_request(VALUE hash_env); nxt_inline void nxt_ruby_add_sptr(VALUE hash_env, const char *name, uint32_t name_len, nxt_unit_sptr_t *sptr, uint32_t len); nxt_inline void nxt_ruby_add_str(VALUE 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); static nxt_int_t nxt_ruby_rack_result_status(VALUE result); static int nxt_ruby_rack_result_headers(VALUE result, nxt_int_t status); static int nxt_ruby_hash_info(VALUE r_key, VALUE r_value, VALUE arg); @@ -428,8 +428,7 @@ fail: static int nxt_ruby_read_request(VALUE hash_env) { - 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; @@ -452,6 +451,10 @@ nxt_ruby_read_request(VALUE hash_env) r->remote_length); nxt_ruby_add_sptr(hash_env, NL("SERVER_ADDR"), &r->local, r->local_length); + nxt_ruby_add_sptr(hash_env, NL("SERVER_NAME"), &r->server_name, + r->server_name_length); + nxt_ruby_add_str(hash_env, NL("SERVER_PORT"), "80", 2); + for (i = 0; i < r->fields_count; i++) { f = r->fields + i; @@ -473,23 +476,6 @@ nxt_ruby_read_request(VALUE hash_env) &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); - - nxt_ruby_add_str(hash_env, NL("SERVER_NAME"), host_start, host_length); - nxt_ruby_add_str(hash_env, NL("SERVER_PORT"), port_start, port_length); - #undef NL return NXT_UNIT_OK; @@ -510,7 +496,7 @@ nxt_ruby_add_sptr(VALUE hash_env, nxt_inline void nxt_ruby_add_str(VALUE 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) { rb_hash_aset(hash_env, rb_str_new(name, name_len), rb_str_new(str, len)); } |