From 675e40c32684a7e89987673b82b5241545763fcb Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Thu, 30 Jan 2020 08:52:31 -0800 Subject: [PATCH] Don't calculate Content-Length, let Rack do that for us; fixes #4440 --- Changes.md | 5 +++++ lib/sidekiq/web/application.rb | 8 +++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Changes.md b/Changes.md index 15fe384f1..de5a411bb 100644 --- a/Changes.md +++ b/Changes.md @@ -2,6 +2,11 @@ [Sidekiq Changes](https://github.com/mperham/sidekiq/blob/master/Changes.md) | [Sidekiq Pro Changes](https://github.com/mperham/sidekiq/blob/master/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/mperham/sidekiq/blob/master/Ent-Changes.md) +HEAD +--------- + +- Fix broken Web UI response when using NewRelic and Rack 2.1.2+. [#4440] + 6.0.4 --------- diff --git a/lib/sidekiq/web/application.rb b/lib/sidekiq/web/application.rb index 6b6e961ad..795154972 100644 --- a/lib/sidekiq/web/application.rb +++ b/lib/sidekiq/web/application.rb @@ -300,22 +300,20 @@ def call(env) resp = case resp when Array + # redirects go here resp else + # rendered content goes here headers = { "Content-Type" => "text/html", "Cache-Control" => "no-cache", "Content-Language" => action.locale, "Content-Security-Policy" => CSP_HEADER, } - + # we'll let Rack calculate Content-Length for us. [200, headers, [resp]] end - resp[1] = resp[1].dup - - resp[1][CONTENT_LENGTH] = resp[2].sum(&:bytesize).to_s - resp end