Sha256: 3963238648c2a4acfb899584dec4e2af7b78f756e4becd6749af2d378437916b

Contents?: true

Size: 520 Bytes

Versions: 62

Compression:

Stored size: 520 Bytes

Contents

# frozen_string_literal: true

module Rack
  # Rack::Head returns an empty body for all HEAD requests. It leaves
  # all other requests unchanged.
  class Head
    def initialize(app)
      @app = app
    end

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

      if env[REQUEST_METHOD] == HEAD
        [
          status, headers, Rack::BodyProxy.new([]) do
            body.close if body.respond_to? :close
          end
        ]
      else
        [status, headers, body]
      end
    end
  end
end

Version data entries

62 entries across 47 versions & 14 rubygems

Version Path
rack-2.2.10 lib/rack/head.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rack-2.2.9/lib/rack/head.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/rack-2.2.7/lib/rack/head.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/rack-2.2.7/lib/rack/head.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/rack-2.2.7/lib/rack/head.rb
rack-2.2.9 lib/rack/head.rb
rack-2.2.8.1 lib/rack/head.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rack-2.2.7/lib/rack/head.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rack-2.2.4/lib/rack/head.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rack-2.2.3/lib/rack/head.rb
rack-2.2.8 lib/rack/head.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rack-2.2.7/lib/rack/head.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rack-2.2.4/lib/rack/head.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rack-2.2.3/lib/rack/head.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/head.rb
rack-2.2.7 lib/rack/head.rb
rack-2.2.6.4 lib/rack/head.rb
rack-2.2.6.3 lib/rack/head.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/head.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/head.rb