Method: Rack::ConditionalGet#call
- Defined in:
- lib/rack/conditional_get.rb
#call(env) ⇒ Object
Return empty 304 response if the response has not been modified since the last request.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rack/conditional_get.rb', line 28 def call(env) case env[REQUEST_METHOD] when "GET", "HEAD" status, headers, body = response = @app.call(env) if status == 200 && fresh?(env, headers) response[0] = 304 headers.delete(CONTENT_TYPE) headers.delete(CONTENT_LENGTH) # We are done with the body: body.close if body.respond_to?(:close) response[2] = [] end response else @app.call(env) end end |