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.6.2 lib/rack/head.rb
rack-2.2.6.1 lib/rack/head.rb
rack-2.2.6 lib/rack/head.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-2.2.5/lib/rack/head.rb
rack-2.2.5 lib/rack/head.rb
diy_rails-0.1.0 vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/head.rb
tdiary-5.2.3 vendor/bundle/ruby/3.1.0/gems/rack-2.2.4/lib/rack/head.rb
rack-2.2.4 lib/rack/head.rb
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/rack-2.2.3.1/lib/rack/head.rb
rack-2.2.3.1 lib/rack/head.rb
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/head.rb
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/3.1.0/gems/rack-2.2.3/lib/rack/head.rb
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/head.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/rack-2.2.3/lib/rack/head.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/head.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/head.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/head.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/head.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/head.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/head.rb