Fix HEAD response header for brid.gy

This commit is contained in:
2023-12-20 22:35:27 +11:00
parent 019b1bab4b
commit a7678abe92
6 changed files with 41 additions and 2 deletions

View File

@@ -0,0 +1,24 @@
require "rack"
require "rack/contrib"
module Adamantium
module Middleware
class HeaderFix
HEADERS_KLASS = Rack.release < "3" ? Rack::Utils::HeaderHash : Rack::Headers
private_constant :HEADERS_KLASS
def initialize(app, &block)
@app = app
@block = block
end
def call(env)
response = @app.call(env)
headers = HEADERS_KLASS.new.merge(response[1])
@block.call(headers, env)
response[1] = headers
response
end
end
end
end