From 9a298f12daf60b50be4762b1cc4b06be6337d2ea Mon Sep 17 00:00:00 2001 From: Corin Langosch Date: Wed, 27 Jul 2011 12:14:05 +0200 Subject: [PATCH 1/2] fixed #11, properly set content-lenght header when serving assets --- lib/rack/webconsole/assets.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rack/webconsole/assets.rb b/lib/rack/webconsole/assets.rb index bada324..ed581bd 100644 --- a/lib/rack/webconsole/assets.rb +++ b/lib/rack/webconsole/assets.rb @@ -41,7 +41,7 @@ def call(env) # Inject the html, css and js code to the view response_body.gsub!('', "#{code}") - headers['Content-Length'] = (response_body.length + 2).to_s + headers['Content-Length'] = response_body.length.to_s [status, headers, [response_body]] end From 0d676803fea0d3acf7bc063982592bda7c6de42f Mon Sep 17 00:00:00 2001 From: Corin Langosch Date: Wed, 27 Jul 2011 13:02:59 +0200 Subject: [PATCH 2/2] fixed #11, content-length has to be set to body#bytesize instead of #length --- lib/rack/webconsole/assets.rb | 2 +- lib/rack/webconsole/repl.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rack/webconsole/assets.rb b/lib/rack/webconsole/assets.rb index ed581bd..dc08794 100644 --- a/lib/rack/webconsole/assets.rb +++ b/lib/rack/webconsole/assets.rb @@ -41,7 +41,7 @@ def call(env) # Inject the html, css and js code to the view response_body.gsub!('', "#{code}") - headers['Content-Length'] = response_body.length.to_s + headers['Content-Length'] = response_body.bytesize.to_s [status, headers, [response_body]] end diff --git a/lib/rack/webconsole/repl.rb b/lib/rack/webconsole/repl.rb index 668cf51..c4c67c3 100644 --- a/lib/rack/webconsole/repl.rb +++ b/lib/rack/webconsole/repl.rb @@ -90,7 +90,7 @@ def call(env) response_body = {:result => result}.to_json headers = {} headers['Content-Type'] = 'application/json' - headers['Content-Length'] = response_body.length.to_s + headers['Content-Length'] = response_body.bytesize.to_s [200, headers, [response_body]] end