Add If-None-Match support to Server::ETag
This commit is contained in:
parent
b048016dc9
commit
d5704b0813
1 changed files with 6 additions and 2 deletions
|
@ -1,15 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Server::ETag < Rack::ETag
|
||||
ETAGS = {}
|
||||
|
||||
def initialize(app)
|
||||
@app = app
|
||||
end
|
||||
|
||||
def call(env)
|
||||
status, headers, body = super(env)
|
||||
if env["HTTP_IF_NONE_MATCH"] == headers["etag"]
|
||||
headers = ETAGS[env["REQUEST_PATH"]] || {}
|
||||
if headers["etag"] && headers["etag"] == env["HTTP_IF_NONE_MATCH"]
|
||||
[304, headers, [""]]
|
||||
else
|
||||
status, headers, body = super(env)
|
||||
ETAGS[env["REQUEST_PATH"]] = headers
|
||||
[status, headers, body]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue