Class: Rack::Head

Inherits:
Object
  • Object
show all
Defined in:
rack/rack/head.rb

Instance Method Summary (collapse)

Constructor Details

- (Head) initialize(app)

Rack::Head returns an empty body for all HEAD requests. It leaves all other requests unchanged.



6
7
8
# File 'rack/rack/head.rb', line 6

def initialize(app)
  @app = app
end

Instance Method Details

- (void) call(env)



10
11
12
13
14
15
16
17
18
19
# File 'rack/rack/head.rb', line 10

def call(env)
  status, headers, body = @app.call(env)

  if env["REQUEST_METHOD"] == "HEAD"
    body.close if body.respond_to? :close
    [status, headers, []]
  else
    [status, headers, body]
  end
end