summaryrefslogtreecommitdiffhomepage
path: root/src/ruby/nxt_ruby.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ruby/nxt_ruby.c')
-rw-r--r--src/ruby/nxt_ruby.c28
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));
}