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

mruby_content_handler_code 'Nginx.rputs nil'; not work #225

Open
hfm opened this issue Oct 14, 2016 · 2 comments
Open

mruby_content_handler_code 'Nginx.rputs nil'; not work #225

hfm opened this issue Oct 14, 2016 · 2 comments

Comments

@hfm
Copy link
Collaborator

hfm commented Oct 14, 2016

Using Nginx.rputs nil in mruby_content_handler_code, nginx will stop processing.

sample config:

events {
    worker_connections  1024;
}
error_log logs/error.log debug;
http {
    server {
        listen       50080;
        server_name  localhost;

        location / {
            mruby_content_handler_code 'Nginx.rputs nil';
        }
    }
}

demo with curl:

$ curl http://localhost:50080/ -v
*   Trying ::1...
* connect to ::1 port 50080 failed: Connection refused
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 50080 (#0)
> GET / HTTP/1.1
> Host: localhost:50080
> User-Agent: curl/7.43.0
> Accept: */*
>
^C   ★ stop processing

error.log

2016/10/14 12:01:02 [notice] 13073#0: ngx_mruby NOTICE ngx_http_mruby_shared_state_compile:1027: compile info: code->code.string=(Nginx.rputs nil) code->cache=(1) in /Users/hfm/src/github.com/matsumoto-r/ngx_mruby/build/nginx/conf/nginx.conf:10
2016/10/14 12:01:02 [notice] 13073#0: ngx_mruby/1.18.7 (mruby/1.2.0) mechanism enabled in /Users/hfm/src/github.com/matsumoto-r/ngx_mruby/build/nginx/conf/nginx.conf:13
2016/10/14 12:02:31 [notice] 14767#0: ngx_mruby NOTICE ngx_http_mruby_shared_state_compile:1027: compile info: code->code.string=(Nginx.rputs nil) code->cache=(1) in /Users/hfm/src/github.com/matsumoto-r/ngx_mruby/build/nginx/conf/nginx.conf:11
2016/10/14 12:02:31 [notice] 14767#0: ngx_mruby/1.18.7 (mruby/1.2.0) mechanism enabled in /Users/hfm/src/github.com/matsumoto-r/ngx_mruby/build/nginx/conf/nginx.conf:14
2016/10/14 12:02:31 [notice] 14767#0: using the "kqueue" event method
2016/10/14 12:02:31 [notice] 14767#0: nginx/1.11.5
2016/10/14 12:02:31 [notice] 14767#0: built by clang 8.0.0 (clang-800.0.38)
2016/10/14 12:02:31 [notice] 14767#0: OS: Darwin 15.6.0
2016/10/14 12:02:31 [notice] 14767#0: hw.ncpu: 4
2016/10/14 12:02:31 [notice] 14767#0: net.inet.tcp.sendspace: 131072
2016/10/14 12:02:31 [notice] 14767#0: kern.ipc.somaxconn: 128
2016/10/14 12:02:31 [notice] 14767#0: getrlimit(RLIMIT_NOFILE): 4864:9223372036854775807
2016/10/14 12:02:31 [notice] 14768#0: start worker processes
2016/10/14 12:02:31 [notice] 14768#0: start worker process 14769
2016/10/14 12:02:32 [info] 14769#0: *1 hooked mruby inline content code: Nginx.rputs nil, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost:50080"
2016/10/14 12:02:32 [info] 14769#0: *1 ngx_mruby INFO ngx_mrb_run:825: mrb_run info: rputs_chain is null and return NGX_OK, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost:50080"
2016/10/14 12:02:33 [info] 14769#0: *1 kevent() reported that client 127.0.0.1 closed keepalive connection

This problem seems to be simillar to #200. Current mruby_content_handler_code does not allow return empty body.

@matsumotory
Copy link
Owner

Thank you for your report. I'll investigate later.

yyamano added a commit to yyamano/ngx_mruby that referenced this issue Jun 9, 2017
yyamano added a commit to yyamano/ngx_mruby that referenced this issue Jun 14, 2017
yyamano added a commit to yyamano/ngx_mruby that referenced this issue Nov 12, 2018
@yyamano
Copy link
Collaborator

yyamano commented Nov 12, 2018

Still doesn't work with the latest version of ngx_mruby. I just rebased the branch for test code at https://github.com/yyamano/ngx_mruby/tree/issue-200

2018/11/11 20:59:43 [info] 15231#0: *121 hooked mruby inline content code: Nginx.return 200, client: 127.0.0.1, server: localhost, request: "GET /issue-200 HTTP/1.0", host: "127.0.0.1"
2018/11/11 20:59:43 [error] 15231#0: *121 ngx_mruby ERROR ngx_mrb_send_header: status code is 200, but response body is empty. return NGX_HTTP_INTERNAL_SERVER_ERROR, client: 127.0.0.1, server: localhost, request: "GET /issue-200 HTTP/1.0", host: "127.0.0.1"
2018/11/11 20:59:43 [info] 15231#0: *121 ngx_mruby INFO ngx_mrb_run:854: already finish this fiber, can not resume, client: 127.0.0.1, server: localhost, request: "GET /issue-200 HTTP/1.0", host: "127.0.0.1"
2018/11/11 20:59:43 [info] 15231#0: *121 ngx_mruby INFO ngx_mrb_finalize_rputs:95: mrb_run info: rputs_chain is null and return NGX_OK, client: 127.0.0.1, server: localhost, request: "GET /issue-200 HTTP/1.0", host: "127.0.0.1"
2018/11/11 20:59:43 [debug] 15231#0: *121 http finalize request: 500, "/issue-200?" a:1, c:1
2018/11/11 20:59:43 [debug] 15231#0: *121 http special response: 500, "/issue-200?"
2018/11/11 20:59:43 [debug] 15231#0: *121 http set discard body
2018/11/11 20:59:43 [debug] 15231#0: *121 HTTP/1.1 500 Internal Server Error

yyamano added a commit to yyamano/ngx_mruby that referenced this issue Aug 15, 2020
yyamano added a commit to yyamano/ngx_mruby that referenced this issue Aug 15, 2020
yyamano added a commit to yyamano/ngx_mruby that referenced this issue Aug 18, 2020
yyamano added a commit to yyamano/ngx_mruby that referenced this issue Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants