lib/roda/plugins/head.rb in roda-3.10.0 vs lib/roda/plugins/head.rb in roda-3.11.0

- old
+ new

@@ -35,10 +35,13 @@ # handle GET. Search engines and other bots may send a # HEAD request prior to crawling a page with a GET request. Without # this plugin those HEAD requests will return a 404 status, which # may prevent search engines from crawling your website. module Head + def self.load_dependencies(app) + app.plugin :_after_hook + end # used to ensure proper resource release on HEAD requests # we do not respond to a to_path method, here. class CloseLater def initialize(body) @@ -54,22 +57,22 @@ @body.close end end module InstanceMethods + private + # Always use an empty response body for head requests, with a # content length of 0. - def call(*) - res = super - if @_request.head? + def _roda_after_30(res) + if res && @_request.head? body = res[2] if body.respond_to?(:close) res[2] = CloseLater.new(body) else res[2] = EMPTY_ARRAY end end - res end end module RequestMethods # Consider HEAD requests as GET requests.