Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Nginx::Headers_in[] returns wrong value. Fixed #471. #472

Merged
merged 1 commit into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/http/ngx_http_mruby_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
8 changes: 8 additions & 0 deletions test/conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions test/t/ngx_mruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down