diff --git a/lib/web_console/injector.rb b/lib/web_console/injector.rb index 1f172038..d3bb3253 100644 --- a/lib/web_console/injector.rb +++ b/lib/web_console/injector.rb @@ -16,7 +16,7 @@ def inject(content) # Set Content-Length header to the size of the current body # + the extra content. Otherwise the response will be truncated. if @headers["Content-Length"] - @headers["Content-Length"] = @body.bytesize + content.bytesize + @headers["Content-Length"] = (@body.bytesize + content.bytesize).to_s end [ diff --git a/test/web_console/injector_test.rb b/test/web_console/injector_test.rb index 7628baf2..277fa976 100644 --- a/test/web_console/injector_test.rb +++ b/test/web_console/injector_test.rb @@ -32,7 +32,7 @@ class InjectorTest < ActiveSupport::TestCase body = [ "foo" ] headers = { "Content-Length" => 3 } - assert_equal [ [ "foobar" ], { "Content-Length" => 6 } ], Injector.new(body, headers).inject("bar") + assert_equal [ [ "foobar" ], { "Content-Length" => "6" } ], Injector.new(body, headers).inject("bar") end end end