Sha256: 66615d513159877b39a87cd71de31edd0bfcdb9abdecd3cf5fb180df2d3ebc24
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
# frozen-string-literal: true # class Roda module RodaPlugins # The drop_body plugin automatically drops the body and # Content-Type/Content-Length headers from the response if # the response status indicates that the response should # not include a body (response statuses 100, 101, 102, 204, 205, # and 304). module DropBody module ResponseMethods DROP_BODY_STATUSES = [100, 101, 102, 204, 205, 304].freeze EMPTY_BODY = [].freeze CONTENT_LENGTH = "Content-Length".freeze RodaPlugins.deprecate_constant(self, :CONTENT_LENGTH) CONTENT_TYPE = "Content-Type".freeze RodaPlugins.deprecate_constant(self, :CONTENT_TYPE) # If the response status indicates a body should not be # returned, use an empty body and remove the Content-Length # and Content-Type headers. def finish r = super if DROP_BODY_STATUSES.include?(r[0]) r[2] = EMPTY_BODY h = r[1] h.delete("Content-Length") h.delete("Content-Type") end r end end end register_plugin(:drop_body, DropBody) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
roda-2.28.0 | lib/roda/plugins/drop_body.rb |