Sha256: f4bd183081a1d00f22f3d94be77adee5b3cadf1d97c5750eb1f9c4905327da03

Contents?: true

Size: 524 Bytes

Versions: 38

Compression:

Stored size: 524 Bytes

Contents

# frozen_string_literal: true

require_relative 'constants'
require_relative 'body_proxy'

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)
      _, _, body = response = @app.call(env)

      if env[REQUEST_METHOD] == HEAD
        response[2] = Rack::BodyProxy.new([]) do
          body.close if body.respond_to? :close
        end
      end

      response
    end
  end
end

Version data entries

38 entries across 37 versions & 8 rubygems

Version Path
rack-3.1.9 lib/rack/head.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/rack-3.1.7/lib/rack/head.rb
rack-3.1.8 lib/rack/head.rb
rack-3.1.7 lib/rack/head.rb
rack-3.1.6 lib/rack/head.rb
rack-3.1.5 lib/rack/head.rb
rack-3.1.4 lib/rack/head.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/rack-3.1.3/lib/rack/head.rb
rack-3.1.3 lib/rack/head.rb
rack-3.1.2 lib/rack/head.rb
rack-3.1.1 lib/rack/head.rb
rack-3.1.0 lib/rack/head.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/rack-3.0.11/lib/rack/head.rb
rack-3.0.10 lib/rack/head.rb
rack-3.0.9.1 lib/rack/head.rb
mlh-rubocop-config-1.0.3 vendor/bundle/ruby/3.2.0/gems/rack-3.0.9/lib/rack/head.rb
rack-3.0.9 lib/rack/head.rb
mlh-rubocop-config-1.0.2 vendor/bundle/ruby/3.2.0/gems/rack-3.0.8/lib/rack/head.rb
fablicop-1.10.3 vendor/bundle/ruby/3.2.0/gems/rack-3.0.7/lib/rack/head.rb
fablicop-1.10.3 vendor/bundle/ruby/3.2.0/gems/rack-3.0.8/lib/rack/head.rb