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
21 def finish
22   r = super
23   case r[0]
24   when 100..199, 204, 304
25     r[2] = EMPTY_ARRAY
26     h = r[1]
27     h.delete(RodaResponseHeaders::CONTENT_LENGTH)
28     h.delete(RodaResponseHeaders::CONTENT_TYPE)
29   when 205
30     r[2] = EMPTY_ARRAY
31     empty_205_headers(r[1])
32   end
33   r
34 end