Skip to content

Commit

Permalink
Don't calculate Content-Length, let Rack do that for us; fixes #4440
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Jan 30, 2020
1 parent 4f630ad commit 675e40c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Changes.md
Expand Up @@ -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
---------

Expand Down
8 changes: 3 additions & 5 deletions lib/sidekiq/web/application.rb
Expand Up @@ -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

Expand Down

0 comments on commit 675e40c

Please sign in to comment.