Skip to content
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
2 changes: 2 additions & 0 deletions lib/fluent/plugin_helper/http_server/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def call(request)
path
end
@router.route!(name, canonical_path, req)
ensure
request.body&.close
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions test/plugin_helper/http_server/test_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down