Module: Lotus::Action::Head

Defined in:
lib/lotus/action/head.rb

Overview

Ensures to not send body or headers for HEAD requests and/or for status codes that doesn’t allow them.

See Also:

Since:

  • 0.3.2

Constant Summary collapse

HTTP_STATUSES_WITHOUT_BODY =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Status codes that by RFC must not include a message body

Since:

  • 0.3.2

Set.new((100..199).to_a << 204 << 205 << 304).freeze
ENTITY_HEADERS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Entity headers allowed in blank body responses, according to RFC 2616 - Section 10 (HTTP 1.1).

“The response MAY include new or updated metainformation in the form

of entity-headers".
{
  'Allow'            => true,
  'Content-Encoding' => true,
  'Content-Language' => true,
  'Content-Location' => true,
  'Content-MD5'      => true,
  'Content-Range'    => true,
  'Expires'          => true,
  'Last-Modified'    => true,
  'extension-header' => true
}.freeze

Instance Method Summary collapse

Instance Method Details

#finishObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Ensures to not send body or headers for HEAD requests and/or for status codes that doesn’t allow them.

See Also:

  • Lotus::Action#finish

Since:

  • 0.3.2



48
49
50
51
52
53
54
55
# File 'lib/lotus/action/head.rb', line 48

def finish
  super

  if _requires_no_body?
    @_body = nil
    @headers.reject! {|header,_| !keep_response_header?(header) }
  end
end