From f97d16acad300f596c2ab4841553e4d8b7ff0116 Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Thu, 11 Aug 2022 07:22:29 -0700 Subject: [PATCH] Rack 2/3 compat: header keys must be lower-case --- lib/sidekiq/web.rb | 2 +- lib/sidekiq/web/action.rb | 6 +++--- lib/sidekiq/web/application.rb | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/sidekiq/web.rb b/lib/sidekiq/web.rb index 60e26bba..656c7b29 100644 --- a/lib/sidekiq/web.rb +++ b/lib/sidekiq/web.rb @@ -148,7 +148,7 @@ module Sidekiq m = middlewares rules = [] - rules = [[:all, {"Cache-Control" => "public, max-age=86400"}]] unless ENV["SIDEKIQ_WEB_TESTING"] + rules = [[:all, {"cache-control" => "public, max-age=86400"}]] unless ENV["SIDEKIQ_WEB_TESTING"] ::Rack::Builder.new do use Rack::Static, urls: ["/stylesheets", "/images", "/javascripts"], diff --git a/lib/sidekiq/web/action.rb b/lib/sidekiq/web/action.rb index 48133685..2d456429 100644 --- a/lib/sidekiq/web/action.rb +++ b/lib/sidekiq/web/action.rb @@ -15,11 +15,11 @@ module Sidekiq end def halt(res) - throw :halt, [res, {"Content-Type" => "text/plain"}, [res.to_s]] + throw :halt, [res, {"content-type" => "text/plain"}, [res.to_s]] end def redirect(location) - throw :halt, [302, {"Location" => "#{request.base_url}#{location}"}, []] + throw :halt, [302, {"location" => "#{request.base_url}#{location}"}, []] end def params @@ -68,7 +68,7 @@ module Sidekiq end def json(payload) - [200, {"Content-Type" => "application/json", "Cache-Control" => "private, no-store"}, [Sidekiq.dump_json(payload)]] + [200, {"content-type" => "application/json", "cache-control" => "private, no-store"}, [Sidekiq.dump_json(payload)]] end def initialize(env, block) diff --git a/lib/sidekiq/web/application.rb b/lib/sidekiq/web/application.rb index 1ffd3484..274cf790 100644 --- a/lib/sidekiq/web/application.rb +++ b/lib/sidekiq/web/application.rb @@ -312,7 +312,7 @@ module Sidekiq def call(env) action = self.class.match(env) - return [404, {"Content-Type" => "text/plain", "X-Cascade" => "pass"}, ["Not Found"]] unless action + return [404, {"content-type" => "text/plain", "x-cascade" => "pass"}, ["Not Found"]] unless action app = @klass resp = catch(:halt) do @@ -329,10 +329,10 @@ module Sidekiq else # rendered content goes here headers = { - "Content-Type" => "text/html", - "Cache-Control" => "private, no-store", - "Content-Language" => action.locale, - "Content-Security-Policy" => CSP_HEADER + "content-type" => "text/html", + "cache-control" => "private, no-store", + "content-language" => action.locale, + "content-security-policy" => CSP_HEADER } # we'll let Rack calculate Content-Length for us. [200, headers, [resp]]