From e929d08201aae949db25ae8c1051a91e96ba3011 Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Wed, 27 Feb 2019 17:25:07 +0300 Subject: 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. --- src/ruby/nxt_ruby.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'src/ruby') 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)); } -- cgit From 5bfdebb9e4161a689113d73775498949a09d7fb5 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Thu, 28 Feb 2019 18:02:42 +0300 Subject: Introducing Java Servlet Container beta. --- src/ruby/nxt_ruby.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ruby') diff --git a/src/ruby/nxt_ruby.c b/src/ruby/nxt_ruby.c index d099a338..17831175 100644 --- a/src/ruby/nxt_ruby.c +++ b/src/ruby/nxt_ruby.c @@ -76,6 +76,7 @@ NXT_EXPORT nxt_app_module_t nxt_app_module = { compat, nxt_string("ruby"), ruby_version, + NULL, nxt_ruby_init, }; -- cgit From a5dd0f8aa9b81921ff28c486a39fd46607dbdbd9 Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Thu, 28 Feb 2019 20:20:41 +0300 Subject: Made QUERY_STRING mandatory. According to CGI/1.1 RFC 3875: The server MUST set this variable; if the Script-URI does not include a query component, the QUERY_STRING MUST be defined as an empty string (""). Python's PEP 333(3) allows omitting it in WSGI interface; PHP docs force no requirements; PSGI and Rack specifications require it even if empty. When nginx proxies requests over FastCGI, it always provides QUERY_STRING. and some PHP apps have been observed to fail if it is missing (see issue #201 on GitHub). A drawback of this change (besides a small overhead) is that there will be no easy way to tell a missing query string from an empty one (i.e. requests with or without the "?" character); yet, it's negligible compared to the possible benefits of wider application compatibility. This closes #226 issue on GitHub. --- src/ruby/nxt_ruby.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/ruby') diff --git a/src/ruby/nxt_ruby.c b/src/ruby/nxt_ruby.c index 17831175..b2398abe 100644 --- a/src/ruby/nxt_ruby.c +++ b/src/ruby/nxt_ruby.c @@ -442,10 +442,8 @@ nxt_ruby_read_request(VALUE hash_env) nxt_ruby_add_sptr(hash_env, NL("REQUEST_URI"), &r->target, r->target_length); nxt_ruby_add_sptr(hash_env, NL("PATH_INFO"), &r->path, r->path_length); - if (r->query.offset) { - nxt_ruby_add_sptr(hash_env, NL("QUERY_STRING"), &r->query, - r->query_length); - } + nxt_ruby_add_sptr(hash_env, NL("QUERY_STRING"), &r->query, + r->query_length); nxt_ruby_add_sptr(hash_env, NL("SERVER_PROTOCOL"), &r->version, r->version_length); nxt_ruby_add_sptr(hash_env, NL("REMOTE_ADDR"), &r->remote, -- cgit