module Roda::RodaPlugins::DropBody::ResponseMethods

  1. lib/roda/plugins/drop_body.rb

Methods

Public Instance

  1. finish

Constants

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

Public Instance methods

finish()

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

[show source]
   # File lib/roda/plugins/drop_body.rb
24 def finish
25   r = super
26   case r[0]
27   when DROP_BODY_RANGE, 204, 304
28     r[2] = EMPTY_ARRAY
29     h = r[1]
30     h.delete(RodaResponseHeaders::CONTENT_LENGTH)
31     h.delete(RodaResponseHeaders::CONTENT_TYPE)
32   when 205
33     r[2] = EMPTY_ARRAY
34     empty_205_headers(r[1])
35   end
36   r
37 end