Fix HEAD response header for brid.gy
This commit is contained in:
24
lib/adamantium/middleware/header_fix.rb
Normal file
24
lib/adamantium/middleware/header_fix.rb
Normal 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
|
Reference in New Issue
Block a user