Module: Roda::RodaPlugins::DropBody::ResponseMethods

Defined in:
lib/roda/plugins/drop_body.rb

Constant Summary collapse

DROP_BODY_STATUSES =
[100, 101, 102, 204, 205, 304].freeze

Instance Method Summary collapse

Instance Method Details

#finishObject

If the response status indicates a body should not be returned, use an empty body and remove the Content-Length and Content-Type headers.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/roda/plugins/drop_body.rb', line 24

def finish
  r = super
  case r[0]
  when DROP_BODY_RANGE, 204, 304
    r[2] = EMPTY_ARRAY
    h = r[1]
    h.delete(RodaResponseHeaders::CONTENT_LENGTH)
    h.delete(RodaResponseHeaders::CONTENT_TYPE)
  when 205
    r[2] = EMPTY_ARRAY
    empty_205_headers(r[1])
  end
  r
end