diff --git a/lib/fluent/plugin_helper/http_server/app.rb b/lib/fluent/plugin_helper/http_server/app.rb index fe8581e1c4..f0456a9b0d 100644 --- a/lib/fluent/plugin_helper/http_server/app.rb +++ b/lib/fluent/plugin_helper/http_server/app.rb @@ -71,6 +71,8 @@ def call(request) path end @router.route!(name, canonical_path, req) + ensure + request.body&.close end end end diff --git a/test/plugin_helper/http_server/test_app.rb b/test/plugin_helper/http_server/test_app.rb index 61ef7b76af..bded72f31f 100644 --- a/test/plugin_helper/http_server/test_app.rb +++ b/test/plugin_helper/http_server/test_app.rb @@ -37,7 +37,7 @@ def route!(method, path, _req) test 'dispatch correct path' do |method| r = DummyRouter.new(method.downcase.to_sym => { '/path/' => 'hi' }) app = Fluent::PluginHelper::HttpServer::App.new(r, NULL_LOGGER) - m = flexmock('request', method: method, path: '/path/') + m = flexmock('request', method: method, path: '/path/', body: nil) r = app.call(m) assert_equal(r.body.read, 'hi') assert_equal(r.status, 200) @@ -46,7 +46,7 @@ def route!(method, path, _req) test 'dispatch correct path for head' do |method| r = DummyRouter.new(head: { '/path/' => 'hi' }) app = Fluent::PluginHelper::HttpServer::App.new(r, NULL_LOGGER) - m = flexmock('request', method: method, path: '/path') + m = flexmock('request', method: method, path: '/path', body: nil) r = app.call(m) assert_equal(r.body.read, '') assert_equal(r.status, 200) @@ -55,7 +55,7 @@ def route!(method, path, _req) test 'if path does not end with `/`' do |method| r = DummyRouter.new(head: { '/path/' => 'hi' }) app = Fluent::PluginHelper::HttpServer::App.new(r, NULL_LOGGER) - m = flexmock('request', method: method, path: '/path') + m = flexmock('request', method: method, path: '/path', body: nil) r = app.call(m) assert_equal(r.body.read, '') assert_equal(r.status, 200)