diff --git a/src/http/ngx_http_mruby_request.c b/src/http/ngx_http_mruby_request.c index adf5079a..6ee19719 100644 --- a/src/http/ngx_http_mruby_request.c +++ b/src/http/ngx_http_mruby_request.c @@ -156,7 +156,8 @@ static mrb_value ngx_mrb_get_request_header(mrb_state *mrb, ngx_list_t *headers, i = 0; } - if (ngx_strncasecmp(header[i].key.data, key, key_len) == 0) { + if (header[i].key.len == key_len && + ngx_strncasecmp(header[i].key.data, key, key_len) == 0) { mrb_ary_push(mrb, ary, mrb_str_new(mrb, (const char *)header[i].value.data, header[i].value.len)); } } diff --git a/test/conf/nginx.conf b/test/conf/nginx.conf index 71c55706..ea9ce044 100644 --- a/test/conf/nginx.conf +++ b/test/conf/nginx.conf @@ -928,6 +928,14 @@ http { end '; } + + location /issue-471 { + mruby_content_handler_code ' + h = Nginx::Headers_in.new + Nginx.rputs h["X-Foo"] + Nginx.rputs h["X-Foo-Bar"] + '; + } } server { diff --git a/test/t/ngx_mruby.rb b/test/t/ngx_mruby.rb index 5cfd3467..af8d426b 100644 --- a/test/t/ngx_mruby.rb +++ b/test/t/ngx_mruby.rb @@ -780,6 +780,11 @@ def _run res = HttpRequest.new.get base + '/iv_init_worker' t.assert_equal 'true', res["body"] end + + t.assert('ngx_mruby - BUG: header issue 471', 'location /issue-471') do + res = HttpRequest.new.get base + '/issue-471', nil, {"X-Foo" => "foo", "X-Foo-Bar" => "bar"} + t.assert_equal 'foobar', res["body"] + end end