ngx_mruby icon indicating copy to clipboard operation
ngx_mruby copied to clipboard

return statement in do ... end block and for loops causes LocalJumpError

Open a2ikm opened this issue 2 years ago • 0 comments

For example, the following locations cause LocalJumpError at their return statements and return 500 Internal Server Error.

location /enable_return_from_block {
    mruby_rewrite_handler_code '
      [0].each do |_|
        r = Nginx::Request.new
        r.headers_out["Location"] = "http://example.com"
        Nginx.return Nginx::HTTP_MOVED_TEMPORARILY
        return
      end
    ';
}

location /enable_return_from_for_statement {
    mruby_rewrite_handler_code '
      for _ in [0]
        r = Nginx::Request.new
        r.headers_out["Location"] = "http://example.com"
        Nginx.return Nginx::HTTP_MOVED_TEMPORARILY
        return
      end
    ';
}

Please check my test results, too: https://github.com/a2ikm/ngx_mruby/pull/2

a2ikm avatar Feb 01 '23 01:02 a2ikm